aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/gendata_h48.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-07-29 12:12:43 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-07-29 12:12:43 +0200
commitea0387796a349c91032fbcb10f50c6ad8607b0f6 (patch)
treeaed484690d24c0c28c7695d4b5389f2e3c341b96 /src/solvers/h48/gendata_h48.h
parent52c21640508c3fc668107778ae027ff4428ebd89 (diff)
downloadnissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.tar.gz
nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.zip
All coordinates unsigned
Diffstat (limited to 'src/solvers/h48/gendata_h48.h')
-rw-r--r--src/solvers/h48/gendata_h48.h42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 72cb05d..c75556d 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -18,12 +18,12 @@ STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t [static 1]);
18STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); 18STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *);
19STATIC const unsigned char *get_h48data_constptr(const unsigned char *); 19STATIC const unsigned char *get_h48data_constptr(const unsigned char *);
20 20
21STATIC_INLINE uint8_t get_h48_pval(const unsigned char *, int64_t, uint8_t); 21STATIC_INLINE uint8_t get_h48_pval(const unsigned char *, uint64_t, uint8_t);
22STATIC_INLINE void set_h48_pval(unsigned char *, int64_t, uint8_t, uint8_t); 22STATIC_INLINE void set_h48_pval(unsigned char *, uint64_t, uint8_t, uint8_t);
23STATIC_INLINE uint8_t get_h48_pval_atomic( 23STATIC_INLINE uint8_t get_h48_pval_atomic(
24 _Atomic const unsigned char *, int64_t, uint8_t); 24 _Atomic const unsigned char *, uint64_t, uint8_t);
25STATIC_INLINE void set_h48_pval_atomic( 25STATIC_INLINE void set_h48_pval_atomic(
26 _Atomic unsigned char *, int64_t, uint8_t, uint8_t); 26 _Atomic unsigned char *, uint64_t, uint8_t, uint8_t);
27 27
28STATIC long long 28STATIC long long
29gendata_h48_dispatch( 29gendata_h48_dispatch(
@@ -50,7 +50,7 @@ STATIC uint64_t
50gendata_h48short(gendata_h48short_arg_t arg[static 1]) 50gendata_h48short(gendata_h48short_arg_t arg[static 1])
51{ 51{
52 uint8_t i, m; 52 uint8_t i, m;
53 int64_t coord; 53 uint64_t coord;
54 uint64_t j; 54 uint64_t j;
55 kvpair_t kv; 55 kvpair_t kv;
56 cube_t cube, d; 56 cube_t cube, d;
@@ -106,7 +106,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1])
106 106
107 if (arg->buf_size < size) { 107 if (arg->buf_size < size) {
108 LOG("[H48 gendata] Error: buffer is too small " 108 LOG("[H48 gendata] Error: buffer is too small "
109 "(needed %" PRId64 " bytes but received %" PRId64 ")\n", 109 "(needed %" PRId64 " bytes but received %" PRIu64 ")\n",
110 size, arg->buf_size); 110 size, arg->buf_size);
111 return NISSY_ERROR_BUFFER_SIZE; 111 return NISSY_ERROR_BUFFER_SIZE;
112 } 112 }
@@ -209,7 +209,7 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1])
209{ 209{
210 _Atomic unsigned char *table; 210 _Atomic unsigned char *table;
211 uint8_t val; 211 uint8_t val;
212 int64_t i, sc, done, d, h48max; 212 uint64_t i, sc, done, d, h48max;
213 uint64_t t, tt, isize, cc, bufsize; 213 uint64_t t, tt, isize, cc, bufsize;
214 h48h0k4_bfs_arg_t bfsarg[THREADS]; 214 h48h0k4_bfs_arg_t bfsarg[THREADS];
215 pthread_t thread[THREADS]; 215 pthread_t thread[THREADS];
@@ -233,7 +233,7 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1])
233 table = arg->h48buf + INFOSIZE; 233 table = arg->h48buf + INFOSIZE;
234 memset(table, 0xFF, H48_TABLESIZE(0, 4)); 234 memset(table, 0xFF, H48_TABLESIZE(0, 4));
235 235
236 h48max = (int64_t)H48_COORDMAX(0); 236 h48max = H48_COORDMAX(0);
237 sc = coord_h48(SOLVED_CUBE, arg->cocsepdata, 0); 237 sc = coord_h48(SOLVED_CUBE, arg->cocsepdata, 0);
238 set_h48_pval_atomic(table, sc, 4, 0); 238 set_h48_pval_atomic(table, sc, 4, 0);
239 arg->info.distribution[0] = 1; 239 arg->info.distribution[0] = 1;
@@ -249,13 +249,13 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1])
249 .selfsim = arg->selfsim, 249 .selfsim = arg->selfsim,
250 .crep = arg->crep, 250 .crep = arg->crep,
251 .start = isize * t, 251 .start = isize * t,
252 .end = t == THREADS-1 ? (uint64_t)h48max : isize * (t+1), 252 .end = t == THREADS-1 ? h48max : isize * (t+1),
253 }; 253 };
254 for (tt = 0; tt < CHUNKS; tt++) 254 for (tt = 0; tt < CHUNKS; tt++)
255 bfsarg[t].table_mutex[tt] = &table_mutex[tt]; 255 bfsarg[t].table_mutex[tt] = &table_mutex[tt];
256 } 256 }
257 for (done = 1, d = 1; done < h48max && d <= arg->maxdepth; d++) { 257 for (done = 1, d = 1; done < h48max && d <= arg->maxdepth; d++) {
258 LOG("[H48 gendata] Generating depth %" PRId64 "\n", d); 258 LOG("[H48 gendata] Generating depth %" PRIu64 "\n", d);
259 259
260 for (t = 0; t < THREADS; t++) { 260 for (t = 0; t < THREADS; t++) {
261 bfsarg[t].depth = d; 261 bfsarg[t].depth = d;
@@ -274,7 +274,7 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1])
274 done += cc; 274 done += cc;
275 arg->info.distribution[d] = cc; 275 arg->info.distribution[d] = cc;
276 276
277 LOG("[H48 gendata] Found %" PRId64 "\n", cc); 277 LOG("[H48 gendata] Found %" PRIu64 "\n", cc);
278 } 278 }
279 279
280 arg->info.maxvalue = d - 1; 280 arg->info.maxvalue = d - 1;
@@ -289,7 +289,7 @@ gendata_h48h0k4_runthread(void *arg)
289 289
290 uint8_t c, m; 290 uint8_t c, m;
291 uint64_t i; 291 uint64_t i;
292 int64_t j; 292 uint64_t j;
293 cube_t cube, moved; 293 cube_t cube, moved;
294 gendata_h48_mark_t markarg; 294 gendata_h48_mark_t markarg;
295 h48h0k4_bfs_arg_t *bfsarg; 295 h48h0k4_bfs_arg_t *bfsarg;
@@ -394,7 +394,7 @@ gendata_h48k2(gendata_h48_arg_t arg[static 1])
394 uint8_t t; 394 uint8_t t;
395 int sleeptime; 395 int sleeptime;
396 unsigned char *table; 396 unsigned char *table;
397 int64_t j; 397 uint64_t j;
398 _Atomic uint64_t count; 398 _Atomic uint64_t count;
399 uint64_t i, ii, inext, bufsize, done, nshort, velocity; 399 uint64_t i, ii, inext, bufsize, done, nshort, velocity;
400 h48map_t shortcubes; 400 h48map_t shortcubes;
@@ -510,7 +510,7 @@ gendata_h48k2_runthread(void *arg)
510 pthread_mutex_unlock(dfsarg->shortcubes_mutex); 510 pthread_mutex_unlock(dfsarg->shortcubes_mutex);
511 511
512 if (kv.val < dfsarg->shortdepth) { 512 if (kv.val < dfsarg->shortdepth) {
513 coord = kv.key >> (int64_t)(11 - dfsarg->h); 513 coord = kv.key >> (uint64_t)(11 - dfsarg->h);
514 mutex = H48_INDEX(coord, dfsarg->k) % CHUNKS; 514 mutex = H48_INDEX(coord, dfsarg->k) % CHUNKS;
515 pthread_mutex_lock(dfsarg->table_mutex[mutex]); 515 pthread_mutex_lock(dfsarg->table_mutex[mutex]);
516 set_h48_pval(dfsarg->table, coord, dfsarg->k, 0); 516 set_h48_pval(dfsarg->table, coord, dfsarg->k, 0);
@@ -607,7 +607,7 @@ STATIC_INLINE void
607gendata_h48_mark_atomic(gendata_h48_mark_t arg[static 1]) 607gendata_h48_mark_atomic(gendata_h48_mark_t arg[static 1])
608{ 608{
609 uint8_t oldval, newval; 609 uint8_t oldval, newval;
610 int64_t coord, mutex; 610 uint64_t coord, mutex;
611 611
612 FOREACH_H48SIM(arg->cube, arg->cocsepdata, arg->selfsim, 612 FOREACH_H48SIM(arg->cube, arg->cocsepdata, arg->selfsim,
613 coord = coord_h48(arg->cube, arg->cocsepdata, arg->h); 613 coord = coord_h48(arg->cube, arg->cocsepdata, arg->h);
@@ -627,7 +627,7 @@ STATIC_INLINE void
627gendata_h48_mark(gendata_h48_mark_t arg[static 1]) 627gendata_h48_mark(gendata_h48_mark_t arg[static 1])
628{ 628{
629 uint8_t oldval, newval; 629 uint8_t oldval, newval;
630 int64_t coord, mutex; 630 uint64_t coord, mutex;
631 631
632 FOREACH_H48SIM(arg->cube, arg->cocsepdata, arg->selfsim, 632 FOREACH_H48SIM(arg->cube, arg->cocsepdata, arg->selfsim,
633 coord = coord_h48(arg->cube, arg->cocsepdata, arg->h); 633 coord = coord_h48(arg->cube, arg->cocsepdata, arg->h);
@@ -644,7 +644,7 @@ STATIC_INLINE bool
644gendata_h48k2_dfs_stop(cube_t cube, int8_t d, h48k2_dfs_arg_t arg[static 1]) 644gendata_h48k2_dfs_stop(cube_t cube, int8_t d, h48k2_dfs_arg_t arg[static 1])
645{ 645{
646 uint64_t val; 646 uint64_t val;
647 int64_t coord, mutex; 647 uint64_t coord, mutex;
648 int8_t oldval; 648 int8_t oldval;
649 649
650 if (arg->h == 0 || arg->h == 11) { 650 if (arg->h == 0 || arg->h == 11) {
@@ -705,19 +705,19 @@ get_h48data_constptr(const unsigned char *data)
705} 705}
706 706
707STATIC_INLINE uint8_t 707STATIC_INLINE uint8_t
708get_h48_pval(const unsigned char *table, int64_t i, uint8_t k) 708get_h48_pval(const unsigned char *table, uint64_t i, uint8_t k)
709{ 709{
710 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); 710 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k);
711} 711}
712 712
713STATIC_INLINE uint8_t 713STATIC_INLINE uint8_t
714get_h48_pval_atomic(_Atomic const unsigned char *table, int64_t i, uint8_t k) 714get_h48_pval_atomic(_Atomic const unsigned char *table, uint64_t i, uint8_t k)
715{ 715{
716 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); 716 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k);
717} 717}
718 718
719STATIC_INLINE void 719STATIC_INLINE void
720set_h48_pval(unsigned char *table, int64_t i, uint8_t k, uint8_t val) 720set_h48_pval(unsigned char *table, uint64_t i, uint8_t k, uint8_t val)
721{ 721{
722 table[H48_INDEX(i, k)] = (table[H48_INDEX(i, k)] & (~H48_MASK(i, k))) 722 table[H48_INDEX(i, k)] = (table[H48_INDEX(i, k)] & (~H48_MASK(i, k)))
723 | (val << H48_SHIFT(i, k)); 723 | (val << H48_SHIFT(i, k));
@@ -726,7 +726,7 @@ set_h48_pval(unsigned char *table, int64_t i, uint8_t k, uint8_t val)
726STATIC_INLINE void 726STATIC_INLINE void
727set_h48_pval_atomic( 727set_h48_pval_atomic(
728 _Atomic unsigned char *table, 728 _Atomic unsigned char *table,
729 int64_t i, 729 uint64_t i,
730 uint8_t k, 730 uint8_t k,
731 uint8_t val 731 uint8_t val
732) 732)

Generated with cgit - Back to sebastiano.tronto.net