feat: print seed value when args.seed < 0

This commit is contained in:
leejet 2023-08-22 23:03:17 +08:00
parent 721cb324af
commit 0d7f04b135

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <ctime>
#include <fstream>
#include <iostream>
#include <random>
@ -36,8 +37,7 @@ int32_t get_num_physical_cores() {
// enumerate the set of thread siblings, num entries is num cores
std::unordered_set<std::string> siblings;
for (uint32_t cpu = 0; cpu < UINT32_MAX; ++cpu) {
std::ifstream thread_siblings("/sys/devices/system/cpu"
+ std::to_string(cpu) + "/topology/thread_siblings");
std::ifstream thread_siblings("/sys/devices/system/cpu" + std::to_string(cpu) + "/topology/thread_siblings");
if (!thread_siblings.is_open()) {
break; // no more cpus
}
@ -282,6 +282,11 @@ void parse_args(int argc, const char* argv[], Option* opt) {
fprintf(stderr, "error: can only work with strength in [0.0, 1.0]\n");
exit(1);
}
if (opt->seed < 0) {
srand((int)time(NULL));
opt->seed = rand();
}
}
int main(int argc, const char* argv[]) {