diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/000_gendata/gendata.c | 6 | ||||
| -rw-r--r-- | tools/100_checkdata/checkdata.c | 6 | ||||
| -rw-r--r-- | tools/300_solve_small/solve_small.c | 4 | ||||
| -rw-r--r-- | tools/301_solve_file/solve_file.c | 4 | ||||
| -rw-r--r-- | tools/302_solve_multisol/solve_multisol.c | 4 | ||||
| -rw-r--r-- | tools/400_solvetest/solve_test.c | 4 | ||||
| -rw-r--r-- | tools/tool.h | 26 |
7 files changed, 30 insertions, 24 deletions
diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c index 213852f..51c2f47 100644 --- a/tools/000_gendata/gendata.c +++ b/tools/000_gendata/gendata.c | |||
| @@ -8,9 +8,9 @@ static void | |||
| 8 | run(void) { | 8 | run(void) { |
| 9 | int64_t size; | 9 | int64_t size; |
| 10 | bool consistent, expected; | 10 | bool consistent, expected; |
| 11 | char *buf, filename[1024]; | 11 | char *buf, filename[1024], dataid[NISSY_DATAID_SIZE]; |
| 12 | 12 | ||
| 13 | size = generatetable(solver, &buf); | 13 | size = generatetable(solver, &buf, dataid); |
| 14 | switch (size) { | 14 | switch (size) { |
| 15 | case -1: | 15 | case -1: |
| 16 | return; | 16 | return; |
| @@ -23,7 +23,7 @@ run(void) { | |||
| 23 | if (consistent && expected) { | 23 | if (consistent && expected) { |
| 24 | printf("\n"); | 24 | printf("\n"); |
| 25 | printf("Generated %" PRId64 " bytes.\n", size); | 25 | printf("Generated %" PRId64 " bytes.\n", size); |
| 26 | sprintf(filename, "tables/%s", solver); | 26 | sprintf(filename, "tables/%s", dataid); |
| 27 | writetable(buf, size, filename); | 27 | writetable(buf, size, filename); |
| 28 | } | 28 | } |
| 29 | if (!consistent) | 29 | if (!consistent) |
diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c index fe94427..8bc308c 100644 --- a/tools/100_checkdata/checkdata.c +++ b/tools/100_checkdata/checkdata.c | |||
| @@ -6,13 +6,13 @@ char *solver, *filename; | |||
| 6 | static void | 6 | static void |
| 7 | run(void) { | 7 | run(void) { |
| 8 | long long int size, result; | 8 | long long int size, result; |
| 9 | char *buf; | 9 | char *buf, dataid[NISSY_DATAID_SIZE]; |
| 10 | FILE *f; | 10 | FILE *f; |
| 11 | 11 | ||
| 12 | size = nissy_datasize(solver); | 12 | size = nissy_solverinfo(solver, dataid); |
| 13 | 13 | ||
| 14 | if (size <= 0) { | 14 | if (size <= 0) { |
| 15 | printf("Error in datasize\n"); | 15 | printf("Error in solverinfo\n"); |
| 16 | return; | 16 | return; |
| 17 | } | 17 | } |
| 18 | 18 | ||
diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c index 073de89..6a1f7b5 100644 --- a/tools/300_solve_small/solve_small.c +++ b/tools/300_solve_small/solve_small.c | |||
| @@ -46,7 +46,7 @@ void run(void) { | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | int main(int argc, char **argv) { | 48 | int main(int argc, char **argv) { |
| 49 | char filename[255]; | 49 | char filename[255], dataid[NISSY_DATAID_SIZE]; |
| 50 | 50 | ||
| 51 | if (argc < 2) { | 51 | if (argc < 2) { |
| 52 | printf("Error: not enough arguments. " | 52 | printf("Error: not enough arguments. " |
| @@ -63,7 +63,7 @@ int main(int argc, char **argv) { | |||
| 63 | if (getdata(solver, &buf, filename) != 0) | 63 | if (getdata(solver, &buf, filename) != 0) |
| 64 | return 1; | 64 | return 1; |
| 65 | 65 | ||
| 66 | size = nissy_datasize(solver); | 66 | size = nissy_solverinfo(solver, dataid); |
| 67 | 67 | ||
| 68 | timerun(run); | 68 | timerun(run); |
| 69 | 69 | ||
diff --git a/tools/301_solve_file/solve_file.c b/tools/301_solve_file/solve_file.c index fe41bb7..cefc608 100644 --- a/tools/301_solve_file/solve_file.c +++ b/tools/301_solve_file/solve_file.c | |||
| @@ -33,7 +33,7 @@ void run(void) { | |||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | int main(int argc, char **argv) { | 35 | int main(int argc, char **argv) { |
| 36 | char filename[255], *scrfilename; | 36 | char filename[255], dataid[NISSY_DATAID_SIZE], *scrfilename; |
| 37 | FILE *scrfile; | 37 | FILE *scrfile; |
| 38 | 38 | ||
| 39 | if (argc < 3) { | 39 | if (argc < 3) { |
| @@ -52,7 +52,7 @@ int main(int argc, char **argv) { | |||
| 52 | if (getdata(solver, &buf, filename) != 0) | 52 | if (getdata(solver, &buf, filename) != 0) |
| 53 | return 1; | 53 | return 1; |
| 54 | 54 | ||
| 55 | size = nissy_datasize(solver); | 55 | size = nissy_solverinfo(solver, dataid); |
| 56 | 56 | ||
| 57 | if ((scrfile = fopen(scrfilename, "r")) == NULL) { | 57 | if ((scrfile = fopen(scrfilename, "r")) == NULL) { |
| 58 | printf("Error: could not read given file '%s'.\n", | 58 | printf("Error: could not read given file '%s'.\n", |
diff --git a/tools/302_solve_multisol/solve_multisol.c b/tools/302_solve_multisol/solve_multisol.c index a03c2a0..c6ab685 100644 --- a/tools/302_solve_multisol/solve_multisol.c +++ b/tools/302_solve_multisol/solve_multisol.c | |||
| @@ -39,7 +39,7 @@ void run(void) { | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | int main(int argc, char **argv) { | 41 | int main(int argc, char **argv) { |
| 42 | char filename[255]; | 42 | char filename[255], dataid[NISSY_DATAID_SIZE]; |
| 43 | 43 | ||
| 44 | if (argc < 3) { | 44 | if (argc < 3) { |
| 45 | printf("Error: not enough arguments. " | 45 | printf("Error: not enough arguments. " |
| @@ -57,7 +57,7 @@ int main(int argc, char **argv) { | |||
| 57 | if (getdata(solver, &buf, filename) != 0) | 57 | if (getdata(solver, &buf, filename) != 0) |
| 58 | return 1; | 58 | return 1; |
| 59 | 59 | ||
| 60 | size = nissy_datasize(solver); | 60 | size = nissy_solverinfo(solver, dataid); |
| 61 | 61 | ||
| 62 | timerun(run); | 62 | timerun(run); |
| 63 | 63 | ||
diff --git a/tools/400_solvetest/solve_test.c b/tools/400_solvetest/solve_test.c index 9b6c094..a98be26 100644 --- a/tools/400_solvetest/solve_test.c +++ b/tools/400_solvetest/solve_test.c | |||
| @@ -94,7 +94,7 @@ void run(void) { | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | int main(int argc, char **argv) { | 96 | int main(int argc, char **argv) { |
| 97 | char filename[255]; | 97 | char filename[255], dataid[NISSY_DATAID_SIZE]; |
| 98 | 98 | ||
| 99 | if (argc < 2) { | 99 | if (argc < 2) { |
| 100 | printf("Error: not enough arguments. " | 100 | printf("Error: not enough arguments. " |
| @@ -110,7 +110,7 @@ int main(int argc, char **argv) { | |||
| 110 | if (getdata(solver, &buf, filename) != 0) | 110 | if (getdata(solver, &buf, filename) != 0) |
| 111 | return 1; | 111 | return 1; |
| 112 | 112 | ||
| 113 | size = nissy_datasize(solver); | 113 | size = nissy_solverinfo(solver, dataid); |
| 114 | 114 | ||
| 115 | timerun(run); | 115 | timerun(run); |
| 116 | 116 | ||
diff --git a/tools/tool.h b/tools/tool.h index 3488f34..b65f33a 100644 --- a/tools/tool.h +++ b/tools/tool.h | |||
| @@ -13,7 +13,8 @@ static void log_stderr(const char *, ...); | |||
| 13 | static void log_stdout(const char *, ...); | 13 | static void log_stdout(const char *, ...); |
| 14 | static double timerun(void (*)(void)); | 14 | static double timerun(void (*)(void)); |
| 15 | static void writetable(const char *, int64_t, const char *); | 15 | static void writetable(const char *, int64_t, const char *); |
| 16 | static long long int generatetable(const char *, char **); | 16 | static long long int generatetable(const char *, char **, |
| 17 | char [static NISSY_DATAID_SIZE]); | ||
| 17 | static long long int derivetable( | 18 | static long long int derivetable( |
| 18 | const char *, const char *, const char *, char **); | 19 | const char *, const char *, const char *, char **); |
| 19 | static int getdata(const char *, char **, const char *); | 20 | static int getdata(const char *, char **, const char *); |
| @@ -86,11 +87,15 @@ writetable(const char *buf, int64_t size, const char *filename) | |||
| 86 | } | 87 | } |
| 87 | 88 | ||
| 88 | static long long int | 89 | static long long int |
| 89 | generatetable(const char *solver, char **buf) | 90 | generatetable( |
| 91 | const char *solver, | ||
| 92 | char **buf, | ||
| 93 | char dataid[static NISSY_DATAID_SIZE] | ||
| 94 | ) | ||
| 90 | { | 95 | { |
| 91 | long long int size, gensize; | 96 | long long int size, gensize; |
| 92 | 97 | ||
| 93 | size = nissy_datasize(solver); | 98 | size = nissy_solverinfo(solver, dataid); |
| 94 | if (size < 0) { | 99 | if (size < 0) { |
| 95 | printf("Error getting table size.\n"); | 100 | printf("Error getting table size.\n"); |
| 96 | return -1; | 101 | return -1; |
| @@ -120,7 +125,7 @@ derivetable( | |||
| 120 | { | 125 | { |
| 121 | uint8_t h, k; | 126 | uint8_t h, k; |
| 122 | long long int size, gensize; | 127 | long long int size, gensize; |
| 123 | char *fulltable; | 128 | char *fulltable, dataid[NISSY_DATAID_SIZE]; |
| 124 | 129 | ||
| 125 | if (getdata(solver_large, &fulltable, filename_large) != 0) { | 130 | if (getdata(solver_large, &fulltable, filename_large) != 0) { |
| 126 | printf("Error reading full table.\n"); | 131 | printf("Error reading full table.\n"); |
| @@ -128,7 +133,7 @@ derivetable( | |||
| 128 | goto derivetable_error_nofree; | 133 | goto derivetable_error_nofree; |
| 129 | } | 134 | } |
| 130 | 135 | ||
| 131 | size = nissy_datasize(solver_small); | 136 | size = nissy_solverinfo(solver_small, dataid); |
| 132 | if (size == -1) { | 137 | if (size == -1) { |
| 133 | printf("Error getting table size.\n"); | 138 | printf("Error getting table size.\n"); |
| 134 | gensize = -2; | 139 | gensize = -2; |
| @@ -164,10 +169,11 @@ getdata( | |||
| 164 | ) { | 169 | ) { |
| 165 | long long int size, sizeread; | 170 | long long int size, sizeread; |
| 166 | FILE *f; | 171 | FILE *f; |
| 172 | char dataid[NISSY_DATAID_SIZE]; | ||
| 167 | 173 | ||
| 168 | if ((f = fopen(filename, "rb")) == NULL) { | 174 | if ((f = fopen(filename, "rb")) == NULL) { |
| 169 | printf("Table file not found, generating it.\n"); | 175 | printf("Table file not found, generating it.\n"); |
| 170 | size = generatetable(solver, buf); | 176 | size = generatetable(solver, buf, dataid); |
| 171 | switch (size) { | 177 | switch (size) { |
| 172 | case -1: | 178 | case -1: |
| 173 | goto getdata_error_nofree; | 179 | goto getdata_error_nofree; |
| @@ -179,7 +185,7 @@ getdata( | |||
| 179 | } | 185 | } |
| 180 | } else { | 186 | } else { |
| 181 | printf("Reading tables from file %s\n", filename); | 187 | printf("Reading tables from file %s\n", filename); |
| 182 | size = nissy_datasize(solver); | 188 | size = nissy_solverinfo(solver, dataid); |
| 183 | *buf = malloc(size); | 189 | *buf = malloc(size); |
| 184 | sizeread = fread(*buf, size, 1, f); | 190 | sizeread = fread(*buf, size, 1, f); |
| 185 | fclose(f); | 191 | fclose(f); |
| @@ -203,10 +209,10 @@ gendata_run( | |||
| 203 | uint64_t expected[static 21] | 209 | uint64_t expected[static 21] |
| 204 | ) { | 210 | ) { |
| 205 | long long int size; | 211 | long long int size; |
| 206 | char *buf, filename[1024]; | 212 | char *buf, filename[1024], dataid[NISSY_DATAID_SIZE]; |
| 207 | 213 | ||
| 208 | sprintf(filename, "tables/%s", solver); | 214 | size = generatetable(solver, &buf, dataid); |
| 209 | size = generatetable(solver, &buf); | 215 | sprintf(filename, "tables/%s", dataid); |
| 210 | switch (size) { | 216 | switch (size) { |
| 211 | case -1: | 217 | case -1: |
| 212 | return; | 218 | return; |
