aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/solvers/h48/gendata_h48.h366
1 files changed, 230 insertions, 136 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 2a62b1d..3445570 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -33,6 +33,7 @@ _t by _ttrep).
33typedef struct { 33typedef struct {
34 uint8_t h; 34 uint8_t h;
35 uint8_t k; 35 uint8_t k;
36 uint8_t base;
36 uint8_t maxdepth; 37 uint8_t maxdepth;
37 tableinfo_t info; 38 tableinfo_t info;
38 void *buf; 39 void *buf;
@@ -56,6 +57,12 @@ typedef struct {
56 uint8_t *table; 57 uint8_t *table;
57 uint64_t *selfsim; 58 uint64_t *selfsim;
58 cube_t *crep; 59 cube_t *crep;
60 uint64_t start;
61 uint64_t end;
62 uint64_t count;
63 uint64_t *distribution;
64 pthread_mutex_t *distribution_mutex;
65 pthread_mutex_t *table_mutex[CHUNKS];
59} h48h0k4_bfs_arg_t; 66} h48h0k4_bfs_arg_t;
60 67
61typedef struct { 68typedef struct {
@@ -75,17 +82,28 @@ typedef struct {
75 uint64_t *count; 82 uint64_t *count;
76} h48k2_dfs_arg_t; 83} h48k2_dfs_arg_t;
77 84
85typedef struct {
86 cube_t cube;
87 int8_t depth;
88 uint8_t h;
89 uint8_t k;
90 uint32_t *cocsepdata;
91 uint64_t *selfsim;
92 uint8_t *table;
93 pthread_mutex_t **table_mutex;
94} gendata_h48_mark_t;
95
78STATIC uint64_t gendata_h48short(gendata_h48short_arg_t *); 96STATIC uint64_t gendata_h48short(gendata_h48short_arg_t *);
79STATIC size_t gendata_h48(gendata_h48_arg_t *); 97STATIC size_t gendata_h48(gendata_h48_arg_t *);
80STATIC size_t gendata_h48h0k4(gendata_h48_arg_t *); 98STATIC size_t gendata_h48h0k4(gendata_h48_arg_t *);
81STATIC int64_t gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *);
82STATIC int64_t gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *);
83STATIC int64_t gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *);
84STATIC size_t gendata_h48k2(gendata_h48_arg_t *); 99STATIC size_t gendata_h48k2(gendata_h48_arg_t *);
85STATIC void * gendata_h48k2_runthread(void *); 100STATIC void * gendata_h48h0k4_runthread(void *);
86STATIC_INLINE void gendata_h48k2_mark(cube_t, int8_t, h48k2_dfs_arg_t *); 101STATIC_INLINE uint64_t gendata_h48_mark(gendata_h48_mark_t *);
87STATIC_INLINE bool gendata_h48k2_dfs_stop(cube_t, uint8_t, h48k2_dfs_arg_t *); 102STATIC_INLINE bool gendata_h48k2_dfs_stop(cube_t, int8_t, h48k2_dfs_arg_t *);
103STATIC size_t gendata_h48k2_realcoord(gendata_h48_arg_t *);
88STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); 104STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg);
105STATIC void * gendata_h48k2_runthread(void *);
106STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *, uint8_t);
89 107
90STATIC uint32_t *get_cocsepdata_ptr(const void *); 108STATIC uint32_t *get_cocsepdata_ptr(const void *);
91STATIC uint8_t *get_h48data_ptr(const void *); 109STATIC uint8_t *get_h48data_ptr(const void *);
@@ -147,8 +165,12 @@ gendata_h48(gendata_h48_arg_t *arg)
147 arg->cocsepdata = (uint32_t *)cocsepdata_offset; 165 arg->cocsepdata = (uint32_t *)cocsepdata_offset;
148 arg->h48buf = (char *)arg->buf + cocsepsize; 166 arg->h48buf = (char *)arg->buf + cocsepsize;
149 167
168 arg->base = 99; // TODO: set this somewhere else
169
150 if (arg->h == 0 && arg->k == 4) { 170 if (arg->h == 0 && arg->k == 4) {
151 h48size = gendata_h48h0k4(arg); 171 h48size = gendata_h48h0k4(arg);
172 } else if ((arg->h == 0 || arg->h == 11) && arg->k == 2) {
173 h48size = gendata_h48k2_realcoord(arg);
152 } else if (arg->k == 2) { 174 } else if (arg->k == 2) {
153 h48size = gendata_h48k2(arg); 175 h48size = gendata_h48k2(arg);
154 } else { 176 } else {
@@ -179,17 +201,15 @@ gendata_h48_error:
179 return 0; 201 return 0;
180} 202}
181 203
182/*
183TODO description
184generating fixed table with h=0, k=4
185*/
186STATIC size_t 204STATIC size_t
187gendata_h48h0k4(gendata_h48_arg_t *arg) 205gendata_h48h0k4(gendata_h48_arg_t *arg)
188{ 206{
189 uint32_t j;
190 uint8_t *table; 207 uint8_t *table;
191 h48h0k4_bfs_arg_t bfsarg; 208 int64_t sc, done, d, h48max;
192 int64_t sc, cc, done, h48max; 209 uint64_t t, tt, isize, cc;
210 h48h0k4_bfs_arg_t bfsarg[THREADS];
211 pthread_t thread[THREADS];
212 pthread_mutex_t distribution_mutex, table_mutex[CHUNKS];
193 213
194 if (arg->buf == NULL) 214 if (arg->buf == NULL)
195 goto gendata_h48h0k4_return_size; 215 goto gendata_h48h0k4_return_size;
@@ -216,109 +236,134 @@ gendata_h48h0k4(gendata_h48_arg_t *arg)
216 sc = coord_h48(SOLVED_CUBE, arg->cocsepdata, 0); 236 sc = coord_h48(SOLVED_CUBE, arg->cocsepdata, 0);
217 set_h48_pval(table, sc, 4, 0); 237 set_h48_pval(table, sc, 4, 0);
218 arg->info.distribution[0] = 1; 238 arg->info.distribution[0] = 1;
219 bfsarg = (h48h0k4_bfs_arg_t) { 239
220 .cocsepdata = arg->cocsepdata, 240 isize = h48max / THREADS;
221 .table = table, 241 isize = (isize / H48_COEFF(arg->k)) * H48_COEFF(arg->k);
222 .selfsim = arg->selfsim, 242 pthread_mutex_init(&distribution_mutex, NULL);
223 .crep = arg->crep 243 for (t = 0; t < CHUNKS; t++)
224 }; 244 pthread_mutex_init(&table_mutex[t], NULL);
225 for ( 245 for (t = 0; t < THREADS; t++) {
226 done = 1, bfsarg.depth = 1, cc = 0; 246 bfsarg[t] = (h48h0k4_bfs_arg_t) {
227 done < h48max && bfsarg.depth <= arg->maxdepth; 247 .cocsepdata = arg->cocsepdata,
228 bfsarg.depth++ 248 .table = table,
229 ) { 249 .selfsim = arg->selfsim,
230 LOG("h48: generating depth %" PRIu8 "\n", bfsarg.depth); 250 .crep = arg->crep,
231 cc = gendata_h48h0k4_bfs(&bfsarg); 251 .start = isize * t,
232 done += cc; 252 .end = t == THREADS-1 ? (uint64_t)h48max : isize * (t+1),
233 arg->info.distribution[bfsarg.depth] = cc; 253 .distribution = arg->info.distribution,
234 LOG("found %" PRId64 "\n", cc); 254 .distribution_mutex = &distribution_mutex,
255 };
256 for (tt = 0; tt < CHUNKS; tt++)
257 bfsarg[t].table_mutex[tt] = &table_mutex[tt];
235 } 258 }
259 for (done = 1, d = 1; done < h48max && d <= arg->maxdepth; d++) {
260 LOG("h48: generating depth %" PRIu8 "\n", d);
261
262 for (t = 0; t < THREADS; t++) {
263 bfsarg[t].depth = d;
264 bfsarg[t].count = 0;
265 pthread_create(&thread[t], NULL,
266 gendata_h48h0k4_runthread, &bfsarg[t]);
267 }
236 268
237 arg->info.maxvalue = bfsarg.depth-1; 269 for (t = 0, cc = 0; t < THREADS; t++) {
270 pthread_join(thread[t], NULL);
271 cc += bfsarg[t].count;
272 }
238 273
239 LOG("h48 pruning table computed\n"); 274 done += cc;
240 LOG("Maximum pruning value: %" PRIu32 "\n", arg->info.maxvalue); 275 arg->info.distribution[d] = cc;
241 LOG("Pruning value distribution:\n");
242 for (j = 0; j <= arg->info.maxvalue; j++)
243 LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, arg->info.distribution[j]);
244 276
277 LOG("found %" PRId64 "\n", cc);
278 }
279
280 arg->info.maxvalue = d - 1;
245 writetableinfo(&arg->info, arg->h48buf); 281 writetableinfo(&arg->info, arg->h48buf);
246 282
247gendata_h48h0k4_return_size: 283gendata_h48h0k4_return_size:
248 return H48_TABLESIZE(0, 4) + INFOSIZE; 284 return H48_TABLESIZE(0, 4) + INFOSIZE;
249} 285}
250 286
251STATIC int64_t 287/*
252gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *arg) 288TODO: the following function suffers from a big performance loss (about 40%)
253{ 289because of all the mutex locking. It is possible to reduce the first lock
254 const uint8_t breakpoint = 10; /* Hand-picked optimal */ 290(at the beginning of the outermost for loop) by caching the next few items at
291once and then looping over the cached elements. But for the second one (inner
292loop) the access is non-sequential, so this cannot be done.
255 293
256 if (arg->depth < breakpoint) 294However, in both cases in theory we do not care if we are reading the old
257 return gendata_h48h0k4_bfs_fromdone(arg); 295value or the updated one. Depending on the compiler guarantees on concurrent
258 else 296memory access, we may be fine just removing the locks altogether.
259 return gendata_h48h0k4_bfs_fromnew(arg);
260}
261 297
262STATIC int64_t 298It is probably possible to solve part of this by using atomics.
263gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *arg) 299*/
300STATIC void *
301gendata_h48h0k4_runthread(void *arg)
264{ 302{
265 uint8_t c, m, x; 303 static const uint8_t breakpoint = 10; /* Hand-picked optimal */
266 uint32_t cc; 304
267 int64_t i, j, k; 305 uint8_t c, m;
306 uint64_t i, d, mutex;
307 int64_t j;
268 cube_t cube, moved; 308 cube_t cube, moved;
309 gendata_h48_mark_t markarg;
310 h48h0k4_bfs_arg_t *bfsarg;
269 311
270 for (i = 0, cc = 0; i < (int64_t)H48_COORDMAX(0); i++) { 312 bfsarg = (h48h0k4_bfs_arg_t *)arg;
271 c = get_h48_pval(arg->table, i, 4);
272 if (c != arg->depth - 1)
273 continue;
274 cube = invcoord_h48(i, arg->crep, 0);
275 for (m = 0; m < 18; m++) {
276 moved = move(cube, m);
277 j = coord_h48(moved, arg->cocsepdata, 0);
278 if (get_h48_pval(arg->table, j, 4) <= arg->depth)
279 continue;
280 FOREACH_H48SIM(moved, arg->cocsepdata, arg->selfsim,
281 k = coord_h48(moved, arg->cocsepdata, 0);
282 x = get_h48_pval(arg->table, k, 4);
283 set_h48_pval(arg->table, k, 4, arg->depth);
284 cc += x != arg->depth;
285 )
286 }
287 }
288 313
289 return cc; 314 markarg = (gendata_h48_mark_t) {
290} 315 .depth = bfsarg->depth,
316 .h = 0,
317 .k = 4,
318 .cocsepdata = bfsarg->cocsepdata,
319 .selfsim = bfsarg->selfsim,
320 .table = bfsarg->table,
321 .table_mutex = bfsarg->table_mutex,
322 };
291 323
292STATIC int64_t 324 /*
293gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *arg) 325 * If depth < breakpoint, scan all neighbors of coordinates at depth-1.
294{ 326 * Otherwise, scan all neighbors of unvisited coordinates.
295 uint8_t c, m, x; 327 */
296 uint32_t cc; 328 for (i = bfsarg->start, d = 0; i < bfsarg->end; i++) {
297 int64_t i, j; 329 mutex = H48_INDEX(i, 4) % CHUNKS;
298 cube_t cube, moved; 330 pthread_mutex_lock(bfsarg->table_mutex[mutex]);
331 c = get_h48_pval(bfsarg->table, i, 4);
332 pthread_mutex_unlock(bfsarg->table_mutex[mutex]);
299 333
300 for (i = 0, cc = 0; i < (int64_t)H48_COORDMAX(0); i++) { 334 if ((bfsarg->depth < breakpoint && c != bfsarg->depth - 1) ||
301 c = get_h48_pval(arg->table, i, 4); 335 (bfsarg->depth >= breakpoint && c != 0xF))
302 if (c != 0xF)
303 continue; 336 continue;
304 cube = invcoord_h48(i, arg->crep, 0); 337
338 cube = invcoord_h48(i, bfsarg->crep, 0);
305 for (m = 0; m < 18; m++) { 339 for (m = 0; m < 18; m++) {
306 moved = move(cube, m); 340 moved = move(cube, m);
307 j = coord_h48(moved, arg->cocsepdata, 0); 341 j = coord_h48(moved, bfsarg->cocsepdata, 0);
308 x = get_h48_pval(arg->table, j, 4); 342 mutex = H48_INDEX(j, 4) % CHUNKS;
309 if (x >= arg->depth) 343 pthread_mutex_lock(bfsarg->table_mutex[mutex]);
310 continue; 344 c = get_h48_pval(bfsarg->table, j, 4);
311 FOREACH_H48SIM(cube, arg->cocsepdata, arg->selfsim, 345 pthread_mutex_unlock(bfsarg->table_mutex[mutex]);
312 j = coord_h48(cube, arg->cocsepdata, 0); 346 if (bfsarg->depth < breakpoint) {
313 x = get_h48_pval(arg->table, j, 4); 347 if (c <= bfsarg->depth)
314 set_h48_pval(arg->table, j, 4, arg->depth); 348 continue;
315 cc += x == 0xF; 349 markarg.cube = moved;
316 ) 350 d += gendata_h48_mark(&markarg);
317 break; /* Enough to find one, skip the rest */ 351 } else {
352 if (c >= bfsarg->depth)
353 continue;
354 markarg.cube = cube;
355 d += gendata_h48_mark(&markarg);
356 break; /* Enough to find one, skip the rest */
357 }
318 } 358 }
319 } 359 }
320 360
321 return cc; 361 pthread_mutex_lock(bfsarg->distribution_mutex);
362 bfsarg->count += d;
363 bfsarg->distribution[bfsarg->depth] += d;
364 pthread_mutex_unlock(bfsarg->distribution_mutex);
365
366 return NULL;
322} 367}
323 368
324STATIC size_t 369STATIC size_t
@@ -369,24 +414,8 @@ gendata_h48k2(gendata_h48_arg_t *arg)
369 }; 414 };
370 gendata_h48short(&shortarg); 415 gendata_h48short(&shortarg);
371 416
372 selectedbase = base[arg->h]; 417 selectedbase = arg->base < 20 ? arg->base : base[arg->h];
373 arg->info = (tableinfo_t) { 418 arg->info = makeinfo_h48k2(arg, selectedbase);
374 .solver = "h48 solver h = , k = 2",
375 .type = TABLETYPE_PRUNING,
376 .infosize = INFOSIZE,
377 .fullsize = H48_TABLESIZE(arg->h, 2) + INFOSIZE,
378 .hash = 0, /* TODO */
379 .entries = H48_COORDMAX(arg->h),
380 .classes = 0,
381 .h48h = arg->h,
382 .bits = 2,
383 .base = selectedbase,
384 .maxvalue = 3,
385 .next = 0,
386 };
387 arg->info.solver[15] = (arg->h % 10) + '0';
388 if (arg->h >= 10)
389 arg->info.solver[14] = (arg->h / 10) + '0';
390 419
391 inext = count = 0; 420 inext = count = 0;
392 pthread_mutex_init(&shortcubes_mutex, NULL); 421 pthread_mutex_init(&shortcubes_mutex, NULL);
@@ -419,6 +448,7 @@ gendata_h48k2(gendata_h48_arg_t *arg)
419 448
420 h48map_destroy(&shortcubes); 449 h48map_destroy(&shortcubes);
421 450
451 /* TODO: inline into mark */
422 for (j = 0; j < H48_COORDMAX(arg->h); j++) { 452 for (j = 0; j < H48_COORDMAX(arg->h); j++) {
423 t = get_h48_pval(table, j, 2); 453 t = get_h48_pval(table, j, 2);
424 arg->info.distribution[t]++; 454 arg->info.distribution[t]++;
@@ -474,21 +504,36 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t *arg)
474 int8_t d; 504 int8_t d;
475 uint8_t m[4]; 505 uint8_t m[4];
476 cube_t cube[4]; 506 cube_t cube[4];
507 gendata_h48_mark_t markarg;
508
509 markarg = (gendata_h48_mark_t) {
510 .h = arg->h,
511 .k = arg->k,
512 .cocsepdata = arg->cocsepdata,
513 .selfsim = arg->selfsim,
514 .table = arg->table,
515 .table_mutex = arg->table_mutex,
516 };
477 517
478 d = (int8_t)arg->shortdepth - (int8_t)arg->base; 518 d = (int8_t)arg->shortdepth - (int8_t)arg->base;
479 519
480 /* Depth d+0 (shortcubes) */ 520 /* Depth d+0 (shortcubes) */
481 gendata_h48k2_mark(arg->cube, d, arg); 521 markarg.depth = d;
522 markarg.cube = arg->cube;
523 gendata_h48_mark(&markarg);
482 524
483 /* Depth d+1 */ 525 /* Depth d+1 */
484 for (m[0] = 0; m[0] < 18; m[0]++) { 526 for (m[0] = 0; m[0] < 18; m[0]++) {
527 markarg.depth = d+1;
485 cube[0] = move(arg->cube, m[0]); 528 cube[0] = move(arg->cube, m[0]);
486 if (gendata_h48k2_dfs_stop(cube[0], d+1, arg)) 529 if (gendata_h48k2_dfs_stop(cube[0], d+1, arg))
487 continue; 530 continue;
488 gendata_h48k2_mark(cube[0], d+1, arg); 531 markarg.cube = cube[0];
532 gendata_h48_mark(&markarg);
489 533
490 /* Depth d+2 */ 534 /* Depth d+2 */
491 for (m[1] = 0; m[1] < 18; m[1]++) { 535 for (m[1] = 0; m[1] < 18; m[1]++) {
536 markarg.depth = d+2;
492 if (m[0] / 3 == m[1] / 3) { 537 if (m[0] / 3 == m[1] / 3) {
493 m[1] += 2; 538 m[1] += 2;
494 continue; 539 continue;
@@ -496,12 +541,14 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t *arg)
496 cube[1] = move(cube[0], m[1]); 541 cube[1] = move(cube[0], m[1]);
497 if (gendata_h48k2_dfs_stop(cube[1], d+2, arg)) 542 if (gendata_h48k2_dfs_stop(cube[1], d+2, arg))
498 continue; 543 continue;
499 gendata_h48k2_mark(cube[1], d+2, arg); 544 markarg.cube = cube[1];
545 gendata_h48_mark(&markarg);
500 if (d >= 0) 546 if (d >= 0)
501 continue; 547 continue;
502 548
503 /* Depth d+3 */ 549 /* Depth d+3 */
504 for (m[2] = 0; m[2] < 18; m[2]++) { 550 for (m[2] = 0; m[2] < 18; m[2]++) {
551 markarg.depth = d+3;
505 if (!allowednextmove(m, 3)) { 552 if (!allowednextmove(m, 3)) {
506 m[2] += 2; 553 m[2] += 2;
507 continue; 554 continue;
@@ -509,48 +556,55 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t *arg)
509 cube[2] = move(cube[1], m[2]); 556 cube[2] = move(cube[1], m[2]);
510 if (gendata_h48k2_dfs_stop(cube[2], d+3, arg)) 557 if (gendata_h48k2_dfs_stop(cube[2], d+3, arg))
511 continue; 558 continue;
512 gendata_h48k2_mark(cube[2], d+3, arg); 559 markarg.cube = cube[2];
560 gendata_h48_mark(&markarg);
513 if (d >= -1) 561 if (d >= -1)
514 continue; 562 continue;
515 563
516 /* Depth d+4 */ 564 /* Depth d+4 */
517 for (m[3] = 0; m[3] < 18; m[3]++) { 565 for (m[3] = 0; m[3] < 18; m[3]++) {
566 markarg.depth = d+4;
518 if (!allowednextmove(m, 4)) { 567 if (!allowednextmove(m, 4)) {
519 m[3] += 2; 568 m[3] += 2;
520 continue; 569 continue;
521 } 570 }
522 cube[3] = move(cube[2], m[3]); 571 cube[3] = move(cube[2], m[3]);
523 gendata_h48k2_mark(cube[3], d+4, arg); 572 markarg.cube = cube[3];
573 gendata_h48_mark(&markarg);
524 } 574 }
525 } 575 }
526 } 576 }
527 } 577 }
528} 578}
529 579
530STATIC_INLINE void 580STATIC_INLINE uint64_t
531gendata_h48k2_mark(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) 581gendata_h48_mark(gendata_h48_mark_t *arg)
532{ 582{
533 uint8_t oldval, newval; 583 uint8_t oldval, newval;
534 int64_t coord, fullcoord, mutex; 584 uint64_t d;
585 int64_t coord, mutex;
535 586
536 FOREACH_H48SIM(cube, arg->cocsepdata, arg->selfsim, 587 d = 0;
537 fullcoord = coord_h48(cube, arg->cocsepdata, 11); 588 FOREACH_H48SIM(arg->cube, arg->cocsepdata, arg->selfsim,
538 coord = fullcoord >> (int64_t)(11 - arg->h); 589 coord = coord_h48(arg->cube, arg->cocsepdata, arg->h);
539 mutex = H48_INDEX(coord, arg->k) % CHUNKS; 590 mutex = H48_INDEX(coord, arg->k) % CHUNKS;
540 pthread_mutex_lock(arg->table_mutex[mutex]); 591 pthread_mutex_lock(arg->table_mutex[mutex]);
541 oldval = get_h48_pval(arg->table, coord, arg->k); 592 oldval = get_h48_pval(arg->table, coord, arg->k);
542 newval = (uint8_t)MAX(depth, 0); 593 newval = (uint8_t)MAX(arg->depth, 0);
594 d += newval < oldval;
543 set_h48_pval(arg->table, coord, arg->k, MIN(oldval, newval)); 595 set_h48_pval(arg->table, coord, arg->k, MIN(oldval, newval));
544 pthread_mutex_unlock(arg->table_mutex[mutex]); 596 pthread_mutex_unlock(arg->table_mutex[mutex]);
545 ) 597 )
598
599 return d;
546} 600}
547 601
548STATIC_INLINE bool 602STATIC_INLINE bool
549gendata_h48k2_dfs_stop(cube_t cube, uint8_t depth, h48k2_dfs_arg_t *arg) 603gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg)
550{ 604{
551 uint64_t val; 605 uint64_t val;
552 int64_t coord; 606 int64_t coord;
553 uint8_t oldval; 607 int8_t oldval;
554 608
555 if (arg->h == 0 || arg->h == 11) { 609 if (arg->h == 0 || arg->h == 11) {
556 /* We are in the "real coordinate" case, we can stop 610 /* We are in the "real coordinate" case, we can stop
@@ -568,26 +622,44 @@ gendata_h48k2_dfs_stop(cube_t cube, uint8_t depth, h48k2_dfs_arg_t *arg)
568 } 622 }
569} 623}
570 624
571STATIC_INLINE uint8_t 625STATIC size_t
572get_h48_pval(const uint8_t *table, int64_t i, uint8_t k) 626gendata_h48k2_realcoord(gendata_h48_arg_t *arg)
573{ 627{
574 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); 628 /* TODO */
629 return gendata_h48k2(arg);
575} 630}
576 631
577STATIC_INLINE void 632STATIC void *
578set_h48_pval(uint8_t *table, int64_t i, uint8_t k, uint8_t val) 633gendata_h48k2_realcoord_runthread(void *arg)
579{ 634{
580 table[H48_INDEX(i, k)] = (table[H48_INDEX(i, k)] & (~H48_MASK(i, k))) 635 /* TODO */
581 | (val << H48_SHIFT(i, k)); 636 return NULL;
582} 637}
583 638
584STATIC_INLINE uint8_t 639STATIC tableinfo_t
585get_h48_bound(cube_t cube, uint32_t cdata, uint8_t h, uint8_t k, uint8_t *table) 640makeinfo_h48k2(gendata_h48_arg_t *arg, uint8_t base)
586{ 641{
587 int64_t coord; 642 tableinfo_t info;
588 643
589 coord = coord_h48_edges(cube, COCLASS(cdata), TTREP(cdata), h); 644 info = (tableinfo_t) {
590 return get_h48_pval(table, coord, k); 645 .solver = "h48 solver h = , k = 2",
646 .type = TABLETYPE_PRUNING,
647 .infosize = INFOSIZE,
648 .fullsize = H48_TABLESIZE(arg->h, 2) + INFOSIZE,
649 .hash = 0, /* TODO */
650 .entries = H48_COORDMAX(arg->h),
651 .classes = 0,
652 .h48h = arg->h,
653 .bits = 2,
654 .base = base,
655 .maxvalue = 3,
656 .next = 0,
657 };
658 info.solver[15] = (arg->h % 10) + '0';
659 if (arg->h >= 10)
660 info.solver[14] = (arg->h / 10) + '0';
661
662 return info;
591} 663}
592 664
593STATIC uint32_t * 665STATIC uint32_t *
@@ -601,3 +673,25 @@ get_h48data_ptr(const void *data)
601{ 673{
602 return (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE; 674 return (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE;
603} 675}
676
677STATIC_INLINE uint8_t
678get_h48_pval(const uint8_t *table, int64_t i, uint8_t k)
679{
680 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k);
681}
682
683STATIC_INLINE void
684set_h48_pval(uint8_t *table, int64_t i, uint8_t k, uint8_t val)
685{
686 table[H48_INDEX(i, k)] = (table[H48_INDEX(i, k)] & (~H48_MASK(i, k)))
687 | (val << H48_SHIFT(i, k));
688}
689
690STATIC_INLINE uint8_t
691get_h48_bound(cube_t cube, uint32_t cdata, uint8_t h, uint8_t k, uint8_t *table)
692{
693 int64_t coord;
694
695 coord = coord_h48_edges(cube, COCLASS(cdata), TTREP(cdata), h);
696 return get_h48_pval(table, coord, k);
697}

Generated with cgit - Back to sebastiano.tronto.net