diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/000_gendata/gendata.c | 29 | ||||
| -rw-r--r-- | tools/100_checkdata/checkdata.c | 52 | ||||
| -rw-r--r-- | tools/expected_distributions.h | 25 |
3 files changed, 79 insertions, 27 deletions
diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c index 78f81ab..90166dd 100644 --- a/tools/000_gendata/gendata.c +++ b/tools/000_gendata/gendata.c | |||
| @@ -1,34 +1,9 @@ | |||
| 1 | #include "../tool.h" | 1 | #include "../tool.h" |
| 2 | #include "../expected_distributions.h" | ||
| 2 | 3 | ||
| 3 | char *solver, *options; | 4 | char *solver, *options; |
| 4 | uint64_t *expected; | 5 | uint64_t *expected; |
| 5 | 6 | ||
| 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 | 7 | static void |
| 33 | run(void) { | 8 | run(void) { |
| 34 | int64_t size; | 9 | int64_t size; |
| @@ -60,7 +35,7 @@ int main(int argc, char **argv) { | |||
| 60 | char description[256]; | 35 | char description[256]; |
| 61 | 36 | ||
| 62 | if (argc < 3) { | 37 | if (argc < 3) { |
| 63 | fprintf(stderr, "Error: not enough arguments." | 38 | fprintf(stderr, "Error: not enough arguments. " |
| 64 | "A solver and its options must be given.\n"); | 39 | "A solver and its options must be given.\n"); |
| 65 | return 1; | 40 | return 1; |
| 66 | } | 41 | } |
diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c new file mode 100644 index 0000000..05961c1 --- /dev/null +++ b/tools/100_checkdata/checkdata.c | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | #include "../expected_distributions.h" | ||
| 3 | |||
| 4 | char *solver, *options, *filename; | ||
| 5 | |||
| 6 | static void | ||
| 7 | run(void) { | ||
| 8 | int64_t size; | ||
| 9 | char *buf; | ||
| 10 | FILE *f; | ||
| 11 | |||
| 12 | size = nissy_datasize(solver, options); | ||
| 13 | |||
| 14 | if (size <= 0) { | ||
| 15 | fprintf(stderr, "Error in datasize\n"); | ||
| 16 | return; | ||
| 17 | } | ||
| 18 | |||
| 19 | if ((f = fopen(filename, "rb")) == NULL) { | ||
| 20 | fprintf(stderr, "Error reading file %s\n", filename); | ||
| 21 | return; | ||
| 22 | } | ||
| 23 | |||
| 24 | buf = malloc(size); | ||
| 25 | fread(buf, size, 1, f); | ||
| 26 | fclose(f); | ||
| 27 | nissy_checkdata(solver, options, buf); | ||
| 28 | free(buf); | ||
| 29 | |||
| 30 | /* TODO: cross-check with expected distributions? */ | ||
| 31 | } | ||
| 32 | |||
| 33 | int main(int argc, char **argv) { | ||
| 34 | char description[256]; | ||
| 35 | |||
| 36 | if (argc < 4) { | ||
| 37 | fprintf(stderr, "Error: not enough arguments. " | ||
| 38 | "A solver, its options and a file name must be given.\n"); | ||
| 39 | return 1; | ||
| 40 | } | ||
| 41 | |||
| 42 | solver = argv[1]; | ||
| 43 | options = argv[2]; | ||
| 44 | filename = argv[3]; | ||
| 45 | sprintf(description, "checking data for solver %s" | ||
| 46 | "with options %s from file %s", solver, options, filename); | ||
| 47 | nissy_setlogger(log_stderr); | ||
| 48 | |||
| 49 | timerun(run, description); | ||
| 50 | |||
| 51 | return 0; | ||
| 52 | } | ||
diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h new file mode 100644 index 0000000..27bd64a --- /dev/null +++ b/tools/expected_distributions.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | uint64_t expected_h48[12][9][21] = { | ||
| 2 | [0] = { | ||
| 3 | [2] = { | ||
| 4 | [0] = 5473562, | ||
| 5 | [1] = 34776317, | ||
| 6 | [2] = 68566704, | ||
| 7 | [3] = 8750867, | ||
| 8 | }, | ||
| 9 | [4] = { | ||
| 10 | [0] = 1, | ||
| 11 | [1] = 1, | ||
| 12 | [2] = 4, | ||
| 13 | [3] = 34, | ||
| 14 | [4] = 331, | ||
| 15 | [5] = 3612, | ||
| 16 | [6] = 41605, | ||
| 17 | [7] = 474128, | ||
| 18 | [8] = 4953846, | ||
| 19 | [9] = 34776317, | ||
| 20 | [10] = 68566704, | ||
| 21 | [11] = 8749194, | ||
| 22 | [12] = 1673, | ||
| 23 | }, | ||
| 24 | }, | ||
| 25 | }; | ||
