diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-05-24 22:20:00 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-05-24 22:20:00 +0200 |
| commit | 8954b4b7eaafa8e306f2aa6cbb7e32334107e6e1 (patch) | |
| tree | 6fc56f9ba2588d7c3c2d5f6d99b3343e1aaf8a34 | |
| parent | 8145e034184ed5807c00f05b90101090c6513a29 (diff) | |
| download | nissy-core-8954b4b7eaafa8e306f2aa6cbb7e32334107e6e1.tar.gz nissy-core-8954b4b7eaafa8e306f2aa6cbb7e32334107e6e1.zip | |
Added table generation utility
| -rw-r--r-- | .gitignore | 5 | ||||
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | src/cube.h | 2 | ||||
| -rw-r--r-- | src/solve_generic.h | 26 | ||||
| -rw-r--r-- | tables/tables.c | 34 |
5 files changed, 65 insertions, 10 deletions
| @@ -3,6 +3,11 @@ config.mk | |||
| 3 | benchmark/results | 3 | benchmark/results |
| 4 | old/benchmark/results | 4 | old/benchmark/results |
| 5 | benchmark/run | 5 | benchmark/run |
| 6 | gen | ||
| 7 | debuggen | ||
| 8 | perf.data | ||
| 9 | perf.data.old | ||
| 10 | tables/data/* | ||
| 6 | test/*/runtest | 11 | test/*/runtest |
| 7 | test/run | 12 | test/run |
| 8 | test/last.* | 13 | test/last.* |
| @@ -20,4 +20,10 @@ test: debugcube.o | |||
| 20 | benchmark: cube.o | 20 | benchmark: cube.o |
| 21 | CUBETYPE=${CUBETYPE} ./benchmark/bench.sh | 21 | CUBETYPE=${CUBETYPE} ./benchmark/bench.sh |
| 22 | 22 | ||
| 23 | .PHONY: all clean test benchmark | 23 | gen: cube.o |
| 24 | ${CC} ${CFLAGS} -o gen cube.o tables/tables.c | ||
| 25 | |||
| 26 | debuggen: debugcube.o | ||
| 27 | ${CC} ${DBGFLAGS} -o debuggen debugcube.o tables/tables.c | ||
| 28 | |||
| 29 | .PHONY: all clean test benchmark gen debuggen | ||
| @@ -161,4 +161,4 @@ void multisolve( | |||
| 161 | 161 | ||
| 162 | /* Returns the number of bytes written to data, -1 in case of error. | 162 | /* Returns the number of bytes written to data, -1 in case of error. |
| 163 | * TODO: write down how much memory every solver requires. */ | 163 | * TODO: write down how much memory every solver requires. */ |
| 164 | int64_t gendata(const char *solver, void *data); | 164 | int64_t gendata(const char *solver, const char *options, void *data); |
diff --git a/src/solve_generic.h b/src/solve_generic.h index 925aa33..6cdcc33 100644 --- a/src/solve_generic.h +++ b/src/solve_generic.h | |||
| @@ -76,14 +76,6 @@ multisolve( | |||
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | int64_t | ||
| 80 | gendata(const char *solver, void *data) | ||
| 81 | { | ||
| 82 | DBG_LOG("gendata: not implemented yet\n"); | ||
| 83 | |||
| 84 | return -1; | ||
| 85 | } | ||
| 86 | |||
| 87 | _static void | 79 | _static void |
| 88 | solve_generic_appendsolution(dfsarg_generic_t *arg) | 80 | solve_generic_appendsolution(dfsarg_generic_t *arg) |
| 89 | { | 81 | { |
| @@ -257,3 +249,21 @@ solve_simple( | |||
| 257 | &estimate_simple | 249 | &estimate_simple |
| 258 | ); | 250 | ); |
| 259 | } | 251 | } |
| 252 | |||
| 253 | int64_t | ||
| 254 | gendata(const char *solver, const char *options, void *data) | ||
| 255 | { | ||
| 256 | int64_t ret; | ||
| 257 | uint8_t maxdepth; | ||
| 258 | |||
| 259 | if (!strcmp(solver, "H48")) { | ||
| 260 | /* TODO: write a generic parser for options */ | ||
| 261 | maxdepth = atoi(options); | ||
| 262 | ret = gendata_h48(data, 0, maxdepth); | ||
| 263 | } else { | ||
| 264 | DBG_LOG("gendata: implemented only for H48 solver\n"); | ||
| 265 | ret = -1; | ||
| 266 | } | ||
| 267 | |||
| 268 | return ret; | ||
| 269 | } | ||
diff --git a/tables/tables.c b/tables/tables.c new file mode 100644 index 0000000..bd37831 --- /dev/null +++ b/tables/tables.c | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #define _POSIX_C_SOURCE 200809L /* Required to use clock_gettime */ | ||
| 2 | |||
| 3 | #include <inttypes.h> | ||
| 4 | #include <stdbool.h> | ||
| 5 | #include <stdio.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include <time.h> | ||
| 8 | |||
| 9 | #include "../src/cube.h" | ||
| 10 | |||
| 11 | #define SIZE_H1 118687270 | ||
| 12 | |||
| 13 | char buf[SIZE_H1]; | ||
| 14 | |||
| 15 | int main(int argc, char *argv[]) { | ||
| 16 | FILE *f; | ||
| 17 | struct timespec t0, t1; | ||
| 18 | double s; | ||
| 19 | |||
| 20 | clock_gettime(CLOCK_MONOTONIC, &t0); | ||
| 21 | gendata("H48", argc > 1 ? argv[1] : "4", buf); | ||
| 22 | clock_gettime(CLOCK_MONOTONIC, &t1); | ||
| 23 | |||
| 24 | if ((f = fopen("tables/data/h48_test", "wb")) == NULL) { | ||
| 25 | printf("Could not open file!\n"); | ||
| 26 | return 1; | ||
| 27 | } | ||
| 28 | fwrite(buf, SIZE_H1, 1, f); | ||
| 29 | |||
| 30 | s = t1.tv_sec - t0.tv_sec + (t1.tv_nsec - t0.tv_nsec) / 1000000000.0; | ||
| 31 | printf("Data generated in %lfs\n", s); | ||
| 32 | |||
| 33 | return 0; | ||
| 34 | } | ||
