diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-29 12:12:43 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-29 12:12:43 +0200 |
| commit | ea0387796a349c91032fbcb10f50c6ad8607b0f6 (patch) | |
| tree | aed484690d24c0c28c7695d4b5389f2e3c341b96 /src/solvers/h48 | |
| parent | 52c21640508c3fc668107778ae027ff4428ebd89 (diff) | |
| download | nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.tar.gz nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.zip | |
All coordinates unsigned
Diffstat (limited to 'src/solvers/h48')
| -rw-r--r-- | src/solvers/h48/coordinate.h | 28 | ||||
| -rw-r--r-- | src/solvers/h48/coordinate_types_macros.h | 2 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_cocsep.h | 12 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_eoesep.h | 42 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 42 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_types_macros.h | 10 | ||||
| -rw-r--r-- | src/solvers/h48/map.h | 2 | ||||
| -rw-r--r-- | src/solvers/h48/solve.h | 10 |
8 files changed, 74 insertions, 74 deletions
diff --git a/src/solvers/h48/coordinate.h b/src/solvers/h48/coordinate.h index 9437fa7..a7f0087 100644 --- a/src/solvers/h48/coordinate.h +++ b/src/solvers/h48/coordinate.h | |||
| @@ -1,17 +1,17 @@ | |||
| 1 | STATIC_INLINE int64_t coord_h48( | 1 | STATIC_INLINE uint64_t coord_h48( |
| 2 | cube_t, const uint32_t [static COCSEP_TABLESIZE], uint8_t); | 2 | cube_t, const uint32_t [static COCSEP_TABLESIZE], uint8_t); |
| 3 | STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); | 3 | STATIC_INLINE uint64_t coord_h48_edges(cube_t, uint64_t, uint8_t, uint8_t); |
| 4 | STATIC_INLINE cube_t invcoord_h48( | 4 | STATIC_INLINE cube_t invcoord_h48( |
| 5 | int64_t, const cube_t [static COCSEP_CLASSES], uint8_t); | 5 | uint64_t, const cube_t [static COCSEP_CLASSES], uint8_t); |
| 6 | 6 | ||
| 7 | STATIC_INLINE int64_t | 7 | STATIC_INLINE uint64_t |
| 8 | coord_h48( | 8 | coord_h48( |
| 9 | cube_t c, | 9 | cube_t c, |
| 10 | const uint32_t cocsepdata[static COCSEP_TABLESIZE], | 10 | const uint32_t cocsepdata[static COCSEP_TABLESIZE], |
| 11 | uint8_t h | 11 | uint8_t h |
| 12 | ) | 12 | ) |
| 13 | { | 13 | { |
| 14 | int64_t cocsep, coclass; | 14 | uint64_t cocsep, coclass; |
| 15 | uint32_t data; | 15 | uint32_t data; |
| 16 | uint8_t ttrep; | 16 | uint8_t ttrep; |
| 17 | 17 | ||
| @@ -19,24 +19,24 @@ coord_h48( | |||
| 19 | 19 | ||
| 20 | cocsep = coord_cocsep(c); | 20 | cocsep = coord_cocsep(c); |
| 21 | data = cocsepdata[cocsep]; | 21 | data = cocsepdata[cocsep]; |
| 22 | coclass = (int64_t)COCLASS(data); | 22 | coclass = COCLASS(data); |
| 23 | ttrep = (int64_t)TTREP(data); | 23 | ttrep = TTREP(data); |
| 24 | 24 | ||
| 25 | return coord_h48_edges(c, coclass, ttrep, h); | 25 | return coord_h48_edges(c, coclass, ttrep, h); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | STATIC_INLINE int64_t | 28 | STATIC_INLINE uint64_t |
| 29 | coord_h48_edges(cube_t c, int64_t coclass, uint8_t ttrep, uint8_t h) | 29 | coord_h48_edges(cube_t c, uint64_t coclass, uint8_t ttrep, uint8_t h) |
| 30 | { | 30 | { |
| 31 | cube_t d; | 31 | cube_t d; |
| 32 | int64_t esep, eo, edges; | 32 | uint64_t esep, eo, edges; |
| 33 | 33 | ||
| 34 | d = transform_edges(c, ttrep); | 34 | d = transform_edges(c, ttrep); |
| 35 | esep = coord_esep(d); | 35 | esep = coord_esep(d); |
| 36 | eo = coord_eo(d); | 36 | eo = coord_eo(d); |
| 37 | edges = (esep << 11) + eo; | 37 | edges = (esep << 11) + eo; |
| 38 | 38 | ||
| 39 | return (coclass * H48_ESIZE(11) + edges) >> (11 - (int64_t)h); | 39 | return (coclass * H48_ESIZE(11) + edges) >> (11 - (uint64_t)h); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | /* | 42 | /* |
| @@ -46,17 +46,17 @@ returned cube is a transformed cube of one that gives the correct value. | |||
| 46 | */ | 46 | */ |
| 47 | STATIC_INLINE cube_t | 47 | STATIC_INLINE cube_t |
| 48 | invcoord_h48( | 48 | invcoord_h48( |
| 49 | int64_t i, | 49 | uint64_t i, |
| 50 | const cube_t crep[static COCSEP_CLASSES], | 50 | const cube_t crep[static COCSEP_CLASSES], |
| 51 | uint8_t h | 51 | uint8_t h |
| 52 | ) | 52 | ) |
| 53 | { | 53 | { |
| 54 | cube_t ret; | 54 | cube_t ret; |
| 55 | int64_t hh, coclass, ee, esep, eo; | 55 | uint64_t hh, coclass, ee, esep, eo; |
| 56 | 56 | ||
| 57 | DBG_ASSERT(h <= 11, "invcoord_h48: h must be between 0 and 11\n"); | 57 | DBG_ASSERT(h <= 11, "invcoord_h48: h must be between 0 and 11\n"); |
| 58 | 58 | ||
| 59 | hh = (int64_t)h; | 59 | hh = (uint64_t)h; |
| 60 | coclass = i / H48_ESIZE(h); | 60 | coclass = i / H48_ESIZE(h); |
| 61 | ee = i % H48_ESIZE(h); | 61 | ee = i % H48_ESIZE(h); |
| 62 | esep = ee >> hh; | 62 | esep = ee >> hh; |
diff --git a/src/solvers/h48/coordinate_types_macros.h b/src/solvers/h48/coordinate_types_macros.h index 04462d6..cf24e47 100644 --- a/src/solvers/h48/coordinate_types_macros.h +++ b/src/solvers/h48/coordinate_types_macros.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #define H48_ESIZE(h) ((COMB_12_4 * COMB_8_4) << (int64_t)(h)) | 1 | #define H48_ESIZE(h) ((COMB_12_4 * COMB_8_4) << (uint64_t)(h)) |
| 2 | 2 | ||
| 3 | #define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) | 3 | #define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) |
| 4 | #define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16)) | 4 | #define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16)) |
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index 5d14db7..db7ac95 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h | |||
| @@ -2,9 +2,9 @@ STATIC size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); | |||
| 2 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [static 1]); | 2 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [static 1]); |
| 3 | 3 | ||
| 4 | STATIC_INLINE bool gendata_cocsep_get_visited( | 4 | STATIC_INLINE bool gendata_cocsep_get_visited( |
| 5 | const uint8_t [static COCSEP_VISITEDSIZE], int64_t); | 5 | const uint8_t [static COCSEP_VISITEDSIZE], uint64_t); |
| 6 | STATIC_INLINE void gendata_cocsep_set_visited( | 6 | STATIC_INLINE void gendata_cocsep_set_visited( |
| 7 | uint8_t [static COCSEP_VISITEDSIZE], int64_t); | 7 | uint8_t [static COCSEP_VISITEDSIZE], uint64_t); |
| 8 | 8 | ||
| 9 | STATIC_INLINE int8_t get_h48_cdata( | 9 | STATIC_INLINE int8_t get_h48_cdata( |
| 10 | cube_t, const uint32_t [static COCSEP_TABLESIZE], uint32_t *); | 10 | cube_t, const uint32_t [static COCSEP_TABLESIZE], uint32_t *); |
| @@ -84,7 +84,7 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1]) | |||
| 84 | uint8_t m; | 84 | uint8_t m; |
| 85 | uint32_t cc, class, ttrep, depth, olddepth, tinv; | 85 | uint32_t cc, class, ttrep, depth, olddepth, tinv; |
| 86 | uint64_t t; | 86 | uint64_t t; |
| 87 | int64_t i, j; | 87 | uint64_t i, j; |
| 88 | cube_t d; | 88 | cube_t d; |
| 89 | cocsep_dfs_arg_t nextarg; | 89 | cocsep_dfs_arg_t nextarg; |
| 90 | 90 | ||
| @@ -136,7 +136,7 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1]) | |||
| 136 | STATIC_INLINE bool | 136 | STATIC_INLINE bool |
| 137 | gendata_cocsep_get_visited( | 137 | gendata_cocsep_get_visited( |
| 138 | const uint8_t a[static COCSEP_VISITEDSIZE], | 138 | const uint8_t a[static COCSEP_VISITEDSIZE], |
| 139 | int64_t i | 139 | uint64_t i |
| 140 | ) | 140 | ) |
| 141 | { | 141 | { |
| 142 | return a[VISITED_IND(i)] & VISITED_MASK(i); | 142 | return a[VISITED_IND(i)] & VISITED_MASK(i); |
| @@ -145,7 +145,7 @@ gendata_cocsep_get_visited( | |||
| 145 | STATIC_INLINE void | 145 | STATIC_INLINE void |
| 146 | gendata_cocsep_set_visited( | 146 | gendata_cocsep_set_visited( |
| 147 | uint8_t a[static COCSEP_VISITEDSIZE], | 147 | uint8_t a[static COCSEP_VISITEDSIZE], |
| 148 | int64_t i | 148 | uint64_t i |
| 149 | ) | 149 | ) |
| 150 | { | 150 | { |
| 151 | a[VISITED_IND(i)] |= VISITED_MASK(i); | 151 | a[VISITED_IND(i)] |= VISITED_MASK(i); |
| @@ -158,7 +158,7 @@ get_h48_cdata( | |||
| 158 | uint32_t *cdata | 158 | uint32_t *cdata |
| 159 | ) | 159 | ) |
| 160 | { | 160 | { |
| 161 | int64_t coord; | 161 | uint64_t coord; |
| 162 | 162 | ||
| 163 | coord = coord_cocsep(cube); | 163 | coord = coord_cocsep(cube); |
| 164 | *cdata = cocsepdata[coord]; | 164 | *cdata = cocsepdata[coord]; |
diff --git a/src/solvers/h48/gendata_eoesep.h b/src/solvers/h48/gendata_eoesep.h index 52e2b8b..e9a2794 100644 --- a/src/solvers/h48/gendata_eoesep.h +++ b/src/solvers/h48/gendata_eoesep.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | STATIC int64_t coord_eoesep_sym(cube_t, const uint32_t [static ESEP_MAX]); | 1 | STATIC uint64_t coord_eoesep_sym(cube_t, const uint32_t [static ESEP_MAX]); |
| 2 | STATIC size_t gendata_esep_classes( | 2 | STATIC size_t gendata_esep_classes( |
| 3 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); | 3 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); |
| 4 | STATIC size_t gendata_eoesep(unsigned char *, uint8_t); | 4 | STATIC size_t gendata_eoesep(unsigned char *, uint8_t); |
| @@ -8,22 +8,22 @@ STATIC uint32_t gendata_eoesep_fromnew(uint8_t, uint8_t [static EOESEP_BUF], | |||
| 8 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); | 8 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); |
| 9 | STATIC uint32_t gendata_eoesep_fromdone(uint8_t, uint8_t [static EOESEP_BUF], | 9 | STATIC uint32_t gendata_eoesep_fromdone(uint8_t, uint8_t [static EOESEP_BUF], |
| 10 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); | 10 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); |
| 11 | STATIC uint32_t gendata_eoesep_marksim(int64_t, uint8_t, | 11 | STATIC uint32_t gendata_eoesep_marksim(uint64_t, uint8_t, |
| 12 | uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); | 12 | uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); |
| 13 | STATIC bool gendata_eoesep_next(cube_t, uint8_t, | 13 | STATIC bool gendata_eoesep_next(cube_t, uint8_t, |
| 14 | uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); | 14 | uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); |
| 15 | STATIC uint8_t get_eoesep_pval( | 15 | STATIC uint8_t get_eoesep_pval( |
| 16 | const uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], int64_t); | 16 | const uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], uint64_t); |
| 17 | STATIC uint8_t get_eoesep_pval_cube(const unsigned char *, cube_t); | 17 | STATIC uint8_t get_eoesep_pval_cube(const unsigned char *, cube_t); |
| 18 | STATIC void set_eoesep_pval( | 18 | STATIC void set_eoesep_pval( |
| 19 | uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], int64_t, uint8_t); | 19 | uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], uint64_t, uint8_t); |
| 20 | 20 | ||
| 21 | STATIC int64_t | 21 | STATIC uint64_t |
| 22 | coord_eoesep_sym(cube_t c, const uint32_t esep_classes[static ESEP_MAX]) | 22 | coord_eoesep_sym(cube_t c, const uint32_t esep_classes[static ESEP_MAX]) |
| 23 | { | 23 | { |
| 24 | uint8_t ttrep; | 24 | uint8_t ttrep; |
| 25 | uint32_t edata, class; | 25 | uint32_t edata, class; |
| 26 | int64_t esep, eo; | 26 | uint64_t esep, eo; |
| 27 | 27 | ||
| 28 | esep = coord_esep(c); | 28 | esep = coord_esep(c); |
| 29 | edata = esep_classes[esep]; | 29 | edata = esep_classes[esep]; |
| @@ -43,7 +43,7 @@ gendata_esep_classes( | |||
| 43 | bool visited[ESEP_MAX]; | 43 | bool visited[ESEP_MAX]; |
| 44 | uint8_t t; | 44 | uint8_t t; |
| 45 | uint32_t class, cl, ti; | 45 | uint32_t class, cl, ti; |
| 46 | int64_t i, j; | 46 | uint64_t i, j; |
| 47 | cube_t c; | 47 | cube_t c; |
| 48 | 48 | ||
| 49 | memset(visited, 0, ESEP_MAX * sizeof(bool)); | 49 | memset(visited, 0, ESEP_MAX * sizeof(bool)); |
| @@ -73,7 +73,7 @@ gendata_eoesep(unsigned char *buf, uint8_t maxdepth) | |||
| 73 | unsigned char *buf8; | 73 | unsigned char *buf8; |
| 74 | uint16_t rep[ESEP_CLASSES]; | 74 | uint16_t rep[ESEP_CLASSES]; |
| 75 | uint32_t *esep_classes, done, level; | 75 | uint32_t *esep_classes, done, level; |
| 76 | int64_t coord; | 76 | uint64_t coord; |
| 77 | tableinfo_t info; | 77 | tableinfo_t info; |
| 78 | 78 | ||
| 79 | if (buf == NULL) | 79 | if (buf == NULL) |
| @@ -140,18 +140,18 @@ gendata_eoesep_fromdone( | |||
| 140 | ) | 140 | ) |
| 141 | { | 141 | { |
| 142 | uint8_t pval; | 142 | uint8_t pval; |
| 143 | int64_t i, esep, eo, coord, done; | 143 | uint64_t i, esep, eo, coord, done; |
| 144 | 144 | ||
| 145 | done = 0; | 145 | done = 0; |
| 146 | for (i = 0; i < (int64_t)ESEP_CLASSES; i++) { | 146 | for (i = 0; i < ESEP_CLASSES; i++) { |
| 147 | esep = rep[i]; | 147 | esep = rep[i]; |
| 148 | for (eo = 0; eo < POW_2_11; eo++) { | 148 | for (eo = 0; eo < POW_2_11; eo++) { |
| 149 | coord = (i << INT64_C(11)) + eo; | 149 | coord = (i << UINT64_C(11)) + eo; |
| 150 | pval = get_eoesep_pval(buf8, coord); | 150 | pval = get_eoesep_pval(buf8, coord); |
| 151 | if (pval != d-1) | 151 | if (pval != d-1) |
| 152 | continue; | 152 | continue; |
| 153 | 153 | ||
| 154 | coord = (esep << INT64_C(11)) + eo; | 154 | coord = (esep << UINT64_C(11)) + eo; |
| 155 | done += gendata_eoesep_marksim( | 155 | done += gendata_eoesep_marksim( |
| 156 | coord, d, buf8, esep_classes); | 156 | coord, d, buf8, esep_classes); |
| 157 | } | 157 | } |
| @@ -169,19 +169,19 @@ gendata_eoesep_fromnew( | |||
| 169 | ) | 169 | ) |
| 170 | { | 170 | { |
| 171 | uint8_t pval; | 171 | uint8_t pval; |
| 172 | int64_t i, esep, eo, coord, done; | 172 | uint64_t i, esep, eo, coord, done; |
| 173 | cube_t c; | 173 | cube_t c; |
| 174 | 174 | ||
| 175 | done = 0; | 175 | done = 0; |
| 176 | for (i = 0; i < (int64_t)ESEP_CLASSES; i++) { | 176 | for (i = 0; i < ESEP_CLASSES; i++) { |
| 177 | esep = rep[i]; | 177 | esep = rep[i]; |
| 178 | for (eo = 0; eo < POW_2_11; eo++) { | 178 | for (eo = 0; eo < POW_2_11; eo++) { |
| 179 | coord = (i << INT64_C(11)) + eo; | 179 | coord = (i << UINT64_C(11)) + eo; |
| 180 | pval = get_eoesep_pval(buf8, coord); | 180 | pval = get_eoesep_pval(buf8, coord); |
| 181 | if (pval != 15) | 181 | if (pval != 15) |
| 182 | continue; | 182 | continue; |
| 183 | 183 | ||
| 184 | c = invcoord_eoesep((esep << INT64_C(11)) + eo); | 184 | c = invcoord_eoesep((esep << UINT64_C(11)) + eo); |
| 185 | if (gendata_eoesep_next(c, d, buf8, esep_classes)) { | 185 | if (gendata_eoesep_next(c, d, buf8, esep_classes)) { |
| 186 | set_eoesep_pval(buf8, coord, d); | 186 | set_eoesep_pval(buf8, coord, d); |
| 187 | done++; | 187 | done++; |
| @@ -194,7 +194,7 @@ gendata_eoesep_fromnew( | |||
| 194 | 194 | ||
| 195 | STATIC uint32_t | 195 | STATIC uint32_t |
| 196 | gendata_eoesep_marksim( | 196 | gendata_eoesep_marksim( |
| 197 | int64_t i, | 197 | uint64_t i, |
| 198 | uint8_t d, | 198 | uint8_t d, |
| 199 | uint8_t buf8[static EOESEP_BUF], | 199 | uint8_t buf8[static EOESEP_BUF], |
| 200 | uint32_t esep_classes[static ESEP_MAX] | 200 | uint32_t esep_classes[static ESEP_MAX] |
| @@ -232,7 +232,7 @@ gendata_eoesep_next( | |||
| 232 | ) | 232 | ) |
| 233 | { | 233 | { |
| 234 | uint8_t m, t, pval; | 234 | uint8_t m, t, pval; |
| 235 | int64_t coord; | 235 | uint64_t coord; |
| 236 | cube_t moved, transformed; | 236 | cube_t moved, transformed; |
| 237 | 237 | ||
| 238 | for (t = 0; t < NTRANS; t++) { | 238 | for (t = 0; t < NTRANS; t++) { |
| @@ -252,7 +252,7 @@ gendata_eoesep_next( | |||
| 252 | STATIC uint8_t | 252 | STATIC uint8_t |
| 253 | get_eoesep_pval( | 253 | get_eoesep_pval( |
| 254 | const uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], | 254 | const uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], |
| 255 | int64_t i | 255 | uint64_t i |
| 256 | ) | 256 | ) |
| 257 | { | 257 | { |
| 258 | return (table[EOESEP_INDEX(i)] & EOESEP_MASK(i)) >> EOESEP_SHIFT(i); | 258 | return (table[EOESEP_INDEX(i)] & EOESEP_MASK(i)) >> EOESEP_SHIFT(i); |
| @@ -261,7 +261,7 @@ get_eoesep_pval( | |||
| 261 | STATIC uint8_t | 261 | STATIC uint8_t |
| 262 | get_eoesep_pval_cube(const unsigned char *data, cube_t c) | 262 | get_eoesep_pval_cube(const unsigned char *data, cube_t c) |
| 263 | { | 263 | { |
| 264 | int64_t coord; | 264 | uint64_t coord; |
| 265 | 265 | ||
| 266 | coord = coord_eoesep_sym(c, (const uint32_t *)data); | 266 | coord = coord_eoesep_sym(c, (const uint32_t *)data); |
| 267 | 267 | ||
| @@ -271,7 +271,7 @@ get_eoesep_pval_cube(const unsigned char *data, cube_t c) | |||
| 271 | STATIC void | 271 | STATIC void |
| 272 | set_eoesep_pval( | 272 | set_eoesep_pval( |
| 273 | uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], | 273 | uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], |
| 274 | int64_t i, | 274 | uint64_t i, |
| 275 | uint8_t val | 275 | uint8_t val |
| 276 | ) | 276 | ) |
| 277 | { | 277 | { |
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]); | |||
| 18 | STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); | 18 | STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); |
| 19 | STATIC const unsigned char *get_h48data_constptr(const unsigned char *); | 19 | STATIC const unsigned char *get_h48data_constptr(const unsigned char *); |
| 20 | 20 | ||
| 21 | STATIC_INLINE uint8_t get_h48_pval(const unsigned char *, int64_t, uint8_t); | 21 | STATIC_INLINE uint8_t get_h48_pval(const unsigned char *, uint64_t, uint8_t); |
| 22 | STATIC_INLINE void set_h48_pval(unsigned char *, int64_t, uint8_t, uint8_t); | 22 | STATIC_INLINE void set_h48_pval(unsigned char *, uint64_t, uint8_t, uint8_t); |
| 23 | STATIC_INLINE uint8_t get_h48_pval_atomic( | 23 | STATIC_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); |
| 25 | STATIC_INLINE void set_h48_pval_atomic( | 25 | STATIC_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 | ||
| 28 | STATIC long long | 28 | STATIC long long |
| 29 | gendata_h48_dispatch( | 29 | gendata_h48_dispatch( |
| @@ -50,7 +50,7 @@ STATIC uint64_t | |||
| 50 | gendata_h48short(gendata_h48short_arg_t arg[static 1]) | 50 | gendata_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 | |||
| 607 | gendata_h48_mark_atomic(gendata_h48_mark_t arg[static 1]) | 607 | gendata_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 | |||
| 627 | gendata_h48_mark(gendata_h48_mark_t arg[static 1]) | 627 | gendata_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 | |||
| 644 | gendata_h48k2_dfs_stop(cube_t cube, int8_t d, h48k2_dfs_arg_t arg[static 1]) | 644 | gendata_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 | ||
| 707 | STATIC_INLINE uint8_t | 707 | STATIC_INLINE uint8_t |
| 708 | get_h48_pval(const unsigned char *table, int64_t i, uint8_t k) | 708 | get_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 | ||
| 713 | STATIC_INLINE uint8_t | 713 | STATIC_INLINE uint8_t |
| 714 | get_h48_pval_atomic(_Atomic const unsigned char *table, int64_t i, uint8_t k) | 714 | get_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 | ||
| 719 | STATIC_INLINE void | 719 | STATIC_INLINE void |
| 720 | set_h48_pval(unsigned char *table, int64_t i, uint8_t k, uint8_t val) | 720 | set_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) | |||
| 726 | STATIC_INLINE void | 726 | STATIC_INLINE void |
| 727 | set_h48_pval_atomic( | 727 | set_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 | ) |
diff --git a/src/solvers/h48/gendata_types_macros.h b/src/solvers/h48/gendata_types_macros.h index 21f0134..9be8e0f 100644 --- a/src/solvers/h48/gendata_types_macros.h +++ b/src/solvers/h48/gendata_types_macros.h | |||
| @@ -18,12 +18,12 @@ | |||
| 18 | #define CBOUND_MASK UINT32_C(0xFF) | 18 | #define CBOUND_MASK UINT32_C(0xFF) |
| 19 | #define CBOUND(x) ((x) & CBOUND_MASK) | 19 | #define CBOUND(x) ((x) & CBOUND_MASK) |
| 20 | 20 | ||
| 21 | #define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * ESEP_MAX)) | 21 | #define H48_COORDMAX_NOEO (COCSEP_CLASSES * ESEP_MAX) |
| 22 | #define H48_COORDMAX(h) (H48_COORDMAX_NOEO << (int64_t)(h)) | 22 | #define H48_COORDMAX(h) (H48_COORDMAX_NOEO << (uint64_t)(h)) |
| 23 | #define H48_DIV(k) ((size_t)8 / (size_t)(k)) | 23 | #define H48_DIV(k) ((size_t)8 / (size_t)(k)) |
| 24 | #define H48_TABLESIZE(h, k) DIV_ROUND_UP((size_t)H48_COORDMAX((h)), H48_DIV(k)) | 24 | #define H48_TABLESIZE(h, k) DIV_ROUND_UP((size_t)H48_COORDMAX((h)), H48_DIV(k)) |
| 25 | 25 | ||
| 26 | #define H48_COEFF(k) (INT64_C(8) / (int64_t)(k)) | 26 | #define H48_COEFF(k) (UINT64_C(8) / (uint64_t)(k)) |
| 27 | #define H48_INDEX(i, k) ((i) / H48_COEFF(k)) | 27 | #define H48_INDEX(i, k) ((i) / H48_COEFF(k)) |
| 28 | #define H48_SHIFT(i, k) ((uint8_t)(k) * (uint8_t)((i) % H48_COEFF(k))) | 28 | #define H48_SHIFT(i, k) ((uint8_t)(k) * (uint8_t)((i) % H48_COEFF(k))) |
| 29 | #define H48_MASK(i, k) ((UINT8_BIT(k) - UINT8_C(1)) << H48_SHIFT(i, k)) | 29 | #define H48_MASK(i, k) ((UINT8_BIT(k) - UINT8_C(1)) << H48_SHIFT(i, k)) |
| @@ -36,10 +36,10 @@ transforming edges, but we need to compose transformations (i.e. conjugate | |||
| 36 | VAR_T by VAR_TTREP). | 36 | VAR_T by VAR_TTREP). |
| 37 | */ | 37 | */ |
| 38 | #define FOREACH_H48SIM(ARG_CUBE, ARG_COCSEPDATA, ARG_SELFSIM, ARG_ACTION) \ | 38 | #define FOREACH_H48SIM(ARG_CUBE, ARG_COCSEPDATA, ARG_SELFSIM, ARG_ACTION) \ |
| 39 | int64_t VAR_COCSEP = coord_cocsep(ARG_CUBE); \ | 39 | uint64_t VAR_COCSEP = coord_cocsep(ARG_CUBE); \ |
| 40 | uint8_t VAR_TTREP = TTREP(ARG_COCSEPDATA[VAR_COCSEP]); \ | 40 | uint8_t VAR_TTREP = TTREP(ARG_COCSEPDATA[VAR_COCSEP]); \ |
| 41 | uint8_t VAR_INVERSE_TTREP = inverse_trans(VAR_TTREP); \ | 41 | uint8_t VAR_INVERSE_TTREP = inverse_trans(VAR_TTREP); \ |
| 42 | int64_t VAR_COCLASS = COCLASS(ARG_COCSEPDATA[VAR_COCSEP]); \ | 42 | uint64_t VAR_COCLASS = COCLASS(ARG_COCSEPDATA[VAR_COCSEP]); \ |
| 43 | cube_t VAR_REP = transform(ARG_CUBE, VAR_TTREP); \ | 43 | cube_t VAR_REP = transform(ARG_CUBE, VAR_TTREP); \ |
| 44 | uint64_t VAR_S = ARG_SELFSIM[VAR_COCLASS]; \ | 44 | uint64_t VAR_S = ARG_SELFSIM[VAR_COCLASS]; \ |
| 45 | for (uint8_t VAR_T = 0; VAR_T < NTRANS && VAR_S; VAR_T++, VAR_S >>= 1) { \ | 45 | for (uint8_t VAR_T = 0; VAR_T < NTRANS && VAR_S; VAR_T++, VAR_S >>= 1) { \ |
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h index 7718794..b603ee3 100644 --- a/src/solvers/h48/map.h +++ b/src/solvers/h48/map.h | |||
| @@ -12,7 +12,7 @@ h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) | |||
| 12 | map->capacity = capacity; | 12 | map->capacity = capacity; |
| 13 | map->randomizer = randomizer; | 13 | map->randomizer = randomizer; |
| 14 | 14 | ||
| 15 | map->table = malloc(map->capacity * sizeof(int64_t)); | 15 | map->table = malloc(map->capacity * sizeof(uint64_t)); |
| 16 | h48map_clear(map); | 16 | h48map_clear(map); |
| 17 | } | 17 | } |
| 18 | 18 | ||
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 6026ec7..50e4f99 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -36,9 +36,9 @@ typedef struct { | |||
| 36 | const unsigned char *h48data_fallback_eoesep; | 36 | const unsigned char *h48data_fallback_eoesep; |
| 37 | uint64_t movemask_normal; | 37 | uint64_t movemask_normal; |
| 38 | uint64_t movemask_inverse; | 38 | uint64_t movemask_inverse; |
| 39 | int64_t nodes_visited; | 39 | uint64_t nodes_visited; |
| 40 | int64_t table_fallbacks; | 40 | uint64_t table_fallbacks; |
| 41 | int64_t table_lookups; | 41 | uint64_t table_lookups; |
| 42 | int8_t threads; | 42 | int8_t threads; |
| 43 | int ntasks; | 43 | int ntasks; |
| 44 | solve_h48_task_t *tasks; | 44 | solve_h48_task_t *tasks; |
| @@ -463,7 +463,7 @@ solve_h48( | |||
| 463 | dfsarg_solve_h48_maketasks_t maketasks_arg; | 463 | dfsarg_solve_h48_maketasks_t maketasks_arg; |
| 464 | long double fallback_rate, lookups_per_node; | 464 | long double fallback_rate, lookups_per_node; |
| 465 | uint64_t offset; | 465 | uint64_t offset; |
| 466 | int64_t nodes_visited, table_lookups, table_fallbacks; | 466 | uint64_t nodes_visited, table_lookups, table_fallbacks; |
| 467 | tableinfo_t info, fbinfo, fbinfo2; | 467 | tableinfo_t info, fbinfo, fbinfo2; |
| 468 | const uint32_t *cocsepdata; | 468 | const uint32_t *cocsepdata; |
| 469 | const unsigned char *fallback, *h48data; | 469 | const unsigned char *fallback, *h48data; |
| @@ -579,7 +579,7 @@ solve_h48( | |||
| 579 | d++ | 579 | d++ |
| 580 | ) { | 580 | ) { |
| 581 | if (d >= H48_LOG_PROGRESS_MIN_DEPTH) { | 581 | if (d >= H48_LOG_PROGRESS_MIN_DEPTH) { |
| 582 | LOG("[H48 solve] Found %" PRId64 " solutions, " | 582 | LOG("[H48 solve] Found %" PRIu64 " solutions, " |
| 583 | "searching at depth %" PRId8 "\n", | 583 | "searching at depth %" PRId8 "\n", |
| 584 | sollist.nsols, d); | 584 | sollist.nsols, d); |
| 585 | } | 585 | } |
