diff options
| author | enricotenuti <tenutz_27@outlook.it> | 2024-09-29 12:42:31 +0200 |
|---|---|---|
| committer | enricotenuti <tenutz_27@outlook.it> | 2024-09-29 12:42:31 +0200 |
| commit | 7a52b4cd50a40e4bce919b6bd51203d0e9867141 (patch) | |
| tree | 95ab133f9771c4791d5c784f1b3d4822b1dd7d3c /tools | |
| parent | 8fcfb3a33fe053ed2032d58ecc0b5d640c155931 (diff) | |
| parent | 774a824a6c80b5af495f4fb99d98758e3b9f6b81 (diff) | |
| download | nissy-core-7a52b4cd50a40e4bce919b6bd51203d0e9867141.tar.gz nissy-core-7a52b4cd50a40e4bce919b6bd51203d0e9867141.zip | |
Merge remote-tracking branch 'upstream/master'
Merge upstream
Diffstat (limited to 'tools')
22 files changed, 271 insertions, 287 deletions
diff --git a/tools/0002_gendata_h48h0k2/gendata_h48h0k2.c b/tools/0002_gendata_h48h0k2/gendata_h48h0k2.c deleted file mode 100644 index 14f99ee..0000000 --- a/tools/0002_gendata_h48h0k2/gendata_h48h0k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 5473562, | ||
| 6 | [1] = 34776317, | ||
| 7 | [2] = 68566704, | ||
| 8 | [3] = 8750867, | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "0;2;20", "tables/h48h0k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 0, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0004_gendata_h48h0k4/gendata_h48h0k4.c b/tools/0004_gendata_h48h0k4/gendata_h48h0k4.c deleted file mode 100644 index ff34bb9..0000000 --- a/tools/0004_gendata_h48h0k4/gendata_h48h0k4.c +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | [0] = 1, | ||
| 5 | [1] = 1, | ||
| 6 | [2] = 4, | ||
| 7 | [3] = 34, | ||
| 8 | [4] = 331, | ||
| 9 | [5] = 3612, | ||
| 10 | [6] = 41605, | ||
| 11 | [7] = 474128, | ||
| 12 | [8] = 4953846, | ||
| 13 | [9] = 34776317, | ||
| 14 | [10] = 68566704, | ||
| 15 | [11] = 8749194, | ||
| 16 | [12] = 1673, | ||
| 17 | }; | ||
| 18 | |||
| 19 | void run(void) { | ||
| 20 | gendata_run("h48", "0;4;20", "tables/h48h0k4", expected); | ||
| 21 | } | ||
| 22 | |||
| 23 | int main(void) { | ||
| 24 | nissy_setlogger(log_stderr); | ||
| 25 | |||
| 26 | timerun(run, "benchmark gendata_h48 h = 0, k = 4"); | ||
| 27 | |||
| 28 | return 0; | ||
| 29 | } | ||
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 | } | ||
diff --git a/tools/0012_gendata_h48h1k2/gendata_h48h1k2.c b/tools/0012_gendata_h48h1k2/gendata_h48h1k2.c deleted file mode 100644 index 0ebdcaa..0000000 --- a/tools/0012_gendata_h48h1k2/gendata_h48h1k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "1;2;20", "tables/h48h1k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 1, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/001_derive_h48/derive_h48.c b/tools/001_derive_h48/derive_h48.c new file mode 100644 index 0000000..3c7f8cc --- /dev/null +++ b/tools/001_derive_h48/derive_h48.c | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | char *opts_large, *opts_small, *filename_large, *filename_small; | ||
| 4 | |||
| 5 | void run(void) { | ||
| 6 | derivedata_run(opts_large, opts_small, filename_large, filename_small); | ||
| 7 | } | ||
| 8 | |||
| 9 | int main(int argc, char **argv) { | ||
| 10 | char description[256]; | ||
| 11 | |||
| 12 | if (argc < 5) { | ||
| 13 | fprintf(stderr, | ||
| 14 | "Error: not enough arguments. Required:\n" | ||
| 15 | "1. Options for large table\n" | ||
| 16 | "2. Options for derived table\n" | ||
| 17 | "3. Filename containing large table\n" | ||
| 18 | "4. Filename for saving derived table\n"); | ||
| 19 | return 1; | ||
| 20 | } | ||
| 21 | |||
| 22 | opts_large = argv[1]; | ||
| 23 | opts_small = argv[2]; | ||
| 24 | filename_large = argv[3]; | ||
| 25 | filename_small = argv[4]; | ||
| 26 | sprintf(description, "deriving %s from %s\n", opts_small, opts_large); | ||
| 27 | |||
| 28 | nissy_setlogger(log_stderr); | ||
| 29 | |||
| 30 | timerun(run, description); | ||
| 31 | |||
| 32 | return 0; | ||
| 33 | } | ||
diff --git a/tools/0022_gendata_h48h2k2/gendata_h48h2k2.c b/tools/0022_gendata_h48h2k2/gendata_h48h2k2.c deleted file mode 100644 index f437e98..0000000 --- a/tools/0022_gendata_h48h2k2/gendata_h48h2k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "2;2;20", "tables/h48h2k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 2, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0032_gendata_h48h3k2/gendata_h48h3k2.c b/tools/0032_gendata_h48h3k2/gendata_h48h3k2.c deleted file mode 100644 index 2e0eab5..0000000 --- a/tools/0032_gendata_h48h3k2/gendata_h48h3k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "3;2;20", "tables/h48h3k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 3, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0042_gendata_h48h4k2/gendata_h48h4k2.c b/tools/0042_gendata_h48h4k2/gendata_h48h4k2.c deleted file mode 100644 index 868c360..0000000 --- a/tools/0042_gendata_h48h4k2/gendata_h48h4k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "4;2;20", "tables/h48h4k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 4, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0052_gendata_h48h5k2/gendata_h48h5k2.c b/tools/0052_gendata_h48h5k2/gendata_h48h5k2.c deleted file mode 100644 index d292d49..0000000 --- a/tools/0052_gendata_h48h5k2/gendata_h48h5k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "5;2;20", "tables/h48h5k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 5, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0062_gendata_h48h6k2/gendata_h48h6k2.c b/tools/0062_gendata_h48h6k2/gendata_h48h6k2.c deleted file mode 100644 index 910d514..0000000 --- a/tools/0062_gendata_h48h6k2/gendata_h48h6k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "6;2;20", "tables/h48h6k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 6, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0072_gendata_h48h7k2/gendata_h48h7k2.c b/tools/0072_gendata_h48h7k2/gendata_h48h7k2.c deleted file mode 100644 index b803328..0000000 --- a/tools/0072_gendata_h48h7k2/gendata_h48h7k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "7;2;20", "tables/h48h7k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 7, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0082_gendata_h48h8k2/gendata_h48h8k2.c b/tools/0082_gendata_h48h8k2/gendata_h48h8k2.c deleted file mode 100644 index 52c377a..0000000 --- a/tools/0082_gendata_h48h8k2/gendata_h48h8k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "8;2;20", "tables/h48h8k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 8, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0092_gendata_h48h9k2/gendata_h48h9k2.c b/tools/0092_gendata_h48h9k2/gendata_h48h9k2.c deleted file mode 100644 index 5d3e34a..0000000 --- a/tools/0092_gendata_h48h9k2/gendata_h48h9k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "9;2;20", "tables/h48h9k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 9, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0102_gendata_h48h10k2/gendata_h48h10k2.c b/tools/0102_gendata_h48h10k2/gendata_h48h10k2.c deleted file mode 100644 index 5e8fbb0..0000000 --- a/tools/0102_gendata_h48h10k2/gendata_h48h10k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "10;2;20", "tables/h48h10k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 10, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
diff --git a/tools/0112_gendata_h48h11k2/gendata_h48h11k2.c b/tools/0112_gendata_h48h11k2/gendata_h48h11k2.c deleted file mode 100644 index 00c0747..0000000 --- a/tools/0112_gendata_h48h11k2/gendata_h48h11k2.c +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | |||
| 3 | uint64_t expected[21] = { | ||
| 4 | /* Base value is 8 */ | ||
| 5 | [0] = 0, /* Unknown */ | ||
| 6 | [1] = 0, /* Unknown */ | ||
| 7 | [2] = 0, /* Unknown */ | ||
| 8 | [3] = 0, /* Unknown */ | ||
| 9 | }; | ||
| 10 | |||
| 11 | void run(void) { | ||
| 12 | gendata_run("h48", "11;2;20", "tables/h48h11k2", expected); | ||
| 13 | } | ||
| 14 | |||
| 15 | int main(void) { | ||
| 16 | nissy_setlogger(log_stderr); | ||
| 17 | |||
| 18 | timerun(run, "benchmark gendata_h48 h = 11, k = 2"); | ||
| 19 | |||
| 20 | return 0; | ||
| 21 | } | ||
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/100_stats_tables_h48/stats_tables_h48.c b/tools/200_stats_tables_h48/stats_tables_h48.c index adac8fa..adac8fa 100644 --- a/tools/100_stats_tables_h48/stats_tables_h48.c +++ b/tools/200_stats_tables_h48/stats_tables_h48.c | |||
diff --git a/tools/200_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c index d476bce..d476bce 100644 --- a/tools/200_solve_small/solve_small.c +++ b/tools/300_solve_small/solve_small.c | |||
diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h new file mode 100644 index 0000000..535cab2 --- /dev/null +++ b/tools/expected_distributions.h | |||
| @@ -0,0 +1,33 @@ | |||
| 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 | [1] = { | ||
| 26 | [2] = { | ||
| 27 | [0] = 6012079, | ||
| 28 | [1] = 45822302, | ||
| 29 | [2] = 142018732, | ||
| 30 | [3] = 41281787, | ||
| 31 | }, | ||
| 32 | }, | ||
| 33 | }; | ||
diff --git a/tools/nissy_extra.h b/tools/nissy_extra.h new file mode 100644 index 0000000..1e714a7 --- /dev/null +++ b/tools/nissy_extra.h | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | /* | ||
| 2 | This header file exposes certain functions that are meant to be used | ||
| 3 | for testing purposes only. | ||
| 4 | */ | ||
| 5 | |||
| 6 | size_t gendata_h48_derive(uint8_t, const void *, void *); | ||
| 7 | int parse_h48_options(const char *, uint8_t *, uint8_t *, uint8_t *); | ||
diff --git a/tools/run_tool.sh b/tools/run_tool.sh index 7e09684..2216a66 100755 --- a/tools/run_tool.sh +++ b/tools/run_tool.sh | |||
| @@ -5,7 +5,7 @@ if [ -z "$TOOL" ]; then | |||
| 5 | exit 1 | 5 | exit 1 |
| 6 | fi | 6 | fi |
| 7 | 7 | ||
| 8 | CC="$CC -D_POSIX_C_SOURCE=199309L" | 8 | CC="$CC -D_POSIX_C_SOURCE=199309L" # For timer |
| 9 | 9 | ||
| 10 | BIN="tools/run" | 10 | BIN="tools/run" |
| 11 | d="$(date +'%Y-%m-%d-%H-%M-%S')" | 11 | d="$(date +'%Y-%m-%d-%H-%M-%S')" |
| @@ -16,7 +16,8 @@ for t in tools/*; do | |||
| 16 | fi | 16 | fi |
| 17 | toolname="$(basename "$t" .c)" | 17 | toolname="$(basename "$t" .c)" |
| 18 | $CC -o $BIN "$t"/*.c "$CUBEOBJ" || exit 1; | 18 | $CC -o $BIN "$t"/*.c "$CUBEOBJ" || exit 1; |
| 19 | $BIN | tee "tools/results/$toolname-$d.txt" "tools/results/last.out" | 19 | $BIN $TOOLARGS \ |
| 20 | | tee "tools/results/$toolname-$d.txt" "tools/results/last.out" | ||
| 20 | break | 21 | break |
| 21 | done | 22 | done |
| 22 | 23 | ||
diff --git a/tools/tool.h b/tools/tool.h index 757657b..c44828d 100644 --- a/tools/tool.h +++ b/tools/tool.h | |||
| @@ -6,14 +6,19 @@ | |||
| 6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| 7 | 7 | ||
| 8 | #include "../src/nissy.h" | 8 | #include "../src/nissy.h" |
| 9 | #include "nissy_extra.h" | ||
| 9 | 10 | ||
| 10 | static void log_stderr(const char *, ...); | 11 | static void log_stderr(const char *, ...); |
| 11 | static void log_stdout(const char *, ...); | 12 | static void log_stdout(const char *, ...); |
| 12 | static double timerun(void (*)(void), const char *); | 13 | static double timerun(void (*)(void), const char *); |
| 14 | static void getfilename(const char *, const char *, char *); | ||
| 13 | static void writetable(const char *, int64_t, const char *); | 15 | static void writetable(const char *, int64_t, const char *); |
| 14 | static int64_t generatetable(const char *, const char *, char **); | 16 | static int64_t generatetable(const char *, const char *, char **); |
| 17 | static int64_t derivetable(const char *, const char *, const char *, char **); | ||
| 15 | static int getdata(const char *, const char *, char **, const char *); | 18 | static int getdata(const char *, const char *, char **, const char *); |
| 16 | static void gendata_run(const char *, const char *, const char *, uint64_t[static 21]); | 19 | static void gendata_run(const char *, const char *, uint64_t[static 21]); |
| 20 | static void derivedata_run( | ||
| 21 | const char *, const char *, const char *, const char *); | ||
| 17 | 22 | ||
| 18 | static void | 23 | static void |
| 19 | log_stderr(const char *str, ...) | 24 | log_stderr(const char *str, ...) |
| @@ -70,6 +75,17 @@ timerun(void (*run)(void), const char *name) | |||
| 70 | } | 75 | } |
| 71 | 76 | ||
| 72 | static void | 77 | static void |
| 78 | getfilename(const char *solver, const char *options, char *filename) | ||
| 79 | { | ||
| 80 | uint8_t h, k; | ||
| 81 | |||
| 82 | /* Only h48 supported for now */ | ||
| 83 | parse_h48_options(options, &h, &k, NULL); | ||
| 84 | |||
| 85 | sprintf(filename, "tables/%sh%dk%d", solver, h, k); | ||
| 86 | } | ||
| 87 | |||
| 88 | static void | ||
| 73 | writetable(const char *buf, int64_t size, const char *filename) | 89 | writetable(const char *buf, int64_t size, const char *filename) |
| 74 | { | 90 | { |
| 75 | FILE *f; | 91 | FILE *f; |
| @@ -109,6 +125,44 @@ generatetable(const char *solver, const char *options, char **buf) | |||
| 109 | return gensize; | 125 | return gensize; |
| 110 | } | 126 | } |
| 111 | 127 | ||
| 128 | static int64_t | ||
| 129 | derivetable( | ||
| 130 | const char *opts_large, | ||
| 131 | const char *opts_small, | ||
| 132 | const char *filename_large, | ||
| 133 | char **buf | ||
| 134 | ) | ||
| 135 | { | ||
| 136 | uint8_t h; | ||
| 137 | int64_t size, gensize; | ||
| 138 | char *fulltable; | ||
| 139 | |||
| 140 | if (getdata("h48", opts_large, &fulltable, filename_large) != 0) { | ||
| 141 | printf("Error reading full table.\n"); | ||
| 142 | return -1; | ||
| 143 | } | ||
| 144 | |||
| 145 | size = nissy_datasize("h48", opts_small); | ||
| 146 | if (size == -1) { | ||
| 147 | printf("Error getting table size.\n"); | ||
| 148 | free(fulltable); | ||
| 149 | return -1; | ||
| 150 | } | ||
| 151 | |||
| 152 | h = atoi(opts_small); /* TODO: use option parser */ | ||
| 153 | *buf = malloc(size); | ||
| 154 | gensize = gendata_h48_derive(h, fulltable, *buf); | ||
| 155 | |||
| 156 | if (gensize != size) { | ||
| 157 | fprintf(stderr, "Error deriving table\n"); | ||
| 158 | free(fulltable); | ||
| 159 | return -2; | ||
| 160 | } | ||
| 161 | |||
| 162 | free(fulltable); | ||
| 163 | return gensize; | ||
| 164 | } | ||
| 165 | |||
| 112 | static int | 166 | static int |
| 113 | getdata( | 167 | getdata( |
| 114 | const char *solver, | 168 | const char *solver, |
| @@ -155,13 +209,12 @@ static void | |||
| 155 | gendata_run( | 209 | gendata_run( |
| 156 | const char *solver, | 210 | const char *solver, |
| 157 | const char *options, | 211 | const char *options, |
| 158 | const char *filename, /* TODO: remove filename, use solver name */ | ||
| 159 | uint64_t expected[static 21] | 212 | uint64_t expected[static 21] |
| 160 | ) { | 213 | ) { |
| 161 | int64_t size; | 214 | int64_t size; |
| 162 | char *buf; | 215 | char *buf, filename[1024]; |
| 163 | 216 | ||
| 164 | 217 | getfilename(solver, options, filename); | |
| 165 | size = generatetable(solver, options, &buf); | 218 | size = generatetable(solver, options, &buf); |
| 166 | switch (size) { | 219 | switch (size) { |
| 167 | case -1: | 220 | case -1: |
| @@ -182,3 +235,34 @@ gendata_run( | |||
| 182 | gendata_run_finish: | 235 | gendata_run_finish: |
| 183 | free(buf); | 236 | free(buf); |
| 184 | } | 237 | } |
| 238 | |||
| 239 | static void | ||
| 240 | derivedata_run( | ||
| 241 | const char *opts_large, | ||
| 242 | const char *opts_small, | ||
| 243 | const char *filename_large, | ||
| 244 | const char *filename_small | ||
| 245 | ) | ||
| 246 | { | ||
| 247 | int64_t size; | ||
| 248 | char *buf; | ||
| 249 | |||
| 250 | size = derivetable(opts_large, opts_small, filename_large, &buf); | ||
| 251 | switch (size) { | ||
| 252 | case -1: | ||
| 253 | return; | ||
| 254 | case -2: | ||
| 255 | goto derivedata_run_finish; | ||
| 256 | default: | ||
| 257 | nissy_datainfo(buf, write_stdout); | ||
| 258 | printf("\n"); | ||
| 259 | printf("Succesfully generated %" PRId64 " bytes. " | ||
| 260 | "See above for details on the tables.\n", size); | ||
| 261 | |||
| 262 | writetable(buf, size, filename_small); | ||
| 263 | break; | ||
| 264 | } | ||
| 265 | |||
| 266 | derivedata_run_finish: | ||
| 267 | free(buf); | ||
| 268 | } | ||
