diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-05 23:17:57 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-05 23:17:57 +0200 |
| commit | 8f6ac739c35c1d94adc504eb74a41b64d94a953f (patch) | |
| tree | 79af7b28613d20a6bea1ae7b5b3a6afae1180fc8 /src/solvers | |
| parent | ce2d2d1339b2e0f8f7bb4c5392acf4fbf4e00f03 (diff) | |
| download | nissy-core-8f6ac739c35c1d94adc504eb74a41b64d94a953f.tar.gz nissy-core-8f6ac739c35c1d94adc504eb74a41b64d94a953f.zip | |
Remove unnecessary _Atomics
Diffstat (limited to 'src/solvers')
| -rw-r--r-- | src/solvers/h48/gendata_cocsep.h | 5 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 48 | ||||
| -rw-r--r-- | src/solvers/h48/solve.h | 4 | ||||
| -rw-r--r-- | src/solvers/h48/stats.h | 4 |
4 files changed, 34 insertions, 27 deletions
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index fd483ce..a8142b4 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h | |||
| @@ -5,8 +5,7 @@ STATIC size_t gendata_cocsep(void *, uint64_t *, cube_t *); | |||
| 5 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); | 5 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); |
| 6 | STATIC void getdistribution_cocsep(const uint32_t *, uint64_t [static 21]); | 6 | STATIC void getdistribution_cocsep(const uint32_t *, uint64_t [static 21]); |
| 7 | 7 | ||
| 8 | STATIC_INLINE int8_t get_h48_cdata( | 8 | STATIC_INLINE int8_t get_h48_cdata(cube_t, const uint32_t *, uint32_t *); |
| 9 | cube_t, _Atomic const uint32_t *, uint32_t *); | ||
| 10 | 9 | ||
| 11 | /* | 10 | /* |
| 12 | Each element of the cocsep table is a uint32_t used as follows: | 11 | Each element of the cocsep table is a uint32_t used as follows: |
| @@ -159,7 +158,7 @@ set_visited(uint8_t *a, int64_t i) | |||
| 159 | } | 158 | } |
| 160 | 159 | ||
| 161 | STATIC_INLINE int8_t | 160 | STATIC_INLINE int8_t |
| 162 | get_h48_cdata(cube_t cube, _Atomic const uint32_t *cocsepdata, uint32_t *cdata) | 161 | get_h48_cdata(cube_t cube, const uint32_t *cocsepdata, uint32_t *cdata) |
| 163 | { | 162 | { |
| 164 | int64_t coord; | 163 | int64_t coord; |
| 165 | 164 | ||
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 *); | |||
| 31 | STATIC void getdistribution_h48(_Atomic const uint8_t *, | 31 | STATIC 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 | ||
| 34 | STATIC _Atomic const uint32_t *get_cocsepdata_constptr(const void *); | 34 | STATIC const uint32_t *get_cocsepdata_constptr(const void *); |
| 35 | STATIC _Atomic const uint8_t *get_h48data_constptr(const void *); | 35 | STATIC const uint8_t *get_h48data_constptr(const void *); |
| 36 | 36 | ||
| 37 | STATIC_INLINE uint8_t get_h48_pval(_Atomic const uint8_t *, int64_t, uint8_t); | 37 | STATIC_INLINE uint8_t get_h48_pval_atomic( |
| 38 | _Atomic const uint8_t *, int64_t, uint8_t); | ||
| 39 | STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t); | ||
| 38 | STATIC_INLINE void set_h48_pval(_Atomic uint8_t *, int64_t, uint8_t, uint8_t); | 40 | STATIC_INLINE void set_h48_pval(_Atomic uint8_t *, int64_t, uint8_t, uint8_t); |
| 39 | STATIC_INLINE uint8_t get_h48_bound( | 41 | STATIC_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 | ||
| 42 | size_t gendata_h48_derive(uint8_t, const void *, void *); | 44 | size_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 | ||
| 621 | STATIC _Atomic const uint32_t * | 623 | STATIC const uint32_t * |
| 622 | get_cocsepdata_constptr(const void *data) | 624 | get_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 | ||
| 627 | STATIC _Atomic const uint8_t * | 629 | STATIC const uint8_t * |
| 628 | get_h48data_constptr(const void *data) | 630 | get_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 | ||
| 633 | STATIC_INLINE uint8_t | 635 | STATIC_INLINE uint8_t |
| 634 | get_h48_pval(_Atomic const uint8_t *table, int64_t i, uint8_t k) | 636 | get_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 | |||
| 641 | STATIC_INLINE uint8_t | ||
| 642 | get_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 | } |
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index c6fe8b7..3948b15 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -8,8 +8,8 @@ typedef struct { | |||
| 8 | int64_t maxsolutions; | 8 | int64_t maxsolutions; |
| 9 | uint8_t h; | 9 | uint8_t h; |
| 10 | uint8_t k; | 10 | uint8_t k; |
| 11 | _Atomic const uint32_t *cocsepdata; | 11 | const uint32_t *cocsepdata; |
| 12 | _Atomic const uint8_t *h48data; | 12 | const uint8_t *h48data; |
| 13 | char **nextsol; | 13 | char **nextsol; |
| 14 | uint8_t nissbranch; | 14 | uint8_t nissbranch; |
| 15 | int8_t npremoves; | 15 | int8_t npremoves; |
diff --git a/src/solvers/h48/stats.h b/src/solvers/h48/stats.h index 5f96189..ca4b72e 100644 --- a/src/solvers/h48/stats.h +++ b/src/solvers/h48/stats.h | |||
| @@ -10,8 +10,8 @@ typedef struct { | |||
| 10 | int8_t nmoves; | 10 | int8_t nmoves; |
| 11 | int8_t depth; | 11 | int8_t depth; |
| 12 | uint8_t moves[MAXLEN]; | 12 | uint8_t moves[MAXLEN]; |
| 13 | _Atomic const uint32_t *cocsepdata; | 13 | const uint32_t *cocsepdata; |
| 14 | _Atomic const uint8_t *h48data; | 14 | const uint8_t *h48data; |
| 15 | char *s; | 15 | char *s; |
| 16 | } dfsarg_solveh48stats_t; | 16 | } dfsarg_solveh48stats_t; |
| 17 | 17 | ||
