Commit 560dc684 authored by Nathan Egge's avatar Nathan Egge

Reset the random seed when testing each CPU type.

Any benchmark that uses random data as input gives bunk results as it
 currently uses differently random data on each run.
This now makes any non-determinism in the tests repeatable across each
 call to check_cpu_flags() and checkasm_check_func().
parent 06331de1
Pipeline #3033 passed with stages
in 7 minutes and 53 seconds
......@@ -133,6 +133,7 @@ static struct {
unsigned cpu_flag;
const char *cpu_flag_name;
const char *test_name;
unsigned int seed;
} state;
/* float compare support code */
......@@ -413,6 +414,7 @@ static void check_cpu_flag(const char *const name, unsigned flag) {
for (int i = 0; tests[i].func; i++) {
if (state.test_name && strcmp(tests[i].name, state.test_name))
continue;
srand(state.seed);
state.current_test_name = tests[i].name;
tests[i].func();
}
......@@ -429,7 +431,7 @@ static void print_cpu_name(void) {
int main(int argc, char *argv[]) {
(void)func_new, (void)func_ref;
unsigned int seed = get_seed();
state.seed = get_seed();
int ret = 0;
while (argc > 1) {
......@@ -447,15 +449,14 @@ int main(int argc, char *argv[]) {
} else if (!strncmp(argv[1], "--test=", 7)) {
state.test_name = argv[1] + 7;
} else {
seed = strtoul(argv[1], NULL, 10);
state.seed = strtoul(argv[1], NULL, 10);
}
argc--;
argv++;
}
fprintf(stderr, "checkasm: using random seed %u\n", seed);
srand(seed);
fprintf(stderr, "checkasm: using random seed %u\n", state.seed);
check_cpu_flag(NULL, 0);
for (int i = 0; cpus[i].flag; i++)
......@@ -521,6 +522,7 @@ void *checkasm_check_func(void *const func, const char *const name, ...) {
v->ok = 1;
v->cpu = state.cpu_flag;
state.current_func_ver = v;
srand(state.seed);
if (state.cpu_flag)
state.num_checked++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment