diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-26 14:59:11 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-26 15:00:16 +0200 |
| commit | 818186b480d7c05e0c58ff89da2180f5b2476434 (patch) | |
| tree | 0f6e4919d4001775a4820dffd29448dbd20c00db | |
| parent | bb09e52a7481718ae1fe324d16b99970450908f8 (diff) | |
| download | nissy-core-818186b480d7c05e0c58ff89da2180f5b2476434.tar.gz nissy-core-818186b480d7c05e0c58ff89da2180f5b2476434.zip | |
Added TOOLARGS and simplified gendata tool(s)
Diffstat (limited to '')
22 files changed, 122 insertions, 294 deletions
| @@ -10,6 +10,7 @@ test/*/runtest | |||
| 10 | test/run | 10 | test/run |
| 11 | test/run.DSYM | 11 | test/run.DSYM |
| 12 | run.DSYM | 12 | run.DSYM |
| 13 | run.core | ||
| 13 | test/last.* | 14 | test/last.* |
| 14 | tools/results | 15 | tools/results |
| 15 | .vscode | 16 | .vscode |
| @@ -61,7 +61,7 @@ The results of the last test case run is saved in test/last.out (standard | |||
| 61 | output, the results compared with the .out files) and test/last.err | 61 | output, the results compared with the .out files) and test/last.err |
| 62 | (standard error). | 62 | (standard error). |
| 63 | 63 | ||
| 64 | Tests are always run in "debug mode": this means that optimizations are | 64 | Tests are always run in debug mode: this means that optimizations are |
| 65 | disabled and some extra logging is enabled. | 65 | disabled and some extra logging is enabled. |
| 66 | 66 | ||
| 67 | See the test folder and test/test.sh for details. | 67 | See the test folder and test/test.sh for details. |
| @@ -70,7 +70,7 @@ See the test folder and test/test.sh for details. | |||
| 70 | 70 | ||
| 71 | In the tools folder there are some small programs that test various | 71 | In the tools folder there are some small programs that test various |
| 72 | functionality of the H48 library. They work similarly to test, but they | 72 | functionality of the H48 library. They work similarly to test, but they |
| 73 | are not run in debug mode. | 73 | are not run in debug mode by default. |
| 74 | 74 | ||
| 75 | To run a tool you must select it with the environment variable `TOOL`. | 75 | To run a tool you must select it with the environment variable `TOOL`. |
| 76 | For example the command: | 76 | For example the command: |
| @@ -79,14 +79,26 @@ For example the command: | |||
| 79 | TOOL=stats make tool | 79 | TOOL=stats make tool |
| 80 | ``` | 80 | ``` |
| 81 | 81 | ||
| 82 | Will run the stats_tables_h48 tool. Like for tests, the value of the | 82 | Will run the stats_tables_h48 tool. |
| 83 | `TOOL` variable can be any regular expression matching the name of the | 83 | |
| 84 | tool. Unlike tests, one and only one tool will be selected for each run. | 84 | To pass some arguments to a tool, use the `TOOLARGS` variable: |
| 85 | |||
| 86 | ``` | ||
| 87 | TOOL=gendata TOOLARGS="h48 0;2;20" make tool | ||
| 88 | ``` | ||
| 89 | |||
| 90 | Like for tests, the value of the `TOOL` variable can be any regular | ||
| 91 | expression matching the name of the tool. Unlike tests, one and | ||
| 92 | only one tool will be selected for each run. The content of the | ||
| 93 | `TOOLARGS` variable is used directly as command line arguments for | ||
| 94 | the chosen tool. | ||
| 85 | 95 | ||
| 86 | Each tool run is automatically timed, so these tools can be used as | 96 | Each tool run is automatically timed, so these tools can be used as |
| 87 | benchmark. The output as well as the time of the run are saved to a | 97 | benchmark. The output as well as the time of the run are saved to a |
| 88 | file in the tools/results folder. | 98 | file in the tools/results folder. |
| 89 | 99 | ||
| 100 | To build and run a tool in debug mode, use `make debugtool`. | ||
| 101 | |||
| 90 | ## Running commands manually | 102 | ## Running commands manually |
| 91 | 103 | ||
| 92 | This project also includes a rudimentary shell that can be used to run | 104 | This project also includes a rudimentary shell that can be used to run |
diff --git a/src/nissy.c b/src/nissy.c index 6bc4aea..318cff1 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | #include "nissy.h" | 12 | #include "nissy.h" |
| 13 | 13 | ||
| 14 | STATIC int parse_h48_options(const char *, uint8_t *, uint8_t *, uint8_t *); | 14 | int parse_h48_options(const char *, uint8_t *, uint8_t *, uint8_t *); |
| 15 | STATIC int64_t write_result(cube_t, char [static 22]); | 15 | STATIC int64_t write_result(cube_t, char [static 22]); |
| 16 | 16 | ||
| 17 | /* TODO: add option to get DR, maybe C-only, E-only, eo... */ | 17 | /* TODO: add option to get DR, maybe C-only, E-only, eo... */ |
| @@ -24,7 +24,7 @@ struct { | |||
| 24 | GETCUBE_OPTIONS(NULL, NULL) | 24 | GETCUBE_OPTIONS(NULL, NULL) |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | STATIC int | 27 | int |
| 28 | parse_h48_options(const char *buf, uint8_t *h, uint8_t *k, uint8_t *maxdepth) | 28 | parse_h48_options(const char *buf, uint8_t *h, uint8_t *k, uint8_t *maxdepth) |
| 29 | { | 29 | { |
| 30 | bool h_valid, k_valid, maxdepth_valid; | 30 | bool h_valid, k_valid, maxdepth_valid; |
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/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/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_gendata/gendata.c b/tools/100_gendata/gendata.c new file mode 100644 index 0000000..78f81ab --- /dev/null +++ b/tools/100_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 | } | ||
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 4d07728..4d07728 100644 --- a/tools/200_solve_small/solve_small.c +++ b/tools/300_solve_small/solve_small.c | |||
diff --git a/tools/nissy_extra.h b/tools/nissy_extra.h new file mode 100644 index 0000000..17906d4 --- /dev/null +++ b/tools/nissy_extra.h | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | /* Intended only for tools */ | ||
| 2 | |||
| 3 | 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..1540f22 100644 --- a/tools/tool.h +++ b/tools/tool.h | |||
| @@ -6,14 +6,16 @@ | |||
| 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 **); |
| 15 | static int getdata(const char *, const char *, char **, const char *); | 17 | 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]); | 18 | static void gendata_run(const char *, const char *, uint64_t *); |
| 17 | 19 | ||
| 18 | static void | 20 | static void |
| 19 | log_stderr(const char *str, ...) | 21 | log_stderr(const char *str, ...) |
| @@ -70,6 +72,17 @@ timerun(void (*run)(void), const char *name) | |||
| 70 | } | 72 | } |
| 71 | 73 | ||
| 72 | static void | 74 | static void |
| 75 | getfilename(const char *solver, const char *options, char *filename) | ||
| 76 | { | ||
| 77 | uint8_t h, k; | ||
| 78 | |||
| 79 | /* Only h48 supported for now */ | ||
| 80 | parse_h48_options(options, &h, &k, NULL); | ||
| 81 | |||
| 82 | sprintf(filename, "tables/%sh%dk%d", solver, h, k); | ||
| 83 | } | ||
| 84 | |||
| 85 | static void | ||
| 73 | writetable(const char *buf, int64_t size, const char *filename) | 86 | writetable(const char *buf, int64_t size, const char *filename) |
| 74 | { | 87 | { |
| 75 | FILE *f; | 88 | FILE *f; |
| @@ -155,13 +168,12 @@ static void | |||
| 155 | gendata_run( | 168 | gendata_run( |
| 156 | const char *solver, | 169 | const char *solver, |
| 157 | const char *options, | 170 | const char *options, |
| 158 | const char *filename, /* TODO: remove filename, use solver name */ | ||
| 159 | uint64_t expected[static 21] | 171 | uint64_t expected[static 21] |
| 160 | ) { | 172 | ) { |
| 161 | int64_t size; | 173 | int64_t size; |
| 162 | char *buf; | 174 | char *buf, filename[1024]; |
| 163 | 175 | ||
| 164 | 176 | getfilename(solver, options, filename); | |
| 165 | size = generatetable(solver, options, &buf); | 177 | size = generatetable(solver, options, &buf); |
| 166 | switch (size) { | 178 | switch (size) { |
| 167 | case -1: | 179 | case -1: |
