diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-05 08:53:38 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-05 08:55:25 +0200 |
| commit | fd5ddb3db9f50411ca579d84f225f265ca35b56a (patch) | |
| tree | b659112cc0e2abd6c7edb08b0938c0d2de4ca066 /src/solvers | |
| parent | c9e2d6466e42d6b779ac9ffa7c5ee9a9c7558df8 (diff) | |
| download | nissy-core-fd5ddb3db9f50411ca579d84f225f265ca35b56a.tar.gz nissy-core-fd5ddb3db9f50411ca579d84f225f265ca35b56a.zip | |
Rename constants from _underscore to CAPS
Diffstat (limited to 'src/solvers')
| -rw-r--r-- | src/solvers/generic/generic.h | 20 | ||||
| -rw-r--r-- | src/solvers/h48/coordinate.h | 14 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_cocsep.h | 22 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 48 | ||||
| -rw-r--r-- | src/solvers/h48/map.h | 28 | ||||
| -rw-r--r-- | src/solvers/h48/solve.h | 42 |
6 files changed, 87 insertions, 87 deletions
diff --git a/src/solvers/generic/generic.h b/src/solvers/generic/generic.h index 41d995a..1e0299b 100644 --- a/src/solvers/generic/generic.h +++ b/src/solvers/generic/generic.h | |||
| @@ -9,14 +9,14 @@ typedef struct { | |||
| 9 | uint8_t (*estimate)(cube_t); | 9 | uint8_t (*estimate)(cube_t); |
| 10 | } dfsarg_generic_t; | 10 | } dfsarg_generic_t; |
| 11 | 11 | ||
| 12 | _static void solve_generic_appendsolution(dfsarg_generic_t *); | 12 | STATIC void solve_generic_appendsolution(dfsarg_generic_t *); |
| 13 | _static int solve_generic_dfs(dfsarg_generic_t *); | 13 | STATIC int solve_generic_dfs(dfsarg_generic_t *); |
| 14 | _static int64_t solve_generic(cube_t, const char *, int8_t, int8_t, int64_t, | 14 | STATIC int64_t solve_generic(cube_t, const char *, int8_t, int8_t, int64_t, |
| 15 | int8_t, char *, uint8_t (*)(cube_t)); | 15 | int8_t, char *, uint8_t (*)(cube_t)); |
| 16 | _static uint8_t estimate_simple(cube_t); | 16 | STATIC uint8_t estimate_simple(cube_t); |
| 17 | _static int64_t solve_simple(cube_t, int8_t, int8_t, int64_t, int8_t, char *); | 17 | STATIC int64_t solve_simple(cube_t, int8_t, int8_t, int64_t, int8_t, char *); |
| 18 | 18 | ||
| 19 | _static void | 19 | STATIC void |
| 20 | solve_generic_appendsolution(dfsarg_generic_t *arg) | 20 | solve_generic_appendsolution(dfsarg_generic_t *arg) |
| 21 | { | 21 | { |
| 22 | int strl; | 22 | int strl; |
| @@ -29,7 +29,7 @@ solve_generic_appendsolution(dfsarg_generic_t *arg) | |||
| 29 | (*arg->nsols)++; | 29 | (*arg->nsols)++; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | _static int | 32 | STATIC int |
| 33 | solve_generic_dfs(dfsarg_generic_t *arg) | 33 | solve_generic_dfs(dfsarg_generic_t *arg) |
| 34 | { | 34 | { |
| 35 | dfsarg_generic_t nextarg; | 35 | dfsarg_generic_t nextarg; |
| @@ -64,7 +64,7 @@ solve_generic_dfs(dfsarg_generic_t *arg) | |||
| 64 | return ret; | 64 | return ret; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | _static int64_t | 67 | STATIC int64_t |
| 68 | solve_generic( | 68 | solve_generic( |
| 69 | cube_t cube, | 69 | cube_t cube, |
| 70 | const char *nisstype, | 70 | const char *nisstype, |
| @@ -128,13 +128,13 @@ solve_generic( | |||
| 128 | return ret; | 128 | return ret; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | _static uint8_t | 131 | STATIC uint8_t |
| 132 | estimate_simple(cube_t cube) | 132 | estimate_simple(cube_t cube) |
| 133 | { | 133 | { |
| 134 | return issolved(cube) ? 0 : 1; | 134 | return issolved(cube) ? 0 : 1; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | _static int64_t | 137 | STATIC int64_t |
| 138 | solve_simple( | 138 | solve_simple( |
| 139 | cube_t cube, | 139 | cube_t cube, |
| 140 | int8_t minmoves, | 140 | int8_t minmoves, |
diff --git a/src/solvers/h48/coordinate.h b/src/solvers/h48/coordinate.h index 47b805d..4da5575 100644 --- a/src/solvers/h48/coordinate.h +++ b/src/solvers/h48/coordinate.h | |||
| @@ -1,15 +1,15 @@ | |||
| 1 | #define H48_ESIZE(h) ((_12c4 * _8c4) << (int64_t)(h)) | 1 | #define H48_ESIZE(h) ((COMB_12_4 * COMB_8_4) << (int64_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)) |
| 5 | #define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8)) | 5 | #define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8)) |
| 6 | #define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8)) | 6 | #define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8)) |
| 7 | 7 | ||
| 8 | _static_inline int64_t coord_h48(cube_t, const uint32_t *, uint8_t); | 8 | STATIC_INLINE int64_t coord_h48(cube_t, const uint32_t *, uint8_t); |
| 9 | _static_inline int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); | 9 | STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); |
| 10 | _static_inline cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); | 10 | STATIC_INLINE cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); |
| 11 | 11 | ||
| 12 | _static_inline int64_t | 12 | STATIC_INLINE int64_t |
| 13 | coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) | 13 | coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) |
| 14 | { | 14 | { |
| 15 | int64_t cocsep, coclass; | 15 | int64_t cocsep, coclass; |
| @@ -26,7 +26,7 @@ coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) | |||
| 26 | return coord_h48_edges(c, coclass, ttrep, h); | 26 | return coord_h48_edges(c, coclass, ttrep, h); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | _static_inline int64_t | 29 | STATIC_INLINE int64_t |
| 30 | coord_h48_edges(cube_t c, int64_t coclass, uint8_t ttrep, uint8_t h) | 30 | coord_h48_edges(cube_t c, int64_t coclass, uint8_t ttrep, uint8_t h) |
| 31 | { | 31 | { |
| 32 | cube_t d; | 32 | cube_t d; |
| @@ -45,7 +45,7 @@ This function does not necessarily return a cube whose coordinate is | |||
| 45 | the given value, because it works up to symmetry. This means that the | 45 | the given value, because it works up to symmetry. This means that the |
| 46 | returned cube is a transformed cube of one that gives the correct value. | 46 | returned cube is a transformed cube of one that gives the correct value. |
| 47 | */ | 47 | */ |
| 48 | _static_inline cube_t | 48 | STATIC_INLINE cube_t |
| 49 | invcoord_h48(int64_t i, const cube_t *crep, uint8_t h) | 49 | invcoord_h48(int64_t i, const cube_t *crep, uint8_t h) |
| 50 | { | 50 | { |
| 51 | cube_t ret; | 51 | cube_t ret; |
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index b7d28e1..54e092e 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #define COCSEP_CLASSES ((size_t)3393) | 1 | #define COCSEP_CLASSES ((size_t)3393) |
| 2 | #define COCSEP_TABLESIZE ((size_t)_3p7 << (size_t)7) | 2 | #define COCSEP_TABLESIZE ((size_t)POW_3_7 << (size_t)7) |
| 3 | #define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + (size_t)7) / (size_t)8) | 3 | #define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + (size_t)7) / (size_t)8) |
| 4 | #define COCSEP_FULLSIZE ((size_t)4 * (COCSEP_TABLESIZE + (size_t)12)) | 4 | #define COCSEP_FULLSIZE ((size_t)4 * (COCSEP_TABLESIZE + (size_t)12)) |
| 5 | 5 | ||
| @@ -20,13 +20,13 @@ typedef struct { | |||
| 20 | cube_t *rep; | 20 | cube_t *rep; |
| 21 | } cocsep_dfs_arg_t; | 21 | } cocsep_dfs_arg_t; |
| 22 | 22 | ||
| 23 | _static_inline bool get_visited(const uint8_t *, int64_t); | 23 | STATIC_INLINE bool get_visited(const uint8_t *, int64_t); |
| 24 | _static_inline void set_visited(uint8_t *, int64_t); | 24 | STATIC_INLINE void set_visited(uint8_t *, int64_t); |
| 25 | 25 | ||
| 26 | _static size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 26 | STATIC size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 27 | _static uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); | 27 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); |
| 28 | 28 | ||
| 29 | _static_inline int8_t get_h48_cdata(cube_t, uint32_t *, uint32_t *); | 29 | STATIC_INLINE int8_t get_h48_cdata(cube_t, uint32_t *, uint32_t *); |
| 30 | 30 | ||
| 31 | /* | 31 | /* |
| 32 | Each element of the cocsep table is a uint32_t used as follows: | 32 | Each element of the cocsep table is a uint32_t used as follows: |
| @@ -39,7 +39,7 @@ After the data as described above, more auxiliary information is appended: | |||
| 39 | - One uint32_t for each "line" of the pruning table, representing the number | 39 | - One uint32_t for each "line" of the pruning table, representing the number |
| 40 | of positions having that pruning value. | 40 | of positions having that pruning value. |
| 41 | */ | 41 | */ |
| 42 | _static size_t | 42 | STATIC size_t |
| 43 | gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep) | 43 | gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep) |
| 44 | { | 44 | { |
| 45 | uint32_t *buf32, *info, cc; | 45 | uint32_t *buf32, *info, cc; |
| @@ -91,7 +91,7 @@ gendata_cocsep_return_size: | |||
| 91 | return COCSEP_FULLSIZE; | 91 | return COCSEP_FULLSIZE; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | _static uint32_t | 94 | STATIC uint32_t |
| 95 | gendata_cocsep_dfs(cocsep_dfs_arg_t *arg) | 95 | gendata_cocsep_dfs(cocsep_dfs_arg_t *arg) |
| 96 | { | 96 | { |
| 97 | uint8_t m; | 97 | uint8_t m; |
| @@ -145,19 +145,19 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t *arg) | |||
| 145 | return cc; | 145 | return cc; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | _static_inline bool | 148 | STATIC_INLINE bool |
| 149 | get_visited(const uint8_t *a, int64_t i) | 149 | get_visited(const uint8_t *a, int64_t i) |
| 150 | { | 150 | { |
| 151 | return a[VISITED_IND(i)] & VISITED_MASK(i); | 151 | return a[VISITED_IND(i)] & VISITED_MASK(i); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | _static_inline void | 154 | STATIC_INLINE void |
| 155 | set_visited(uint8_t *a, int64_t i) | 155 | set_visited(uint8_t *a, int64_t i) |
| 156 | { | 156 | { |
| 157 | a[VISITED_IND(i)] |= VISITED_MASK(i); | 157 | a[VISITED_IND(i)] |= VISITED_MASK(i); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | _static_inline int8_t | 160 | STATIC_INLINE int8_t |
| 161 | get_h48_cdata(cube_t cube, uint32_t *cocsepdata, uint32_t *cdata) | 161 | get_h48_cdata(cube_t cube, uint32_t *cocsepdata, uint32_t *cdata) |
| 162 | { | 162 | { |
| 163 | int64_t coord; | 163 | int64_t coord; |
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 6486834..0778b3c 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * _12c4 * _8c4)) | 1 | #define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * COMB_12_4 * COMB_8_4)) |
| 2 | #define H48_COORDMAX(h) ((int64_t)(H48_COORDMAX_NOEO << (int64_t)(h))) | 2 | #define H48_COORDMAX(h) ((int64_t)(H48_COORDMAX_NOEO << (int64_t)(h))) |
| 3 | #define H48_DIV(k) ((size_t)8 / (size_t)(k)) | 3 | #define H48_DIV(k) ((size_t)8 / (size_t)(k)) |
| 4 | #define H48_TABLESIZE(h, k) _div_round_up((size_t)H48_COORDMAX((h)), H48_DIV(k)) | 4 | #define H48_TABLESIZE(h, k) _div_round_up((size_t)H48_COORDMAX((h)), H48_DIV(k)) |
| @@ -6,7 +6,7 @@ | |||
| 6 | #define H48_COEFF(k) (UINT32_C(32) / (uint32_t)(k)) | 6 | #define H48_COEFF(k) (UINT32_C(32) / (uint32_t)(k)) |
| 7 | #define H48_INDEX(i, k) ((uint32_t)(i) / H48_COEFF(k)) | 7 | #define H48_INDEX(i, k) ((uint32_t)(i) / H48_COEFF(k)) |
| 8 | #define H48_SHIFT(i, k) ((uint32_t)(k) * ((uint32_t)(i) % H48_COEFF(k))) | 8 | #define H48_SHIFT(i, k) ((uint32_t)(k) * ((uint32_t)(i) % H48_COEFF(k))) |
| 9 | #define H48_MASK(i, k) ((_bit_u32(k) - (uint32_t)(1)) << H48_SHIFT(i, k)) | 9 | #define H48_MASK(i, k) ((UINT32_BIT(k) - (uint32_t)(1)) << H48_SHIFT(i, k)) |
| 10 | 10 | ||
| 11 | #define MAXLEN 20 | 11 | #define MAXLEN 20 |
| 12 | 12 | ||
| @@ -74,21 +74,21 @@ typedef struct { | |||
| 74 | h48map_t *shortcubes; | 74 | h48map_t *shortcubes; |
| 75 | } h48k2_dfs_arg_t; | 75 | } h48k2_dfs_arg_t; |
| 76 | 76 | ||
| 77 | _static_inline uint8_t get_esep_pval(const uint32_t *, int64_t, uint8_t); | 77 | STATIC_INLINE uint8_t get_esep_pval(const uint32_t *, int64_t, uint8_t); |
| 78 | _static_inline void set_esep_pval(uint32_t *, int64_t, uint8_t, uint8_t); | 78 | STATIC_INLINE void set_esep_pval(uint32_t *, int64_t, uint8_t, uint8_t); |
| 79 | 79 | ||
| 80 | _static uint64_t gen_h48short(gendata_h48short_arg_t *); | 80 | STATIC uint64_t gen_h48short(gendata_h48short_arg_t *); |
| 81 | _static size_t gendata_h48(gendata_h48_arg_t *); | 81 | STATIC size_t gendata_h48(gendata_h48_arg_t *); |
| 82 | _static size_t gendata_h48h0k4(gendata_h48_arg_t *); | 82 | STATIC size_t gendata_h48h0k4(gendata_h48_arg_t *); |
| 83 | _static int64_t gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *); | 83 | STATIC int64_t gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *); |
| 84 | _static int64_t gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *); | 84 | STATIC int64_t gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *); |
| 85 | _static int64_t gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *); | 85 | STATIC int64_t gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *); |
| 86 | _static size_t gendata_h48k2(gendata_h48_arg_t *); | 86 | STATIC size_t gendata_h48k2(gendata_h48_arg_t *); |
| 87 | _static void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); | 87 | STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); |
| 88 | 88 | ||
| 89 | _static_inline int8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint8_t, uint32_t *); | 89 | STATIC_INLINE int8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint8_t, uint32_t *); |
| 90 | 90 | ||
| 91 | _static uint64_t | 91 | STATIC uint64_t |
| 92 | gen_h48short(gendata_h48short_arg_t *arg) | 92 | gen_h48short(gendata_h48short_arg_t *arg) |
| 93 | { | 93 | { |
| 94 | uint8_t i, m; | 94 | uint8_t i, m; |
| @@ -129,7 +129,7 @@ gen_h48short(gendata_h48short_arg_t *arg) | |||
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | /* Generic function that dispatches to the data generators */ | 131 | /* Generic function that dispatches to the data generators */ |
| 132 | _static size_t | 132 | STATIC size_t |
| 133 | gendata_h48(gendata_h48_arg_t *arg) | 133 | gendata_h48(gendata_h48_arg_t *arg) |
| 134 | { | 134 | { |
| 135 | static const size_t infosize = 88; /* TODO: change to e.g. 1024 */ | 135 | static const size_t infosize = 88; /* TODO: change to e.g. 1024 */ |
| @@ -164,7 +164,7 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 164 | TODO description | 164 | TODO description |
| 165 | generating fixed table with h=0, k=4 | 165 | generating fixed table with h=0, k=4 |
| 166 | */ | 166 | */ |
| 167 | _static size_t | 167 | STATIC size_t |
| 168 | gendata_h48h0k4(gendata_h48_arg_t *arg) | 168 | gendata_h48h0k4(gendata_h48_arg_t *arg) |
| 169 | { | 169 | { |
| 170 | uint32_t j; | 170 | uint32_t j; |
| @@ -208,7 +208,7 @@ gendata_h48h0k4_return_size: | |||
| 208 | return H48_TABLESIZE(0, 4); | 208 | return H48_TABLESIZE(0, 4); |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | _static int64_t | 211 | STATIC int64_t |
| 212 | gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *arg) | 212 | gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *arg) |
| 213 | { | 213 | { |
| 214 | const uint8_t breakpoint = 10; /* Hand-picked optimal */ | 214 | const uint8_t breakpoint = 10; /* Hand-picked optimal */ |
| @@ -219,7 +219,7 @@ gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *arg) | |||
| 219 | return gendata_h48h0k4_bfs_fromnew(arg); | 219 | return gendata_h48h0k4_bfs_fromnew(arg); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | _static int64_t | 222 | STATIC int64_t |
| 223 | gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *arg) | 223 | gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *arg) |
| 224 | { | 224 | { |
| 225 | uint8_t c, m, x; | 225 | uint8_t c, m, x; |
| @@ -249,7 +249,7 @@ gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *arg) | |||
| 249 | return cc; | 249 | return cc; |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | _static int64_t | 252 | STATIC int64_t |
| 253 | gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *arg) | 253 | gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *arg) |
| 254 | { | 254 | { |
| 255 | uint8_t c, m, x; | 255 | uint8_t c, m, x; |
| @@ -281,7 +281,7 @@ gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *arg) | |||
| 281 | return cc; | 281 | return cc; |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | _static size_t | 284 | STATIC size_t |
| 285 | gendata_h48k2(gendata_h48_arg_t *arg) | 285 | gendata_h48k2(gendata_h48_arg_t *arg) |
| 286 | { | 286 | { |
| 287 | static const uint8_t shortdepth = 8; | 287 | static const uint8_t shortdepth = 8; |
| @@ -363,7 +363,7 @@ gendata_h48k2_return_size: | |||
| 363 | return H48_TABLESIZE(arg->h, 2); | 363 | return H48_TABLESIZE(arg->h, 2); |
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | _static void | 366 | STATIC void |
| 367 | gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) | 367 | gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) |
| 368 | { | 368 | { |
| 369 | cube_t ccc; | 369 | cube_t ccc; |
| @@ -406,20 +406,20 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) | |||
| 406 | } | 406 | } |
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | _static_inline uint8_t | 409 | STATIC_INLINE uint8_t |
| 410 | get_esep_pval(const uint32_t *buf32, int64_t i, uint8_t k) | 410 | get_esep_pval(const uint32_t *buf32, int64_t i, uint8_t k) |
| 411 | { | 411 | { |
| 412 | return (buf32[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); | 412 | return (buf32[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); |
| 413 | } | 413 | } |
| 414 | 414 | ||
| 415 | _static_inline void | 415 | STATIC_INLINE void |
| 416 | set_esep_pval(uint32_t *buf32, int64_t i, uint8_t k, uint8_t val) | 416 | set_esep_pval(uint32_t *buf32, int64_t i, uint8_t k, uint8_t val) |
| 417 | { | 417 | { |
| 418 | buf32[H48_INDEX(i, k)] = (buf32[H48_INDEX(i, k)] & (~H48_MASK(i, k))) | 418 | buf32[H48_INDEX(i, k)] = (buf32[H48_INDEX(i, k)] & (~H48_MASK(i, k))) |
| 419 | | (val << H48_SHIFT(i, k)); | 419 | | (val << H48_SHIFT(i, k)); |
| 420 | } | 420 | } |
| 421 | 421 | ||
| 422 | _static_inline int8_t | 422 | STATIC_INLINE int8_t |
| 423 | get_h48_bound(cube_t cube, uint32_t cdata, uint8_t h, uint8_t k, uint32_t *h48data) | 423 | get_h48_bound(cube_t cube, uint32_t cdata, uint8_t h, uint8_t k, uint32_t *h48data) |
| 424 | { | 424 | { |
| 425 | int64_t coord; | 425 | int64_t coord; |
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h index 0e9f926..34416fc 100644 --- a/src/solvers/h48/map.h +++ b/src/solvers/h48/map.h | |||
| @@ -15,15 +15,15 @@ typedef struct { | |||
| 15 | uint64_t val; | 15 | uint64_t val; |
| 16 | } kvpair_t; | 16 | } kvpair_t; |
| 17 | 17 | ||
| 18 | _static void h48map_create(h48map_t *, uint64_t, uint64_t); | 18 | STATIC void h48map_create(h48map_t *, uint64_t, uint64_t); |
| 19 | _static void h48map_clear(h48map_t *); | 19 | STATIC void h48map_clear(h48map_t *); |
| 20 | _static void h48map_destroy(h48map_t *); | 20 | STATIC void h48map_destroy(h48map_t *); |
| 21 | _static uint64_t h48map_lookup(h48map_t *, uint64_t); | 21 | STATIC uint64_t h48map_lookup(h48map_t *, uint64_t); |
| 22 | _static void h48map_insertmin(h48map_t *, uint64_t, uint64_t); | 22 | STATIC void h48map_insertmin(h48map_t *, uint64_t, uint64_t); |
| 23 | _static uint64_t h48map_value(h48map_t *, uint64_t); | 23 | STATIC uint64_t h48map_value(h48map_t *, uint64_t); |
| 24 | _static kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); | 24 | STATIC kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); |
| 25 | 25 | ||
| 26 | _static void | 26 | STATIC void |
| 27 | h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) | 27 | h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) |
| 28 | { | 28 | { |
| 29 | map->capacity = capacity; | 29 | map->capacity = capacity; |
| @@ -33,20 +33,20 @@ h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) | |||
| 33 | h48map_clear(map); | 33 | h48map_clear(map); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | _static void | 36 | STATIC void |
| 37 | h48map_clear(h48map_t *map) | 37 | h48map_clear(h48map_t *map) |
| 38 | { | 38 | { |
| 39 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); | 39 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); |
| 40 | map->n = 0; | 40 | map->n = 0; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | _static void | 43 | STATIC void |
| 44 | h48map_destroy(h48map_t *map) | 44 | h48map_destroy(h48map_t *map) |
| 45 | { | 45 | { |
| 46 | free(map->table); | 46 | free(map->table); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | _static_inline uint64_t | 49 | STATIC_INLINE uint64_t |
| 50 | h48map_lookup(h48map_t *map, uint64_t x) | 50 | h48map_lookup(h48map_t *map, uint64_t x) |
| 51 | { | 51 | { |
| 52 | uint64_t hash, i; | 52 | uint64_t hash, i; |
| @@ -60,7 +60,7 @@ h48map_lookup(h48map_t *map, uint64_t x) | |||
| 60 | return i; | 60 | return i; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | _static_inline void | 63 | STATIC_INLINE void |
| 64 | h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) | 64 | h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) |
| 65 | { | 65 | { |
| 66 | uint64_t i, oldval, min; | 66 | uint64_t i, oldval, min; |
| @@ -73,13 +73,13 @@ h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) | |||
| 73 | map->table[i] = (key & MAP_KEYMASK) | (min << MAP_KEYSHIFT); | 73 | map->table[i] = (key & MAP_KEYMASK) | (min << MAP_KEYSHIFT); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | _static_inline uint64_t | 76 | STATIC_INLINE uint64_t |
| 77 | h48map_value(h48map_t *map, uint64_t key) | 77 | h48map_value(h48map_t *map, uint64_t key) |
| 78 | { | 78 | { |
| 79 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; | 79 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | _static kvpair_t | 82 | STATIC kvpair_t |
| 83 | h48map_nextkvpair(h48map_t *map, uint64_t *p) | 83 | h48map_nextkvpair(h48map_t *map, uint64_t *p) |
| 84 | { | 84 | { |
| 85 | kvpair_t kv; | 85 | kvpair_t kv; |
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 3878498..88c5a1e 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -26,22 +26,22 @@ typedef struct { | |||
| 26 | char *s; | 26 | char *s; |
| 27 | } dfsarg_solveh48stats_t; | 27 | } dfsarg_solveh48stats_t; |
| 28 | 28 | ||
| 29 | _static uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint32_t); | 29 | STATIC uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint32_t); |
| 30 | 30 | ||
| 31 | _static void solve_h48_appendsolution(dfsarg_solveh48_t *); | 31 | STATIC void solve_h48_appendsolution(dfsarg_solveh48_t *); |
| 32 | _static_inline bool solve_h48_stop(dfsarg_solveh48_t *); | 32 | STATIC_INLINE bool solve_h48_stop(dfsarg_solveh48_t *); |
| 33 | _static int64_t solve_h48_dfs(dfsarg_solveh48_t *); | 33 | STATIC int64_t solve_h48_dfs(dfsarg_solveh48_t *); |
| 34 | _static int64_t solve_h48(cube_t, int8_t, int8_t, int8_t, uint8_t, uint8_t, const void *, char *); | 34 | STATIC int64_t solve_h48(cube_t, int8_t, int8_t, int8_t, uint8_t, uint8_t, const void *, char *); |
| 35 | 35 | ||
| 36 | _static int64_t solve_h48stats_dfs(dfsarg_solveh48stats_t *); | 36 | STATIC int64_t solve_h48stats_dfs(dfsarg_solveh48stats_t *); |
| 37 | _static int64_t solve_h48stats(cube_t, int8_t, const void *, char [static 12]); | 37 | STATIC int64_t solve_h48stats(cube_t, int8_t, const void *, char [static 12]); |
| 38 | 38 | ||
| 39 | _static uint32_t | 39 | STATIC uint32_t |
| 40 | allowednextmove_h48(uint8_t *moves, uint8_t n, uint32_t h48branch) | 40 | allowednextmove_h48(uint8_t *moves, uint8_t n, uint32_t h48branch) |
| 41 | { | 41 | { |
| 42 | uint32_t result = _mm_allmoves; | 42 | uint32_t result = MM_ALLMOVES; |
| 43 | if (h48branch & _mm_normalbranch) | 43 | if (h48branch & MM_NORMALBRANCH) |
| 44 | result &= _mm_nohalfturns; | 44 | result &= MM_NOHALFTURNS; |
| 45 | if (n < 1) | 45 | if (n < 1) |
| 46 | return result; | 46 | return result; |
| 47 | 47 | ||
| @@ -64,7 +64,7 @@ allowednextmove_h48(uint8_t *moves, uint8_t n, uint32_t h48branch) | |||
| 64 | return result; | 64 | return result; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | _static void | 67 | STATIC void |
| 68 | solve_h48_appendsolution(dfsarg_solveh48_t *arg) | 68 | solve_h48_appendsolution(dfsarg_solveh48_t *arg) |
| 69 | { | 69 | { |
| 70 | int strl; | 70 | int strl; |
| @@ -89,13 +89,13 @@ solve_h48_appendsolution(dfsarg_solveh48_t *arg) | |||
| 89 | (*arg->nsols)++; | 89 | (*arg->nsols)++; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | _static_inline bool | 92 | STATIC_INLINE bool |
| 93 | solve_h48_stop(dfsarg_solveh48_t *arg) | 93 | solve_h48_stop(dfsarg_solveh48_t *arg) |
| 94 | { | 94 | { |
| 95 | uint32_t data, data_inv; | 95 | uint32_t data, data_inv; |
| 96 | int8_t bound; | 96 | int8_t bound; |
| 97 | 97 | ||
| 98 | arg->nissbranch = _mm_normal; | 98 | arg->nissbranch = MM_NORMAL; |
| 99 | bound = get_h48_cdata(arg->cube, arg->cocsepdata, &data); | 99 | bound = get_h48_cdata(arg->cube, arg->cocsepdata, &data); |
| 100 | if (bound + arg->nmoves + arg->npremoves > arg->depth) | 100 | if (bound + arg->nmoves + arg->npremoves > arg->depth) |
| 101 | return true; | 101 | return true; |
| @@ -109,18 +109,18 @@ solve_h48_stop(dfsarg_solveh48_t *arg) | |||
| 109 | if (bound + arg->nmoves + arg->npremoves > arg->depth) | 109 | if (bound + arg->nmoves + arg->npremoves > arg->depth) |
| 110 | return true; | 110 | return true; |
| 111 | if (bound + arg->nmoves + arg->npremoves == arg->depth) | 111 | if (bound + arg->nmoves + arg->npremoves == arg->depth) |
| 112 | arg->nissbranch = _mm_inversebranch; | 112 | arg->nissbranch = MM_INVERSEBRANCH; |
| 113 | 113 | ||
| 114 | bound = get_h48_bound(arg->inverse, data_inv, arg->h, arg->k, arg->h48data); | 114 | bound = get_h48_bound(arg->inverse, data_inv, arg->h, arg->k, arg->h48data); |
| 115 | if (bound + arg->nmoves + arg->npremoves > arg->depth) | 115 | if (bound + arg->nmoves + arg->npremoves > arg->depth) |
| 116 | return true; | 116 | return true; |
| 117 | if (bound + arg->nmoves + arg->npremoves == arg->depth) | 117 | if (bound + arg->nmoves + arg->npremoves == arg->depth) |
| 118 | arg->nissbranch = _mm_normalbranch; | 118 | arg->nissbranch = MM_NORMALBRANCH; |
| 119 | 119 | ||
| 120 | return false; | 120 | return false; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | _static int64_t | 123 | STATIC int64_t |
| 124 | solve_h48_dfs(dfsarg_solveh48_t *arg) | 124 | solve_h48_dfs(dfsarg_solveh48_t *arg) |
| 125 | { | 125 | { |
| 126 | dfsarg_solveh48_t nextarg; | 126 | dfsarg_solveh48_t nextarg; |
| @@ -144,7 +144,7 @@ solve_h48_dfs(dfsarg_solveh48_t *arg) | |||
| 144 | nextarg = *arg; | 144 | nextarg = *arg; |
| 145 | ret = 0; | 145 | ret = 0; |
| 146 | uint32_t allowed; | 146 | uint32_t allowed; |
| 147 | if(arg->nissbranch & _mm_inverse) { | 147 | if(arg->nissbranch & MM_INVERSE) { |
| 148 | allowed = allowednextmove_h48(arg->premoves, arg->npremoves, arg->nissbranch); | 148 | allowed = allowednextmove_h48(arg->premoves, arg->npremoves, arg->nissbranch); |
| 149 | for (m = 0; m < 18; m++) { | 149 | for (m = 0; m < 18; m++) { |
| 150 | if(allowed & (1 << m)) { | 150 | if(allowed & (1 << m)) { |
| @@ -171,7 +171,7 @@ solve_h48_dfs(dfsarg_solveh48_t *arg) | |||
| 171 | return ret; | 171 | return ret; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | _static int64_t | 174 | STATIC int64_t |
| 175 | solve_h48( | 175 | solve_h48( |
| 176 | cube_t cube, | 176 | cube_t cube, |
| 177 | int8_t minmoves, | 177 | int8_t minmoves, |
| @@ -219,7 +219,7 @@ each of the 12 h48 coordinates, one for each value of h from 0 to 11. | |||
| 219 | The solutions array is filled with the length of the solutions. The | 219 | The solutions array is filled with the length of the solutions. The |
| 220 | solution array is therefore not a printable string. | 220 | solution array is therefore not a printable string. |
| 221 | */ | 221 | */ |
| 222 | _static int64_t | 222 | STATIC int64_t |
| 223 | solve_h48stats_dfs(dfsarg_solveh48stats_t *arg) | 223 | solve_h48stats_dfs(dfsarg_solveh48stats_t *arg) |
| 224 | { | 224 | { |
| 225 | const int64_t limit = 11; | 225 | const int64_t limit = 11; |
| @@ -268,7 +268,7 @@ solve_h48stats_dfs(dfsarg_solveh48stats_t *arg) | |||
| 268 | return 0; | 268 | return 0; |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | _static int64_t | 271 | STATIC int64_t |
| 272 | solve_h48stats( | 272 | solve_h48stats( |
| 273 | cube_t cube, | 273 | cube_t cube, |
| 274 | int8_t maxmoves, | 274 | int8_t maxmoves, |
