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