diff options
Diffstat (limited to 'tools/000_gendata')
| -rw-r--r-- | tools/000_gendata/gendata.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c new file mode 100644 index 0000000..90166dd --- /dev/null +++ b/tools/000_gendata/gendata.c | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | #include "../expected_distributions.h" | ||
| 3 | |||
| 4 | char *solver, *options; | ||
| 5 | uint64_t *expected; | ||
| 6 | |||
| 7 | static void | ||
| 8 | run(void) { | ||
| 9 | int64_t size; | ||
| 10 | char *buf, filename[1024]; | ||
| 11 | |||
| 12 | getfilename(solver, options, filename); | ||
| 13 | size = generatetable(solver, options, &buf); | ||
| 14 | switch (size) { | ||
| 15 | case -1: | ||
| 16 | return; | ||
| 17 | case -2: | ||
| 18 | goto gendata_run_finish; | ||
| 19 | default: | ||
| 20 | nissy_datainfo(buf, write_stdout); | ||
| 21 | printf("\n"); | ||
| 22 | printf("Succesfully generated %" PRId64 " bytes. " | ||
| 23 | "See above for details on the tables.\n", size); | ||
| 24 | |||
| 25 | writetable(buf, size, filename); | ||
| 26 | break; | ||
| 27 | } | ||
| 28 | |||
| 29 | gendata_run_finish: | ||
| 30 | free(buf); | ||
| 31 | } | ||
| 32 | |||
| 33 | int main(int argc, char **argv) { | ||
| 34 | uint8_t h, k; | ||
| 35 | char description[256]; | ||
| 36 | |||
| 37 | if (argc < 3) { | ||
| 38 | fprintf(stderr, "Error: not enough arguments. " | ||
| 39 | "A solver and its options must be given.\n"); | ||
| 40 | return 1; | ||
| 41 | } | ||
| 42 | |||
| 43 | solver = argv[1]; | ||
| 44 | options = argv[2]; | ||
| 45 | parse_h48_options(options, &h, &k, NULL); | ||
| 46 | expected = expected_h48[h][k]; | ||
| 47 | sprintf(description, "benchmark gendata_h48 h = %" PRIu8 | ||
| 48 | ", k = %" PRIu8 "", h, k); | ||
| 49 | |||
| 50 | nissy_setlogger(log_stderr); | ||
| 51 | |||
| 52 | timerun(run, description); | ||
| 53 | |||
| 54 | return 0; | ||
| 55 | } | ||
