From fd5ddb3db9f50411ca579d84f225f265ca35b56a Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 5 Sep 2024 08:53:38 +0200 Subject: Rename constants from _underscore to CAPS --- src/solvers/h48/coordinate.h | 14 ++++++------ src/solvers/h48/gendata_cocsep.h | 22 +++++++++--------- src/solvers/h48/gendata_h48.h | 48 ++++++++++++++++++++-------------------- src/solvers/h48/map.h | 30 ++++++++++++------------- src/solvers/h48/solve.h | 42 +++++++++++++++++------------------ 5 files changed, 78 insertions(+), 78 deletions(-) (limited to 'src/solvers/h48') 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 @@ -#define H48_ESIZE(h) ((_12c4 * _8c4) << (int64_t)(h)) +#define H48_ESIZE(h) ((COMB_12_4 * COMB_8_4) << (int64_t)(h)) #define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) #define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16)) #define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8)) #define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8)) -_static_inline int64_t coord_h48(cube_t, const uint32_t *, uint8_t); -_static_inline int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); -_static_inline cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); +STATIC_INLINE int64_t coord_h48(cube_t, const uint32_t *, uint8_t); +STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); +STATIC_INLINE cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); -_static_inline int64_t +STATIC_INLINE int64_t coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) { int64_t cocsep, coclass; @@ -26,7 +26,7 @@ coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) return coord_h48_edges(c, coclass, ttrep, h); } -_static_inline int64_t +STATIC_INLINE int64_t coord_h48_edges(cube_t c, int64_t coclass, uint8_t ttrep, uint8_t h) { cube_t d; @@ -45,7 +45,7 @@ This function does not necessarily return a cube whose coordinate is the given value, because it works up to symmetry. This means that the returned cube is a transformed cube of one that gives the correct value. */ -_static_inline cube_t +STATIC_INLINE cube_t invcoord_h48(int64_t i, const cube_t *crep, uint8_t h) { 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 @@ #define COCSEP_CLASSES ((size_t)3393) -#define COCSEP_TABLESIZE ((size_t)_3p7 << (size_t)7) +#define COCSEP_TABLESIZE ((size_t)POW_3_7 << (size_t)7) #define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + (size_t)7) / (size_t)8) #define COCSEP_FULLSIZE ((size_t)4 * (COCSEP_TABLESIZE + (size_t)12)) @@ -20,13 +20,13 @@ typedef struct { cube_t *rep; } cocsep_dfs_arg_t; -_static_inline bool get_visited(const uint8_t *, int64_t); -_static_inline void set_visited(uint8_t *, int64_t); +STATIC_INLINE bool get_visited(const uint8_t *, int64_t); +STATIC_INLINE void set_visited(uint8_t *, int64_t); -_static size_t gendata_cocsep(void *, uint64_t *, cube_t *); -_static uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); +STATIC size_t gendata_cocsep(void *, uint64_t *, cube_t *); +STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); -_static_inline int8_t get_h48_cdata(cube_t, uint32_t *, uint32_t *); +STATIC_INLINE int8_t get_h48_cdata(cube_t, uint32_t *, uint32_t *); /* 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: - One uint32_t for each "line" of the pruning table, representing the number of positions having that pruning value. */ -_static size_t +STATIC size_t gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep) { uint32_t *buf32, *info, cc; @@ -91,7 +91,7 @@ gendata_cocsep_return_size: return COCSEP_FULLSIZE; } -_static uint32_t +STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *arg) { uint8_t m; @@ -145,19 +145,19 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t *arg) return cc; } -_static_inline bool +STATIC_INLINE bool get_visited(const uint8_t *a, int64_t i) { return a[VISITED_IND(i)] & VISITED_MASK(i); } -_static_inline void +STATIC_INLINE void set_visited(uint8_t *a, int64_t i) { a[VISITED_IND(i)] |= VISITED_MASK(i); } -_static_inline int8_t +STATIC_INLINE int8_t get_h48_cdata(cube_t cube, uint32_t *cocsepdata, uint32_t *cdata) { 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 @@ -#define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * _12c4 * _8c4)) +#define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * COMB_12_4 * COMB_8_4)) #define H48_COORDMAX(h) ((int64_t)(H48_COORDMAX_NOEO << (int64_t)(h))) #define H48_DIV(k) ((size_t)8 / (size_t)(k)) #define H48_TABLESIZE(h, k) _div_round_up((size_t)H48_COORDMAX((h)), H48_DIV(k)) @@ -6,7 +6,7 @@ #define H48_COEFF(k) (UINT32_C(32) / (uint32_t)(k)) #define H48_INDEX(i, k) ((uint32_t)(i) / H48_COEFF(k)) #define H48_SHIFT(i, k) ((uint32_t)(k) * ((uint32_t)(i) % H48_COEFF(k))) -#define H48_MASK(i, k) ((_bit_u32(k) - (uint32_t)(1)) << H48_SHIFT(i, k)) +#define H48_MASK(i, k) ((UINT32_BIT(k) - (uint32_t)(1)) << H48_SHIFT(i, k)) #define MAXLEN 20 @@ -74,21 +74,21 @@ typedef struct { h48map_t *shortcubes; } h48k2_dfs_arg_t; -_static_inline uint8_t get_esep_pval(const uint32_t *, int64_t, uint8_t); -_static_inline void set_esep_pval(uint32_t *, int64_t, uint8_t, uint8_t); +STATIC_INLINE uint8_t get_esep_pval(const uint32_t *, int64_t, uint8_t); +STATIC_INLINE void set_esep_pval(uint32_t *, int64_t, uint8_t, uint8_t); -_static uint64_t gen_h48short(gendata_h48short_arg_t *); -_static size_t gendata_h48(gendata_h48_arg_t *); -_static size_t gendata_h48h0k4(gendata_h48_arg_t *); -_static int64_t gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *); -_static int64_t gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *); -_static int64_t gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *); -_static size_t gendata_h48k2(gendata_h48_arg_t *); -_static void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); +STATIC uint64_t gen_h48short(gendata_h48short_arg_t *); +STATIC size_t gendata_h48(gendata_h48_arg_t *); +STATIC size_t gendata_h48h0k4(gendata_h48_arg_t *); +STATIC int64_t gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *); +STATIC int64_t gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *); +STATIC int64_t gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *); +STATIC size_t gendata_h48k2(gendata_h48_arg_t *); +STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); -_static_inline int8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint8_t, uint32_t *); +STATIC_INLINE int8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint8_t, uint32_t *); -_static uint64_t +STATIC uint64_t gen_h48short(gendata_h48short_arg_t *arg) { uint8_t i, m; @@ -129,7 +129,7 @@ gen_h48short(gendata_h48short_arg_t *arg) } /* Generic function that dispatches to the data generators */ -_static size_t +STATIC size_t gendata_h48(gendata_h48_arg_t *arg) { static const size_t infosize = 88; /* TODO: change to e.g. 1024 */ @@ -164,7 +164,7 @@ gendata_h48(gendata_h48_arg_t *arg) TODO description generating fixed table with h=0, k=4 */ -_static size_t +STATIC size_t gendata_h48h0k4(gendata_h48_arg_t *arg) { uint32_t j; @@ -208,7 +208,7 @@ gendata_h48h0k4_return_size: return H48_TABLESIZE(0, 4); } -_static int64_t +STATIC int64_t gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *arg) { const uint8_t breakpoint = 10; /* Hand-picked optimal */ @@ -219,7 +219,7 @@ gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *arg) return gendata_h48h0k4_bfs_fromnew(arg); } -_static int64_t +STATIC int64_t gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *arg) { uint8_t c, m, x; @@ -249,7 +249,7 @@ gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *arg) return cc; } -_static int64_t +STATIC int64_t gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *arg) { uint8_t c, m, x; @@ -281,7 +281,7 @@ gendata_h48h0k4_bfs_fromnew(h48h0k4_bfs_arg_t *arg) return cc; } -_static size_t +STATIC size_t gendata_h48k2(gendata_h48_arg_t *arg) { static const uint8_t shortdepth = 8; @@ -363,7 +363,7 @@ gendata_h48k2_return_size: return H48_TABLESIZE(arg->h, 2); } -_static void +STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) { cube_t ccc; @@ -406,20 +406,20 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) } } -_static_inline uint8_t +STATIC_INLINE uint8_t get_esep_pval(const uint32_t *buf32, int64_t i, uint8_t k) { return (buf32[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); } -_static_inline void +STATIC_INLINE void set_esep_pval(uint32_t *buf32, int64_t i, uint8_t k, uint8_t val) { buf32[H48_INDEX(i, k)] = (buf32[H48_INDEX(i, k)] & (~H48_MASK(i, k))) | (val << H48_SHIFT(i, k)); } -_static_inline int8_t +STATIC_INLINE int8_t get_h48_bound(cube_t cube, uint32_t cdata, uint8_t h, uint8_t k, uint32_t *h48data) { 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 { uint64_t val; } kvpair_t; -_static void h48map_create(h48map_t *, uint64_t, uint64_t); -_static void h48map_clear(h48map_t *); -_static void h48map_destroy(h48map_t *); -_static uint64_t h48map_lookup(h48map_t *, uint64_t); -_static void h48map_insertmin(h48map_t *, uint64_t, uint64_t); -_static uint64_t h48map_value(h48map_t *, uint64_t); -_static kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); - -_static void +STATIC void h48map_create(h48map_t *, uint64_t, uint64_t); +STATIC void h48map_clear(h48map_t *); +STATIC void h48map_destroy(h48map_t *); +STATIC uint64_t h48map_lookup(h48map_t *, uint64_t); +STATIC void h48map_insertmin(h48map_t *, uint64_t, uint64_t); +STATIC uint64_t h48map_value(h48map_t *, uint64_t); +STATIC kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); + +STATIC void h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) { map->capacity = capacity; @@ -33,20 +33,20 @@ h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) h48map_clear(map); } -_static void +STATIC void h48map_clear(h48map_t *map) { memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); map->n = 0; } -_static void +STATIC void h48map_destroy(h48map_t *map) { free(map->table); } -_static_inline uint64_t +STATIC_INLINE uint64_t h48map_lookup(h48map_t *map, uint64_t x) { uint64_t hash, i; @@ -60,7 +60,7 @@ h48map_lookup(h48map_t *map, uint64_t x) return i; } -_static_inline void +STATIC_INLINE void h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) { uint64_t i, oldval, min; @@ -73,13 +73,13 @@ h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) map->table[i] = (key & MAP_KEYMASK) | (min << MAP_KEYSHIFT); } -_static_inline uint64_t +STATIC_INLINE uint64_t h48map_value(h48map_t *map, uint64_t key) { return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; } -_static kvpair_t +STATIC kvpair_t h48map_nextkvpair(h48map_t *map, uint64_t *p) { 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 { char *s; } dfsarg_solveh48stats_t; -_static uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint32_t); +STATIC uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint32_t); -_static void solve_h48_appendsolution(dfsarg_solveh48_t *); -_static_inline bool solve_h48_stop(dfsarg_solveh48_t *); -_static int64_t solve_h48_dfs(dfsarg_solveh48_t *); -_static int64_t solve_h48(cube_t, int8_t, int8_t, int8_t, uint8_t, uint8_t, const void *, char *); +STATIC void solve_h48_appendsolution(dfsarg_solveh48_t *); +STATIC_INLINE bool solve_h48_stop(dfsarg_solveh48_t *); +STATIC int64_t solve_h48_dfs(dfsarg_solveh48_t *); +STATIC int64_t solve_h48(cube_t, int8_t, int8_t, int8_t, uint8_t, uint8_t, const void *, char *); -_static int64_t solve_h48stats_dfs(dfsarg_solveh48stats_t *); -_static int64_t solve_h48stats(cube_t, int8_t, const void *, char [static 12]); +STATIC int64_t solve_h48stats_dfs(dfsarg_solveh48stats_t *); +STATIC int64_t solve_h48stats(cube_t, int8_t, const void *, char [static 12]); -_static uint32_t +STATIC uint32_t allowednextmove_h48(uint8_t *moves, uint8_t n, uint32_t h48branch) { - uint32_t result = _mm_allmoves; - if (h48branch & _mm_normalbranch) - result &= _mm_nohalfturns; + uint32_t result = MM_ALLMOVES; + if (h48branch & MM_NORMALBRANCH) + result &= MM_NOHALFTURNS; if (n < 1) return result; @@ -64,7 +64,7 @@ allowednextmove_h48(uint8_t *moves, uint8_t n, uint32_t h48branch) return result; } -_static void +STATIC void solve_h48_appendsolution(dfsarg_solveh48_t *arg) { int strl; @@ -89,13 +89,13 @@ solve_h48_appendsolution(dfsarg_solveh48_t *arg) (*arg->nsols)++; } -_static_inline bool +STATIC_INLINE bool solve_h48_stop(dfsarg_solveh48_t *arg) { uint32_t data, data_inv; int8_t bound; - arg->nissbranch = _mm_normal; + arg->nissbranch = MM_NORMAL; bound = get_h48_cdata(arg->cube, arg->cocsepdata, &data); if (bound + arg->nmoves + arg->npremoves > arg->depth) return true; @@ -109,18 +109,18 @@ solve_h48_stop(dfsarg_solveh48_t *arg) if (bound + arg->nmoves + arg->npremoves > arg->depth) return true; if (bound + arg->nmoves + arg->npremoves == arg->depth) - arg->nissbranch = _mm_inversebranch; + arg->nissbranch = MM_INVERSEBRANCH; bound = get_h48_bound(arg->inverse, data_inv, arg->h, arg->k, arg->h48data); if (bound + arg->nmoves + arg->npremoves > arg->depth) return true; if (bound + arg->nmoves + arg->npremoves == arg->depth) - arg->nissbranch = _mm_normalbranch; + arg->nissbranch = MM_NORMALBRANCH; return false; } -_static int64_t +STATIC int64_t solve_h48_dfs(dfsarg_solveh48_t *arg) { dfsarg_solveh48_t nextarg; @@ -144,7 +144,7 @@ solve_h48_dfs(dfsarg_solveh48_t *arg) nextarg = *arg; ret = 0; uint32_t allowed; - if(arg->nissbranch & _mm_inverse) { + if(arg->nissbranch & MM_INVERSE) { allowed = allowednextmove_h48(arg->premoves, arg->npremoves, arg->nissbranch); for (m = 0; m < 18; m++) { if(allowed & (1 << m)) { @@ -171,7 +171,7 @@ solve_h48_dfs(dfsarg_solveh48_t *arg) return ret; } -_static int64_t +STATIC int64_t solve_h48( cube_t cube, int8_t minmoves, @@ -219,7 +219,7 @@ each of the 12 h48 coordinates, one for each value of h from 0 to 11. The solutions array is filled with the length of the solutions. The solution array is therefore not a printable string. */ -_static int64_t +STATIC int64_t solve_h48stats_dfs(dfsarg_solveh48stats_t *arg) { const int64_t limit = 11; @@ -268,7 +268,7 @@ solve_h48stats_dfs(dfsarg_solveh48stats_t *arg) return 0; } -_static int64_t +STATIC int64_t solve_h48stats( cube_t cube, int8_t maxmoves, -- cgit v1.3