aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-06-13 21:08:38 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-06-13 21:08:38 +0200
commit7812684339d03f6993882358b0045c1bc2d5032c (patch)
tree41eb0137be98381bff21b161f406ea4eb7658e32
parentb4d33513bd44c82426ef9e3c6daf5b8046672514 (diff)
downloadnissy-core-7812684339d03f6993882358b0045c1bc2d5032c.tar.gz
nissy-core-7812684339d03f6993882358b0045c1bc2d5032c.zip
Added "dryrun" for gendata
-rw-r--r--TODO.txt1
-rw-r--r--src/cube.h12
-rw-r--r--src/cube_public.h12
-rw-r--r--src/solve_h48.h11
4 files changed, 33 insertions, 3 deletions
diff --git a/TODO.txt b/TODO.txt
index f0c81a6..614e8e5 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -3,7 +3,6 @@ Solver
3 3
4More utilities for tables (in cube.h) 4More utilities for tables (in cube.h)
5 - cleanup solve and gendata in cube.h and cube_public.h 5 - cleanup solve and gendata in cube.h and cube_public.h
6 - for tables, a "dryrun" function that only tells you the size needed
7 - check hash of generated data 6 - check hash of generated data
8 7
9Goal: find out which k value is best 8Goal: find out which k value is best
diff --git a/src/cube.h b/src/cube.h
index ab8e964..0eedfec 100644
--- a/src/cube.h
+++ b/src/cube.h
@@ -51,6 +51,16 @@ int nissy_convertcube(
51 char *result 51 char *result
52); 52);
53 53
54/*
55Returns the size of the data generated by nissy_gendata, when called with
56the same parameters, or -1 in case of error. The returned value can be
57slightly larger than the actual table size.
58*/
59int64_t nissy_datasize(
60 const char *solver,
61 const char *options
62);
63
54/* Returns the number of bytes written, or -1 in case of error */ 64/* Returns the number of bytes written, or -1 in case of error */
55int64_t nissy_gendata( 65int64_t nissy_gendata(
56 const char *solver, 66 const char *solver,
@@ -59,7 +69,7 @@ int64_t nissy_gendata(
59); 69);
60 70
61/* Returns the number of solutions found, or -1 in case of error */ 71/* Returns the number of solutions found, or -1 in case of error */
62int nissy_solve( 72int64_t nissy_solve(
63 const char cube[static 22], 73 const char cube[static 22],
64 const char *solver, 74 const char *solver,
65 const char *options, 75 const char *options,
diff --git a/src/cube_public.h b/src/cube_public.h
index 1b0cc14..01b6dac 100644
--- a/src/cube_public.h
+++ b/src/cube_public.h
@@ -1,3 +1,5 @@
1#include "cube.h"
2
1int write_result(cube_t, char [static 22]); 3int write_result(cube_t, char [static 22]);
2 4
3int 5int
@@ -127,6 +129,16 @@ nissy_writecube(
127} 129}
128 130
129int64_t 131int64_t
132nissy_datasize(
133 const char *solver,
134 const char *options
135)
136{
137 /* gendata() handles a NULL *data as a "dryrun" request */
138 return nissy_gendata(solver, options, NULL);
139}
140
141int64_t
130nissy_gendata( 142nissy_gendata(
131 const char *solver, 143 const char *solver,
132 const char *options, 144 const char *options,
diff --git a/src/solve_h48.h b/src/solve_h48.h
index 8691d49..8be67b6 100644
--- a/src/solve_h48.h
+++ b/src/solve_h48.h
@@ -129,6 +129,9 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep)
129 uint8_t i, j, visited[COCSEP_VISITEDSIZE]; 129 uint8_t i, j, visited[COCSEP_VISITEDSIZE];
130 dfsarg_cocsep_t arg; 130 dfsarg_cocsep_t arg;
131 131
132 if (buf == NULL)
133 goto gendata_cocsep_return_size;
134
132 buf32 = (uint32_t *)buf; 135 buf32 = (uint32_t *)buf;
133 info = buf32 + COCSEP_TABLESIZE; 136 info = buf32 + COCSEP_TABLESIZE;
134 memset(buf32, 0xFF, sizeof(uint32_t) * COCSEP_TABLESIZE); 137 memset(buf32, 0xFF, sizeof(uint32_t) * COCSEP_TABLESIZE);
@@ -165,6 +168,7 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep)
165 for (j = 0; j < 10; j++) 168 for (j = 0; j < 10; j++)
166 DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+2]); 169 DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+2]);
167 170
171gendata_cocsep_return_size:
168 return COCSEP_FULLSIZE; 172 return COCSEP_FULLSIZE;
169} 173}
170 174
@@ -234,8 +238,12 @@ gendata_h48(void *buf, uint8_t h, uint8_t maxdepth)
234 cube_t crep[COCSEP_CLASSES]; 238 cube_t crep[COCSEP_CLASSES];
235 size_t cocsepsize, infosize; 239 size_t cocsepsize, infosize;
236 240
237 esep_max = (int64_t)ESEP_MAX(h); 241 infosize = 4 * maxdepth;
238 cocsepsize = gendata_cocsep(buf, selfsim, crep); 242 cocsepsize = gendata_cocsep(buf, selfsim, crep);
243 if (buf == NULL)
244 goto gendata_h48_return_size;
245
246 esep_max = (int64_t)ESEP_MAX(h);
239 cocsepdata = (uint32_t *)buf; 247 cocsepdata = (uint32_t *)buf;
240 buf32 = cocsepdata + cocsepsize / 4; 248 buf32 = cocsepdata + cocsepsize / 4;
241 info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t)); 249 info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t));
@@ -272,6 +280,7 @@ gendata_h48(void *buf, uint8_t h, uint8_t maxdepth)
272 for (j = 0; j <= info[0]; j++) 280 for (j = 0; j <= info[0]; j++)
273 DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+1]); 281 DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+1]);
274 282
283gendata_h48_return_size:
275 return cocsepsize + ESEP_TABLESIZE(h, k) + infosize; 284 return cocsepsize + ESEP_TABLESIZE(h, k) + infosize;
276} 285}
277 286

Generated with cgit - Back to sebastiano.tronto.net