aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nissy.c2
-rw-r--r--src/solvers/h48/gendata_cocsep.h5
-rw-r--r--src/solvers/h48/gendata_h48.h45
-rw-r--r--src/solvers/h48/solve.h4
-rw-r--r--src/solvers/h48/stats.h4
5 files changed, 30 insertions, 30 deletions
diff --git a/src/nissy.c b/src/nissy.c
index 44efb83..561ef53 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -75,7 +75,7 @@ checkdata(const void *buf, const tableinfo_t *info)
75 getdistribution_cocsep( 75 getdistribution_cocsep(
76 (uint32_t *)((char *)buf + INFOSIZE), distr); 76 (uint32_t *)((char *)buf + INFOSIZE), distr);
77 } else if (!strncmp(info->solver, "h48", 3)) { 77 } else if (!strncmp(info->solver, "h48", 3)) {
78 getdistribution_h48((uint8_t *)buf + INFOSIZE, distr, 78 getdistribution_h48((_Atomic uint8_t *)buf + INFOSIZE, distr,
79 info->h48h, info->bits); 79 info->h48h, info->bits);
80 } else { 80 } else {
81 LOG("checkdata: unknown solver %s\n", info->solver); 81 LOG("checkdata: unknown solver %s\n", info->solver);
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h
index a8142b4..fd483ce 100644
--- a/src/solvers/h48/gendata_cocsep.h
+++ b/src/solvers/h48/gendata_cocsep.h
@@ -5,7 +5,8 @@ STATIC size_t gendata_cocsep(void *, uint64_t *, cube_t *);
5STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); 5STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *);
6STATIC void getdistribution_cocsep(const uint32_t *, uint64_t [static 21]); 6STATIC void getdistribution_cocsep(const uint32_t *, uint64_t [static 21]);
7 7
8STATIC_INLINE int8_t get_h48_cdata(cube_t, const uint32_t *, uint32_t *); 8STATIC_INLINE int8_t get_h48_cdata(
9 cube_t, _Atomic const uint32_t *, uint32_t *);
9 10
10/* 11/*
11Each element of the cocsep table is a uint32_t used as follows: 12Each element of the cocsep table is a uint32_t used as follows:
@@ -158,7 +159,7 @@ set_visited(uint8_t *a, int64_t i)
158} 159}
159 160
160STATIC_INLINE int8_t 161STATIC_INLINE int8_t
161get_h48_cdata(cube_t cube, const uint32_t *cocsepdata, uint32_t *cdata) 162get_h48_cdata(cube_t cube, _Atomic const uint32_t *cocsepdata, uint32_t *cdata)
162{ 163{
163 int64_t coord; 164 int64_t coord;
164 165
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 2f55d3e..391c97b 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -28,16 +28,16 @@ STATIC size_t gendata_h48k2_realcoord(gendata_h48_arg_t *);
28STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); 28STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg);
29STATIC void * gendata_h48k2_runthread(void *); 29STATIC void * gendata_h48k2_runthread(void *);
30STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *); 30STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *);
31STATIC void getdistribution_h48(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 const uint32_t *get_cocsepdata_constptr(const void *); 34STATIC _Atomic const uint32_t *get_cocsepdata_constptr(const void *);
35STATIC const uint8_t *get_h48data_constptr(const void *); 35STATIC _Atomic const uint8_t *get_h48data_constptr(const void *);
36 36
37STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t); 37STATIC_INLINE uint8_t get_h48_pval(_Atomic const uint8_t *, int64_t, uint8_t);
38STATIC_INLINE void set_h48_pval(_Atomic uint8_t *, int64_t, uint8_t, uint8_t); 38STATIC_INLINE void set_h48_pval(_Atomic uint8_t *, int64_t, uint8_t, uint8_t);
39STATIC_INLINE uint8_t get_h48_bound( 39STATIC_INLINE uint8_t get_h48_bound(
40 cube_t, uint32_t, uint8_t, uint8_t, const uint8_t *); 40 cube_t, uint32_t, uint8_t, uint8_t, _Atomic const uint8_t *);
41 41
42size_t gendata_h48_derive(uint8_t, const void *, void *); 42size_t gendata_h48_derive(uint8_t, const void *, void *);
43 43
@@ -196,7 +196,7 @@ gendata_h48h0k4(gendata_h48_arg_t *arg)
196 pthread_join(thread[t], NULL); 196 pthread_join(thread[t], NULL);
197 197
198 for (i = 0, cc = 0; i < h48max; i++) { 198 for (i = 0, cc = 0; i < h48max; i++) {
199 val = get_h48_pval((uint8_t *)table, i, 4); 199 val = get_h48_pval(table, i, 4);
200 cc += val == d; 200 cc += val == d;
201 } 201 }
202 202
@@ -242,7 +242,7 @@ gendata_h48h0k4_runthread(void *arg)
242 * Otherwise, scan all neighbors of unvisited coordinates. 242 * Otherwise, scan all neighbors of unvisited coordinates.
243 */ 243 */
244 for (i = bfsarg->start; i < bfsarg->end; i++) { 244 for (i = bfsarg->start; i < bfsarg->end; i++) {
245 c = get_h48_pval((uint8_t *)bfsarg->table, i, 4); 245 c = get_h48_pval(bfsarg->table, i, 4);
246 246
247 if ((bfsarg->depth < breakpoint && c != bfsarg->depth - 1) || 247 if ((bfsarg->depth < breakpoint && c != bfsarg->depth - 1) ||
248 (bfsarg->depth >= breakpoint && c != 0xF)) 248 (bfsarg->depth >= breakpoint && c != 0xF))
@@ -252,7 +252,7 @@ gendata_h48h0k4_runthread(void *arg)
252 for (m = 0; m < 18; m++) { 252 for (m = 0; m < 18; m++) {
253 moved = move(cube, m); 253 moved = move(cube, m);
254 j = coord_h48(moved, bfsarg->cocsepdata, 0); 254 j = coord_h48(moved, bfsarg->cocsepdata, 0);
255 c = get_h48_pval((uint8_t *)bfsarg->table, j, 4); 255 c = get_h48_pval(bfsarg->table, j, 4);
256 if (bfsarg->depth < breakpoint) { 256 if (bfsarg->depth < breakpoint) {
257 if (c <= bfsarg->depth) 257 if (c <= bfsarg->depth)
258 continue; 258 continue;
@@ -387,7 +387,7 @@ gendata_h48k2(gendata_h48_arg_t *arg)
387 h48map_destroy(&shortcubes); 387 h48map_destroy(&shortcubes);
388 388
389 for (j = 0; j < H48_COORDMAX(arg->h); j++) { 389 for (j = 0; j < H48_COORDMAX(arg->h); j++) {
390 t = get_h48_pval((uint8_t *)table, j, 2); 390 t = get_h48_pval(table, j, 2);
391 arg->info.distribution[t]++; 391 arg->info.distribution[t]++;
392 } 392 }
393 393
@@ -522,7 +522,7 @@ gendata_h48_mark(gendata_h48_mark_t *arg)
522 522
523 FOREACH_H48SIM(arg->cube, arg->cocsepdata, arg->selfsim, 523 FOREACH_H48SIM(arg->cube, arg->cocsepdata, arg->selfsim,
524 coord = coord_h48(arg->cube, arg->cocsepdata, arg->h); 524 coord = coord_h48(arg->cube, arg->cocsepdata, arg->h);
525 oldval = get_h48_pval((uint8_t *)arg->table, coord, arg->k); 525 oldval = get_h48_pval(arg->table, coord, arg->k);
526 newval = (uint8_t)MAX(arg->depth, 0); 526 newval = (uint8_t)MAX(arg->depth, 0);
527 if (newval < oldval) { 527 if (newval < oldval) {
528 mutex = H48_INDEX(coord, arg->k) % CHUNKS; 528 mutex = H48_INDEX(coord, arg->k) % CHUNKS;
@@ -546,7 +546,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); 546 coord = coord_h48(cube, arg->cocsepdata, arg->h);
547 mutex = H48_INDEX(coord, arg->k) % CHUNKS; 547 mutex = H48_INDEX(coord, arg->k) % CHUNKS;
548 pthread_mutex_lock(arg->table_mutex[mutex]); 548 pthread_mutex_lock(arg->table_mutex[mutex]);
549 oldval = get_h48_pval((uint8_t *)arg->table, coord, arg->k); 549 oldval = get_h48_pval(arg->table, coord, arg->k);
550 pthread_mutex_unlock(arg->table_mutex[mutex]); 550 pthread_mutex_unlock(arg->table_mutex[mutex]);
551 return oldval <= depth; 551 return oldval <= depth;
552 } else { 552 } else {
@@ -601,7 +601,7 @@ makeinfo_h48k2(gendata_h48_arg_t *arg)
601 601
602STATIC void 602STATIC void
603getdistribution_h48( 603getdistribution_h48(
604 const uint8_t *table, 604 _Atomic const uint8_t *table,
605 uint64_t distr[static INFO_DISTRIBUTION_LEN], 605 uint64_t distr[static INFO_DISTRIBUTION_LEN],
606 uint8_t h, 606 uint8_t h,
607 uint8_t k 607 uint8_t k
@@ -618,20 +618,20 @@ getdistribution_h48(
618 } 618 }
619} 619}
620 620
621STATIC const uint32_t * 621STATIC _Atomic const uint32_t *
622get_cocsepdata_constptr(const void *data) 622get_cocsepdata_constptr(const void *data)
623{ 623{
624 return (uint32_t *)((char *)data + INFOSIZE); 624 return (_Atomic uint32_t *)((char *)data + INFOSIZE);
625} 625}
626 626
627STATIC const uint8_t * 627STATIC _Atomic const uint8_t *
628get_h48data_constptr(const void *data) 628get_h48data_constptr(const void *data)
629{ 629{
630 return (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE; 630 return (_Atomic uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE;
631} 631}
632 632
633STATIC_INLINE uint8_t 633STATIC_INLINE uint8_t
634get_h48_pval(const uint8_t *table, int64_t i, uint8_t k) 634get_h48_pval(_Atomic const uint8_t *table, int64_t i, uint8_t k)
635{ 635{
636 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); 636 return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k);
637} 637}
@@ -649,7 +649,7 @@ get_h48_bound(
649 uint32_t cdata, 649 uint32_t cdata,
650 uint8_t h, 650 uint8_t h,
651 uint8_t k, 651 uint8_t k,
652 const uint8_t *table 652 _Atomic const uint8_t *table
653) { 653) {
654 int64_t coord; 654 int64_t coord;
655 655
@@ -662,7 +662,7 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
662{ 662{
663 size_t cocsepsize, h48size; 663 size_t cocsepsize, h48size;
664 uint8_t val_full, val_derive; 664 uint8_t val_full, val_derive;
665 const uint8_t *h48full; 665 _Atomic const uint8_t *h48full;
666 _Atomic uint8_t *h48derive; 666 _Atomic uint8_t *h48derive;
667 int64_t i, j, h48max; 667 int64_t i, j, h48max;
668 gendata_h48_arg_t arg; 668 gendata_h48_arg_t arg;
@@ -703,7 +703,7 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
703 goto gendata_h48_derive_error; 703 goto gendata_h48_derive_error;
704 } 704 }
705 705
706 h48full = (const uint8_t *)fulltable + cocsepsize + INFOSIZE; 706 h48full = (_Atomic const uint8_t *)fulltable + cocsepsize + INFOSIZE;
707 h48derive = (_Atomic uint8_t *)arg.h48buf + INFOSIZE; 707 h48derive = (_Atomic uint8_t *)arg.h48buf + INFOSIZE;
708 memset(h48derive, 0xFF, H48_TABLESIZE(h, arg.k)); 708 memset(h48derive, 0xFF, H48_TABLESIZE(h, arg.k));
709 memset(arg.info.distribution, 0, 709 memset(arg.info.distribution, 0,
@@ -715,13 +715,12 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
715 LOG("Processing %" PRId64 "th coordinate\n", i); 715 LOG("Processing %" PRId64 "th coordinate\n", i);
716 j = i >> (int64_t)(fulltableinfo.h48h - h); 716 j = i >> (int64_t)(fulltableinfo.h48h - h);
717 val_full = get_h48_pval(h48full, i, arg.k); 717 val_full = get_h48_pval(h48full, i, arg.k);
718 val_derive = get_h48_pval((uint8_t *)h48derive, j, arg.k); 718 val_derive = get_h48_pval(h48derive, j, arg.k);
719 set_h48_pval( 719 set_h48_pval(
720 h48derive, j, arg.k, MIN(val_full, val_derive)); 720 h48derive, j, arg.k, MIN(val_full, val_derive));
721 } 721 }
722 722
723 getdistribution_h48( 723 getdistribution_h48(h48derive, arg.info.distribution, h, arg.k);
724 (uint8_t *)h48derive, arg.info.distribution, h, arg.k);
725 724
726 if (!writetableinfo(&arg.info, arg.h48buf)) { 725 if (!writetableinfo(&arg.info, arg.h48buf)) {
727 LOG("gendata_h48_derive: could not write info for table\n"); 726 LOG("gendata_h48_derive: could not write info for table\n");
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h
index 3948b15..c6fe8b7 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 const uint32_t *cocsepdata; 11 _Atomic const uint32_t *cocsepdata;
12 const uint8_t *h48data; 12 _Atomic 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 ca4b72e..5f96189 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 const uint32_t *cocsepdata; 13 _Atomic const uint32_t *cocsepdata;
14 const uint8_t *h48data; 14 _Atomic const uint8_t *h48data;
15 char *s; 15 char *s;
16} dfsarg_solveh48stats_t; 16} dfsarg_solveh48stats_t;
17 17

Generated with cgit - Back to sebastiano.tronto.net