aboutsummaryrefslogtreecommitdiff
path: root/src/solve_h48.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-05-20 17:39:07 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-05-20 17:39:07 +0200
commit8bacac732dcb2c0118e47e1bb81be855f4a0bf58 (patch)
tree503960622342592d141fa0a375dee9b9aa265fe7 /src/solve_h48.h
parent4dde2625a1bcb5381b50b22e7212070266cd224f (diff)
downloadnissy-core-8bacac732dcb2c0118e47e1bb81be855f4a0bf58.tar.gz
nissy-core-8bacac732dcb2c0118e47e1bb81be855f4a0bf58.zip
Tests for gendata h48
Diffstat (limited to 'src/solve_h48.h')
-rw-r--r--src/solve_h48.h43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/solve_h48.h b/src/solve_h48.h
index b95e6ce..be2c328 100644
--- a/src/solve_h48.h
+++ b/src/solve_h48.h
@@ -1,12 +1,10 @@
1#define COCSEP_CLASSES 3393U 1#define COCSEP_CLASSES 3393U
2#define COCSEP_TABLESIZE (_3p7 << 7U) 2#define COCSEP_TABLESIZE (_3p7 << 7U)
3#define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + 7U) / 8U) 3#define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + 7U) / 8U)
4#define COCSEP_INFOSIZE 12U 4#define COCSEP_FULLSIZE (4*(COCSEP_TABLESIZE + 12))
5#define COCSEP_FULLSIZE (4 * (COCSEP_TABLESIZE + COCSEP_INFOSIZE))
6 5
7#define ESEP_MAX(h) ((COCSEP_CLASSES * _12c4 * _8c4) << (h)) 6#define ESEP_MAX(h) ((COCSEP_CLASSES * _12c4 * _8c4) << (h))
8#define ESEP_TABLESIZE(h, k) (ESEP_MAX((h)) >> (k)) 7#define ESEP_TABLESIZE(h, k) (ESEP_MAX((h)) / (8U / (k)))
9#define ESEP_INFOSIZE 25 /* TODO unknown yet */
10 8
11#define H48_ESIZE(h) ((_12c4 * _8c4) << (h)) 9#define H48_ESIZE(h) ((_12c4 * _8c4) << (h))
12 10
@@ -41,7 +39,7 @@ _static_inline cube_fast_t invcoord_h48(int64_t, const cube_fast_t *, uint8_t);
41 39
42_static size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); 40_static size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *);
43_static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); 41_static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *);
44_static size_t gendata_h48(void *, uint8_t); 42_static size_t gendata_h48(void *, uint8_t, uint8_t);
45_static uint64_t gendata_esep_bfs(bfsarg_esep_t *); 43_static uint64_t gendata_esep_bfs(bfsarg_esep_t *);
46 44
47_static_inline bool get_visited(const uint8_t *, int64_t); 45_static_inline bool get_visited(const uint8_t *, int64_t);
@@ -120,7 +118,6 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_fast_t *rep)
120 buf32 = (uint32_t *)buf; 118 buf32 = (uint32_t *)buf;
121 info = buf32 + COCSEP_TABLESIZE; 119 info = buf32 + COCSEP_TABLESIZE;
122 memset(buf32, 0xFFU, sizeof(uint32_t) * COCSEP_TABLESIZE); 120 memset(buf32, 0xFFU, sizeof(uint32_t) * COCSEP_TABLESIZE);
123 memset(info, 0, sizeof(uint32_t) * COCSEP_INFOSIZE);
124 memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES); 121 memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES);
125 122
126 arg = (dfsarg_cocsep_t) { 123 arg = (dfsarg_cocsep_t) {
@@ -163,7 +160,6 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg)
163 uint8_t m, t, tinv, olddepth; 160 uint8_t m, t, tinv, olddepth;
164 uint32_t cc; 161 uint32_t cc;
165 int64_t i, ii; 162 int64_t i, ii;
166 uint64_t sim;
167 cube_fast_t d; 163 cube_fast_t d;
168 dfsarg_cocsep_t nextarg; 164 dfsarg_cocsep_t nextarg;
169 165
@@ -208,10 +204,10 @@ TODO description
208generating fixed table with h=0, k=4 204generating fixed table with h=0, k=4
209*/ 205*/
210_static size_t 206_static size_t
211gendata_h48(void *buf, uint8_t h) 207gendata_h48(void *buf, uint8_t h, uint8_t maxdepth)
212{ 208{
213 const int k = 1; /* TODO: other cases? */ 209 const int k = 4; /* TODO: other cases? */
214 uint32_t *buf32, *info, *cocsepdata; 210 uint32_t j, *buf32, *info, *cocsepdata;
215 bfsarg_esep_t arg; 211 bfsarg_esep_t arg;
216 int64_t sc, cc, tot; 212 int64_t sc, cc, tot;
217 uint64_t selfsim[COCSEP_CLASSES]; 213 uint64_t selfsim[COCSEP_CLASSES];
@@ -219,17 +215,14 @@ gendata_h48(void *buf, uint8_t h)
219 size_t cocsepsize; 215 size_t cocsepsize;
220 216
221 cocsepsize = gendata_cocsep(buf, selfsim, crep); 217 cocsepsize = gendata_cocsep(buf, selfsim, crep);
222 DBG_ASSERT(cocsepsize == COCSEP_FULLSIZE, 0,
223 "gendata_h48: error computing cocsep data\n");
224
225 cocsepdata = (uint32_t *)buf; 218 cocsepdata = (uint32_t *)buf;
226 buf32 = cocsepdata + cocsepsize; 219 buf32 = cocsepdata + cocsepsize/4;
227 info = buf32 + ESEP_TABLESIZE(h, k); 220 info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t));
228 memset(buf32, 0xFFU, sizeof(uint32_t) * ESEP_TABLESIZE(h, k)); 221 memset(buf32, 0xFFU, ESEP_TABLESIZE(h, k));
229 memset(info, 0, sizeof(uint32_t) * ESEP_INFOSIZE);
230 222
231 sc = coord_h48(cubetofast(solved), cocsepdata, h); 223 sc = coord_h48(cubetofast(solved), cocsepdata, h);
232 set_esep_pval(buf32, sc, 0); 224 set_esep_pval(buf32, sc, 0);
225 info[1] = 1;
233 arg = (bfsarg_esep_t) { 226 arg = (bfsarg_esep_t) {
234 .h = h, 227 .h = h,
235 .cocsepdata = cocsepdata, 228 .cocsepdata = cocsepdata,
@@ -237,7 +230,11 @@ gendata_h48(void *buf, uint8_t h)
237 .crep = crep, 230 .crep = crep,
238 .selfsim = selfsim 231 .selfsim = selfsim
239 }; 232 };
240 for (tot = 1, arg.depth = 1, cc = 0; tot < ESEP_MAX(h); arg.depth++) { 233 for (
234 tot = 1, arg.depth = 1, cc = 0;
235 tot < ESEP_MAX(h) && arg.depth <= maxdepth;
236 arg.depth++
237 ) {
241 DBG_LOG("esep: generating depth %" PRIu8 "\n", arg.depth); 238 DBG_LOG("esep: generating depth %" PRIu8 "\n", arg.depth);
242 cc = gendata_esep_bfs(&arg); 239 cc = gendata_esep_bfs(&arg);
243 tot += cc; 240 tot += cc;
@@ -245,7 +242,15 @@ gendata_h48(void *buf, uint8_t h)
245 DBG_LOG("found %" PRIu64 "\n", cc); 242 DBG_LOG("found %" PRIu64 "\n", cc);
246 } 243 }
247 244
248 return COCSEP_FULLSIZE + cc; 245 info[0] = arg.depth-1;
246
247 DBG_LOG("h48 pruning table computed\n");
248 DBG_LOG("Maximum pruning value: %" PRIu32 "\n", info[0]);
249 DBG_LOG("Pruning value distribution:\n");
250 for (j = 0; j <= info[0]; j++)
251 DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+1]);
252
253 return COCSEP_FULLSIZE + ESEP_TABLESIZE(h, k) + 4*(info[0]+2);
249} 254}
250 255
251_static uint64_t 256_static uint64_t

Generated with cgit - Back to sebastiano.tronto.net