aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.gitignore5
-rw-r--r--Makefile8
-rw-r--r--src/cube.h2
-rw-r--r--src/solve_generic.h26
-rw-r--r--tables/tables.c34
5 files changed, 65 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 0191ea5..c676583 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,11 @@ config.mk
3benchmark/results 3benchmark/results
4old/benchmark/results 4old/benchmark/results
5benchmark/run 5benchmark/run
6gen
7debuggen
8perf.data
9perf.data.old
10tables/data/*
6test/*/runtest 11test/*/runtest
7test/run 12test/run
8test/last.* 13test/last.*
diff --git a/Makefile b/Makefile
index a315476..f117b52 100644
--- a/Makefile
+++ b/Makefile
@@ -20,4 +20,10 @@ test: debugcube.o
20benchmark: cube.o 20benchmark: cube.o
21 CUBETYPE=${CUBETYPE} ./benchmark/bench.sh 21 CUBETYPE=${CUBETYPE} ./benchmark/bench.sh
22 22
23.PHONY: all clean test benchmark 23gen: cube.o
24 ${CC} ${CFLAGS} -o gen cube.o tables/tables.c
25
26debuggen: debugcube.o
27 ${CC} ${DBGFLAGS} -o debuggen debugcube.o tables/tables.c
28
29.PHONY: all clean test benchmark gen debuggen
diff --git a/src/cube.h b/src/cube.h
index 32547cf..694560a 100644
--- a/src/cube.h
+++ b/src/cube.h
@@ -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. */
164int64_t gendata(const char *solver, void *data); 164int64_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
79int64_t
80gendata(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
88solve_generic_appendsolution(dfsarg_generic_t *arg) 80solve_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
253int64_t
254gendata(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
13char buf[SIZE_H1];
14
15int 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}

Generated with cgit - Back to sebastiano.tronto.net