aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/gendata_h48.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-05 23:17:57 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-05 23:17:57 +0200
commit8f6ac739c35c1d94adc504eb74a41b64d94a953f (patch)
tree79af7b28613d20a6bea1ae7b5b3a6afae1180fc8 /src/solvers/h48/gendata_h48.h
parentce2d2d1339b2e0f8f7bb4c5392acf4fbf4e00f03 (diff)
downloadnissy-core-8f6ac739c35c1d94adc504eb74a41b64d94a953f.tar.gz
nissy-core-8f6ac739c35c1d94adc504eb74a41b64d94a953f.zip
Remove unnecessary _Atomics
Diffstat (limited to 'src/solvers/h48/gendata_h48.h')
-rw-r--r--src/solvers/h48/gendata_h48.h48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 391c97b..4124d56 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -31,13 +31,15 @@ STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *);
31STATIC void getdistribution_h48(_Atomic const uint8_t *, 31STATIC void getdistribution_h48(_Atomic const uint8_t *,
32 uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t, uint8_t); 32 uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t, uint8_t);
33 33
34STATIC _Atomic const uint32_t *get_cocsepdata_constptr(const void *); 34STATIC const uint32_t *get_cocsepdata_constptr(const void *);
35STATIC _Atomic const uint8_t *get_h48data_constptr(const void *); 35STATIC const uint8_t *get_h48data_constptr(const void *);
36 36
37STATIC_INLINE uint8_t get_h48_pval(_Atomic const uint8_t *, int64_t, uint8_t); 37STATIC_INLINE uint8_t get_h48_pval_atomic(
38 _Atomic const uint8_t *, int64_t, uint8_t);
39STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t);
38STATIC_INLINE void set_h48_pval(_Atomic uint8_t *, int64_t, uint8_t, uint8_t); 40STATIC_INLINE void set_h48_pval(_Atomic uint8_t *, int64_t, uint8_t, uint8_t);
39STATIC_INLINE uint8_t get_h48_bound( 41STATIC_INLINE uint8_t get_h48_bound(
40 cube_t, uint32_t, uint8_t, uint8_t, _Atomic const uint8_t *); 42 cube_t, uint32_t, uint8_t, uint8_t, const uint8_t *);
41 43
42size_t gendata_h48_derive(uint8_t, const void *, void *); 44size_t gendata_h48_derive(uint8_t, const void *, void *);
43 45
@@ -196,7 +198,7 @@ gendata_h48h0k4(gendata_h48_arg_t *arg)
196 pthread_join(thread[t], NULL); 198 pthread_join(thread[t], NULL);
197 199
198 for (i = 0, cc = 0; i < h48max; i++) { 200 for (i = 0, cc = 0; i < h48max; i++) {
199 val = get_h48_pval(table, i, 4); 201 val = get_h48_pval_atomic(table, i, 4);
200 cc += val == d; 202 cc += val == d;
201 } 203 }
202 204
@@ -242,7 +244,7 @@ gendata_h48h0k4_runthread(void *arg)
242 * Otherwise, scan all neighbors of unvisited coordinates. 244 * Otherwise, scan all neighbors of unvisited coordinates.
243 */ 245 */
244 for (i = bfsarg->start; i < bfsarg->end; i++) { 246 for (i = bfsarg->start; i < bfsarg->end; i++) {
245 c = get_h48_pval(bfsarg->table, i, 4); 247 c = get_h48_pval_atomic(bfsarg->table, i, 4);
246 248
247 if ((bfsarg->depth < breakpoint && c != bfsarg->depth - 1) || 249 if ((bfsarg->depth < breakpoint && c != bfsarg->depth - 1) ||
248 (bfsarg->depth >= breakpoint && c != 0xF)) 250 (bfsarg->depth >= breakpoint && c != 0xF))
@@ -252,7 +254,7 @@ gendata_h48h0k4_runthread(void *arg)
252 for (m = 0; m < 18; m++) { 254 for (m = 0; m < 18; m++) {
253 moved = move(cube, m); 255 moved = move(cube, m);
254 j = coord_h48(moved, bfsarg->cocsepdata, 0); 256 j = coord_h48(moved, bfsarg->cocsepdata, 0);
255 c = get_h48_pval(bfsarg->table, j, 4); 257 c = get_h48_pval_atomic(bfsarg->table, j, 4);
256 if (bfsarg->depth < breakpoint) { 258 if (bfsarg->depth < breakpoint) {
257 if (c <= bfsarg->depth) 259 if (c <= bfsarg->depth)
258 continue; 260 continue;
@@ -387,7 +389,7 @@ gendata_h48k2(gendata_h48_arg_t *arg)
387 h48map_destroy(&shortcubes); 389 h48map_destroy(&shortcubes);
388 390
389 for (j = 0; j < H48_COORDMAX(arg->h); j++) { 391 for (j = 0; j < H48_COORDMAX(arg->h); j++) {
390 t = get_h48_pval(table, j, 2); 392 t = get_h48_pval_atomic(table, j, 2);
391 arg->info.distribution[t]++; 393 arg->info.distribution[t]++;
392 } 394 }
393 395
@@ -522,7 +524,7 @@ gendata_h48_mark(gendata_h48_mark_t *arg)
522 524
523 FOREACH_H48SIM(arg->cube, arg->cocsepdata, arg->selfsim, 525 FOREACH_H48SIM(arg->cube, arg->cocsepdata, arg->selfsim,
524 coord = coord_h48(arg->cube, arg->cocsepdata, arg->h); 526 coord = coord_h48(arg->cube, arg->cocsepdata, arg->h);
525 oldval = get_h48_pval(arg->table, coord, arg->k); 527 oldval = get_h48_pval_atomic(arg->table, coord, arg->k);
526 newval = (uint8_t)MAX(arg->depth, 0); 528 newval = (uint8_t)MAX(arg->depth, 0);
527 if (newval < oldval) { 529 if (newval < oldval) {
528 mutex = H48_INDEX(coord, arg->k) % CHUNKS; 530 mutex = H48_INDEX(coord, arg->k) % CHUNKS;
@@ -546,7 +548,7 @@ gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg)
546 coord = coord_h48(cube, arg->cocsepdata, arg->h); 548 coord = coord_h48(cube, arg->cocsepdata, arg->h);
547 mutex = H48_INDEX(coord, arg->k) % CHUNKS; 549 mutex = H48_INDEX(coord, arg->k) % CHUNKS;
548 pthread_mutex_lock(arg->table_mutex[mutex]); 550 pthread_mutex_lock(arg->table_mutex[mutex]);
549 oldval = get_h48_pval(arg->table, coord, arg->k); 551 oldval = get_h48_pval_atomic(arg->table, coord, arg->k);
550 pthread_mutex_unlock(arg->table_mutex[mutex]); 552 pthread_mutex_unlock(arg->table_mutex[mutex]);
551 return oldval <= depth; 553 return oldval <= depth;
552 } else { 554 } else {
@@ -613,25 +615,31 @@ getdistribution_h48(
613 615
614 h48max = H48_COORDMAX(h); 616 h48max = H48_COORDMAX(h);
615 for (i = 0; i < h48max; i++) { 617 for (i = 0; i < h48max; i++) {
616 val = get_h48_pval(table, i, k); 618 val = get_h48_pval_atomic(table, i, k);
617 distr[val]++; 619 distr[val]++;
618 } 620 }
619} 621}
620 622
621STATIC _Atomic const uint32_t * 623STATIC const uint32_t *
622get_cocsepdata_constptr(const void *data) 624get_cocsepdata_constptr(const void *data)
623{ 625{
624 return (_Atomic uint32_t *)((char *)data + INFOSIZE); 626 return (uint32_t *)((char *)data + INFOSIZE);
625} 627}
626 628
627STATIC _Atomic const uint8_t * 629STATIC const uint8_t *
628get_h48data_constptr(const void *data) 630get_h48data_constptr(const void *data)
629{ 631{
630 return (_Atomic uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE; 632 return (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE;
631} 633}
632 634
633STATIC_INLINE uint8_t 635STATIC_INLINE uint8_t
634get_h48_pval(_Atomic const uint8_t *table, int64_t i, uint8_t k) 636get_h48_pval_atomic(_Atomic const uint8_t *table, int64_t i, uint8_t k)
637{
638 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k);
639}
640
641STATIC_INLINE uint8_t
642get_h48_pval(const uint8_t *table, int64_t i, uint8_t k)
635{ 643{
636 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); 644 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k);
637} 645}
@@ -649,7 +657,7 @@ get_h48_bound(
649 uint32_t cdata, 657 uint32_t cdata,
650 uint8_t h, 658 uint8_t h,
651 uint8_t k, 659 uint8_t k,
652 _Atomic const uint8_t *table 660 const uint8_t *table
653) { 661) {
654 int64_t coord; 662 int64_t coord;
655 663
@@ -662,7 +670,7 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
662{ 670{
663 size_t cocsepsize, h48size; 671 size_t cocsepsize, h48size;
664 uint8_t val_full, val_derive; 672 uint8_t val_full, val_derive;
665 _Atomic const uint8_t *h48full; 673 const uint8_t *h48full;
666 _Atomic uint8_t *h48derive; 674 _Atomic uint8_t *h48derive;
667 int64_t i, j, h48max; 675 int64_t i, j, h48max;
668 gendata_h48_arg_t arg; 676 gendata_h48_arg_t arg;
@@ -703,7 +711,7 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
703 goto gendata_h48_derive_error; 711 goto gendata_h48_derive_error;
704 } 712 }
705 713
706 h48full = (_Atomic const uint8_t *)fulltable + cocsepsize + INFOSIZE; 714 h48full = (const uint8_t *)fulltable + cocsepsize + INFOSIZE;
707 h48derive = (_Atomic uint8_t *)arg.h48buf + INFOSIZE; 715 h48derive = (_Atomic uint8_t *)arg.h48buf + INFOSIZE;
708 memset(h48derive, 0xFF, H48_TABLESIZE(h, arg.k)); 716 memset(h48derive, 0xFF, H48_TABLESIZE(h, arg.k));
709 memset(arg.info.distribution, 0, 717 memset(arg.info.distribution, 0,
@@ -715,7 +723,7 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
715 LOG("Processing %" PRId64 "th coordinate\n", i); 723 LOG("Processing %" PRId64 "th coordinate\n", i);
716 j = i >> (int64_t)(fulltableinfo.h48h - h); 724 j = i >> (int64_t)(fulltableinfo.h48h - h);
717 val_full = get_h48_pval(h48full, i, arg.k); 725 val_full = get_h48_pval(h48full, i, arg.k);
718 val_derive = get_h48_pval(h48derive, j, arg.k); 726 val_derive = get_h48_pval_atomic(h48derive, j, arg.k);
719 set_h48_pval( 727 set_h48_pval(
720 h48derive, j, arg.k, MIN(val_full, val_derive)); 728 h48derive, j, arg.k, MIN(val_full, val_derive));
721 } 729 }

Generated with cgit - Back to sebastiano.tronto.net