diff options
| -rw-r--r-- | src/arch/avx2.h | 8 | ||||
| -rw-r--r-- | src/arch/common.h | 8 | ||||
| -rw-r--r-- | src/arch/neon.h | 8 | ||||
| -rw-r--r-- | src/arch/portable.h | 8 | ||||
| -rw-r--r-- | src/core/cube.h | 2 | ||||
| -rw-r--r-- | src/nissy.c | 6 | ||||
| -rw-r--r-- | src/solvers/coord/gendata.h | 32 | ||||
| -rw-r--r-- | src/solvers/coord/utils.h | 3 | ||||
| -rw-r--r-- | src/solvers/h48/coordinate.h | 21 | ||||
| -rw-r--r-- | src/solvers/h48/coordinate_types_macros.h (renamed from src/solvers/h48/coordinate_macros.h) | 0 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_cocsep.h | 39 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_eoesep.h | 17 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 61 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_types_macros.h | 2 | ||||
| -rw-r--r-- | src/solvers/h48/h48.h | 4 | ||||
| -rw-r--r-- | src/solvers/h48/map.h | 31 | ||||
| -rw-r--r-- | src/solvers/h48/solve.h | 18 | ||||
| -rw-r--r-- | src/solvers/tables.h | 49 | ||||
| -rw-r--r-- | test/111_h48map/h48map_tests.c | 10 | ||||
| -rw-r--r-- | test/112_gendata_h48short/gendata_h48short_tests.c | 8 | ||||
| -rw-r--r-- | test/test.h | 2 | ||||
| -rw-r--r-- | tools/expected_distributions.h | 4 |
22 files changed, 182 insertions, 159 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h index b6ff510..ebcf84f 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h | |||
| @@ -23,7 +23,7 @@ popcount_u32(uint32_t x) | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | STATIC void | 25 | STATIC void |
| 26 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 26 | pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) |
| 27 | { | 27 | { |
| 28 | uint8_t aux[32]; | 28 | uint8_t aux[32]; |
| 29 | 29 | ||
| @@ -252,19 +252,19 @@ coord_esep(cube_t c) | |||
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | STATIC_INLINE void | 254 | STATIC_INLINE void |
| 255 | copy_corners(cube_t *dest, cube_t src) | 255 | copy_corners(cube_t dest[static 1], cube_t src) |
| 256 | { | 256 | { |
| 257 | *dest = _mm256_blend_epi32(*dest, src, 0x0F); | 257 | *dest = _mm256_blend_epi32(*dest, src, 0x0F); |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | STATIC_INLINE void | 260 | STATIC_INLINE void |
| 261 | copy_edges(cube_t *dest, cube_t src) | 261 | copy_edges(cube_t dest[static 1], cube_t src) |
| 262 | { | 262 | { |
| 263 | *dest = _mm256_blend_epi32(*dest, src, 0xF0); | 263 | *dest = _mm256_blend_epi32(*dest, src, 0xF0); |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | STATIC_INLINE void | 266 | STATIC_INLINE void |
| 267 | set_eo(cube_t *cube, int64_t eo) | 267 | set_eo(cube_t cube[static 1], int64_t eo) |
| 268 | { | 268 | { |
| 269 | int64_t eo12, eotop, eobot; | 269 | int64_t eo12, eotop, eobot; |
| 270 | __m256i veo; | 270 | __m256i veo; |
diff --git a/src/arch/common.h b/src/arch/common.h index 52e0fc7..5c1efde 100644 --- a/src/arch/common.h +++ b/src/arch/common.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | STATIC_INLINE int popcount_u32(uint32_t); | 1 | STATIC_INLINE int popcount_u32(uint32_t); |
| 2 | 2 | ||
| 3 | STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | 3 | STATIC void pieces(cube_t [static 1], uint8_t [static 8], uint8_t [static 12]); |
| 4 | STATIC_INLINE bool equal(cube_t, cube_t); | 4 | STATIC_INLINE bool equal(cube_t, cube_t); |
| 5 | STATIC_INLINE cube_t invertco(cube_t); | 5 | STATIC_INLINE cube_t invertco(cube_t); |
| 6 | STATIC_INLINE cube_t compose_edges(cube_t, cube_t); | 6 | STATIC_INLINE cube_t compose_edges(cube_t, cube_t); |
| @@ -14,9 +14,9 @@ STATIC_INLINE int64_t coord_cocsep(cube_t); | |||
| 14 | STATIC_INLINE int64_t coord_eo(cube_t); | 14 | STATIC_INLINE int64_t coord_eo(cube_t); |
| 15 | STATIC_INLINE int64_t coord_esep(cube_t); | 15 | STATIC_INLINE int64_t coord_esep(cube_t); |
| 16 | 16 | ||
| 17 | STATIC_INLINE void copy_corners(cube_t *, cube_t); | 17 | STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); |
| 18 | STATIC_INLINE void copy_edges(cube_t *, cube_t); | 18 | STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); |
| 19 | STATIC_INLINE void set_eo(cube_t *, int64_t); | 19 | STATIC_INLINE void set_eo(cube_t [static 1], int64_t); |
| 20 | STATIC_INLINE cube_t invcoord_esep(int64_t); | 20 | STATIC_INLINE cube_t invcoord_esep(int64_t); |
| 21 | 21 | ||
| 22 | STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); | 22 | STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); |
diff --git a/src/arch/neon.h b/src/arch/neon.h index 19f6f9d..d5f5f8b 100644 --- a/src/arch/neon.h +++ b/src/arch/neon.h | |||
| @@ -39,7 +39,7 @@ popcount_u32(uint32_t x) | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | STATIC void | 41 | STATIC void |
| 42 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 42 | pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) |
| 43 | { | 43 | { |
| 44 | // First 8 bytes of the corner vector are copied from the c array | 44 | // First 8 bytes of the corner vector are copied from the c array |
| 45 | vst1_u8(c, cube->corner); | 45 | vst1_u8(c, cube->corner); |
| @@ -287,19 +287,19 @@ coord_esep(cube_t c) | |||
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | STATIC_INLINE void | 289 | STATIC_INLINE void |
| 290 | copy_corners(cube_t *dst, cube_t src) | 290 | copy_corners(cube_t dst[static 1], cube_t src) |
| 291 | { | 291 | { |
| 292 | dst->corner = src.corner; | 292 | dst->corner = src.corner; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | STATIC_INLINE void | 295 | STATIC_INLINE void |
| 296 | copy_edges(cube_t *dst, cube_t src) | 296 | copy_edges(cube_t dst[static 1], cube_t src) |
| 297 | { | 297 | { |
| 298 | dst->edge = src.edge; | 298 | dst->edge = src.edge; |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | STATIC_INLINE void | 301 | STATIC_INLINE void |
| 302 | set_eo(cube_t *cube, int64_t eo) | 302 | set_eo(cube_t cube[static 1], int64_t eo) |
| 303 | { | 303 | { |
| 304 | // Temp array to store the NEON vector | 304 | // Temp array to store the NEON vector |
| 305 | uint8_t mem[16]; | 305 | uint8_t mem[16]; |
diff --git a/src/arch/portable.h b/src/arch/portable.h index b8c5211..4ac5fe7 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h | |||
| @@ -22,7 +22,7 @@ popcount_u32(uint32_t x) | |||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | STATIC void | 24 | STATIC void |
| 25 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 25 | pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) |
| 26 | { | 26 | { |
| 27 | memcpy(c, cube->corner, 8); | 27 | memcpy(c, cube->corner, 8); |
| 28 | memcpy(e, cube->edge, 12); | 28 | memcpy(e, cube->edge, 12); |
| @@ -227,19 +227,19 @@ coord_esep(cube_t c) | |||
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | STATIC_INLINE void | 229 | STATIC_INLINE void |
| 230 | copy_corners(cube_t *dest, cube_t src) | 230 | copy_corners(cube_t dest[static 1], cube_t src) |
| 231 | { | 231 | { |
| 232 | memcpy(&dest->corner, src.corner, sizeof(src.corner)); | 232 | memcpy(&dest->corner, src.corner, sizeof(src.corner)); |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | STATIC_INLINE void | 235 | STATIC_INLINE void |
| 236 | copy_edges(cube_t *dest, cube_t src) | 236 | copy_edges(cube_t dest[static 1], cube_t src) |
| 237 | { | 237 | { |
| 238 | memcpy(&dest->edge, src.edge, sizeof(src.edge)); | 238 | memcpy(&dest->edge, src.edge, sizeof(src.edge)); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | STATIC_INLINE void | 241 | STATIC_INLINE void |
| 242 | set_eo(cube_t *cube, int64_t eo) | 242 | set_eo(cube_t cube[static 1], int64_t eo) |
| 243 | { | 243 | { |
| 244 | uint8_t i, sum, flip; | 244 | uint8_t i, sum, flip; |
| 245 | 245 | ||
diff --git a/src/core/cube.h b/src/core/cube.h index ab5f181..7a68fb2 100644 --- a/src/core/cube.h +++ b/src/core/cube.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | STATIC cube_t solvecube(void); | 1 | STATIC cube_t solvedcube(void); |
| 2 | STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); | 2 | STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); |
| 3 | STATIC bool isconsistent(cube_t); | 3 | STATIC bool isconsistent(cube_t); |
| 4 | STATIC bool issolvable(cube_t); | 4 | STATIC bool issolvable(cube_t); |
diff --git a/src/nissy.c b/src/nissy.c index 431362d..e8a6550 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | long long parse_h48_solver( | 15 | long long parse_h48_solver( |
| 16 | const char *, uint8_t [static 1], uint8_t [static 1]); | 16 | const char *, uint8_t [static 1], uint8_t [static 1]); |
| 17 | STATIC bool checkdata(const char *, const tableinfo_t *); | 17 | STATIC bool checkdata(const char *, const tableinfo_t [static 1]); |
| 18 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], | 18 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], |
| 19 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); | 19 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); |
| 20 | STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); | 20 | STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); |
| @@ -66,11 +66,11 @@ parse_h48_solver_error: | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | STATIC bool | 68 | STATIC bool |
| 69 | checkdata(const char *buf, const tableinfo_t *info) | 69 | checkdata(const char *buf, const tableinfo_t info[static 1]) |
| 70 | { | 70 | { |
| 71 | uint64_t distr[INFO_DISTRIBUTION_LEN]; | 71 | uint64_t distr[INFO_DISTRIBUTION_LEN]; |
| 72 | 72 | ||
| 73 | if (info == NULL || my_strnlen(info->solver, INFO_SOLVER_STRLEN) | 73 | if (my_strnlen(info->solver, INFO_SOLVER_STRLEN) |
| 74 | == INFO_SOLVER_STRLEN) { | 74 | == INFO_SOLVER_STRLEN) { |
| 75 | LOG("checkdata: error reading table info\n"); | 75 | LOG("checkdata: error reading table info\n"); |
| 76 | return false; | 76 | return false; |
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h index 5819608..ca058b0 100644 --- a/src/solvers/coord/gendata.h +++ b/src/solvers/coord/gendata.h | |||
| @@ -1,10 +1,13 @@ | |||
| 1 | STATIC size_t gendata_coord(const coord_t *, void *); | 1 | STATIC size_t gendata_coord(const coord_t [static 1], void *); |
| 2 | STATIC int64_t gendata_coord_dispatch(const char *, void *); | 2 | STATIC int64_t gendata_coord_dispatch(const char *, void *); |
| 3 | STATIC tableinfo_t genptable_coord(const coord_t *, const void *, uint8_t *); | 3 | STATIC tableinfo_t genptable_coord( |
| 4 | const coord_t [static 1], const void *, uint8_t *); | ||
| 4 | STATIC void getdistribution_coord( | 5 | STATIC void getdistribution_coord( |
| 5 | const uint8_t *, const char *, uint64_t [static INFO_DISTRIBUTION_LEN]); | 6 | const uint8_t *, const char *, uint64_t [static INFO_DISTRIBUTION_LEN]); |
| 6 | STATIC uint8_t get_coord_pval(const coord_t *, const uint8_t *, uint64_t); | 7 | STATIC uint8_t get_coord_pval( |
| 7 | STATIC void set_coord_pval(const coord_t *, uint8_t *, uint64_t, uint8_t); | 8 | const coord_t [static 1], const uint8_t *, uint64_t); |
| 9 | STATIC void set_coord_pval( | ||
| 10 | const coord_t [static 1], uint8_t *, uint64_t, uint8_t); | ||
| 8 | 11 | ||
| 9 | STATIC int64_t | 12 | STATIC int64_t |
| 10 | gendata_coord_dispatch(const char *coordstr, void *buf) | 13 | gendata_coord_dispatch(const char *coordstr, void *buf) |
| @@ -22,7 +25,7 @@ gendata_coord_dispatch(const char *coordstr, void *buf) | |||
| 22 | } | 25 | } |
| 23 | 26 | ||
| 24 | STATIC size_t | 27 | STATIC size_t |
| 25 | gendata_coord(const coord_t *coord, void *buf) | 28 | gendata_coord(const coord_t coord[static 1], void *buf) |
| 26 | { | 29 | { |
| 27 | uint64_t coord_dsize, tablesize, ninfo; | 30 | uint64_t coord_dsize, tablesize, ninfo; |
| 28 | void *pruningbuf, *coord_data; | 31 | void *pruningbuf, *coord_data; |
| @@ -72,7 +75,11 @@ gendata_coord_return_size: | |||
| 72 | } | 75 | } |
| 73 | 76 | ||
| 74 | STATIC tableinfo_t | 77 | STATIC tableinfo_t |
| 75 | genptable_coord(const coord_t *coord, const void *data, uint8_t *table) | 78 | genptable_coord( |
| 79 | const coord_t coord[static 1], | ||
| 80 | const void *data, | ||
| 81 | uint8_t *table | ||
| 82 | ) | ||
| 76 | { | 83 | { |
| 77 | uint64_t tablesize, i, j, d, tot; | 84 | uint64_t tablesize, i, j, d, tot; |
| 78 | tableinfo_t info; | 85 | tableinfo_t info; |
| @@ -147,13 +154,22 @@ getdistribution_coord( | |||
| 147 | } | 154 | } |
| 148 | 155 | ||
| 149 | STATIC uint8_t | 156 | STATIC uint8_t |
| 150 | get_coord_pval(const coord_t *coord, const uint8_t *table, uint64_t i) | 157 | get_coord_pval( |
| 158 | const coord_t coord[static 1], | ||
| 159 | const uint8_t *table, | ||
| 160 | uint64_t i | ||
| 161 | ) | ||
| 151 | { | 162 | { |
| 152 | return (table[COORD_INDEX(i)] & COORD_MASK(i)) >> COORD_SHIFT(i); | 163 | return (table[COORD_INDEX(i)] & COORD_MASK(i)) >> COORD_SHIFT(i); |
| 153 | } | 164 | } |
| 154 | 165 | ||
| 155 | STATIC void | 166 | STATIC void |
| 156 | set_coord_pval(const coord_t *coord, uint8_t *table, uint64_t i, uint8_t val) | 167 | set_coord_pval( |
| 168 | const coord_t coord[static 1], | ||
| 169 | uint8_t *table, | ||
| 170 | uint64_t i, | ||
| 171 | uint8_t val | ||
| 172 | ) | ||
| 157 | { | 173 | { |
| 158 | table[COORD_INDEX(i)] = (table[COORD_INDEX(i)] & (~COORD_MASK(i))) | 174 | table[COORD_INDEX(i)] = (table[COORD_INDEX(i)] & (~COORD_MASK(i))) |
| 159 | | (val << COORD_SHIFT(i)); | 175 | | (val << COORD_SHIFT(i)); |
diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h index ab4aded..e9d0595 100644 --- a/src/solvers/coord/utils.h +++ b/src/solvers/coord/utils.h | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | STATIC coord_t *parse_coord(size_t n, const char [n]); | 1 | STATIC coord_t *parse_coord(size_t n, const char [n]); |
| 2 | STATIC uint8_t parse_axis(size_t n, const char [n]); | 2 | STATIC uint8_t parse_axis(size_t n, const char [n]); |
| 3 | STATIC void parse_coord_and_axis(size_t n, const char [n], coord_t **, uint8_t *); | 3 | STATIC void parse_coord_and_axis( |
| 4 | size_t n, const char [n], coord_t **, uint8_t *); | ||
| 4 | STATIC int64_t dataid_coord(const char *, char [static NISSY_DATAID_SIZE]); | 5 | STATIC int64_t dataid_coord(const char *, char [static NISSY_DATAID_SIZE]); |
| 5 | 6 | ||
| 6 | STATIC coord_t * | 7 | STATIC coord_t * |
diff --git a/src/solvers/h48/coordinate.h b/src/solvers/h48/coordinate.h index 6caac2a..eb08fd8 100644 --- a/src/solvers/h48/coordinate.h +++ b/src/solvers/h48/coordinate.h | |||
| @@ -1,12 +1,15 @@ | |||
| 1 | /* Macros defined in a separate file for easier testing */ | 1 | STATIC_INLINE int64_t coord_h48( |
| 2 | #include "coordinate_macros.h" | 2 | cube_t, const uint32_t [static COCSEP_TABLESIZE], uint8_t); |
| 3 | |||
| 4 | STATIC_INLINE int64_t coord_h48(cube_t, const uint32_t *, uint8_t); | ||
| 5 | STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); | 3 | STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); |
| 6 | STATIC_INLINE cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); | 4 | STATIC_INLINE cube_t invcoord_h48( |
| 5 | int64_t, const cube_t [static COCSEP_CLASSES], uint8_t); | ||
| 7 | 6 | ||
| 8 | STATIC_INLINE int64_t | 7 | STATIC_INLINE int64_t |
| 9 | coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) | 8 | coord_h48( |
| 9 | cube_t c, | ||
| 10 | const uint32_t cocsepdata[static COCSEP_TABLESIZE], | ||
| 11 | uint8_t h | ||
| 12 | ) | ||
| 10 | { | 13 | { |
| 11 | int64_t cocsep, coclass; | 14 | int64_t cocsep, coclass; |
| 12 | uint32_t data; | 15 | uint32_t data; |
| @@ -42,7 +45,11 @@ the given value, because it works up to symmetry. This means that the | |||
| 42 | returned cube is a transformed cube of one that gives the correct value. | 45 | returned cube is a transformed cube of one that gives the correct value. |
| 43 | */ | 46 | */ |
| 44 | STATIC_INLINE cube_t | 47 | STATIC_INLINE cube_t |
| 45 | invcoord_h48(int64_t i, const cube_t *crep, uint8_t h) | 48 | invcoord_h48( |
| 49 | int64_t i, | ||
| 50 | const cube_t crep[static COCSEP_CLASSES], | ||
| 51 | uint8_t h | ||
| 52 | ) | ||
| 46 | { | 53 | { |
| 47 | cube_t ret; | 54 | cube_t ret; |
| 48 | int64_t hh, coclass, ee, esep, eo; | 55 | int64_t hh, coclass, ee, esep, eo; |
diff --git a/src/solvers/h48/coordinate_macros.h b/src/solvers/h48/coordinate_types_macros.h index 04462d6..04462d6 100644 --- a/src/solvers/h48/coordinate_macros.h +++ b/src/solvers/h48/coordinate_types_macros.h | |||
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index bf67962..cda1608 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h | |||
| @@ -1,11 +1,15 @@ | |||
| 1 | STATIC_INLINE bool gendata_cocsep_get_visited(const uint8_t *, int64_t); | ||
| 2 | STATIC_INLINE void gendata_cocsep_set_visited(uint8_t *, int64_t); | ||
| 3 | |||
| 4 | STATIC size_t gendata_cocsep(char *, uint64_t *, cube_t *); | 1 | STATIC size_t gendata_cocsep(char *, uint64_t *, cube_t *); |
| 5 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); | 2 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [static 1]); |
| 6 | STATIC void getdistribution_cocsep(const uint32_t *, uint64_t [static 21]); | 3 | STATIC void getdistribution_cocsep( |
| 4 | const uint32_t [static COCSEP_TABLESIZE], uint64_t [static 21]); | ||
| 5 | |||
| 6 | STATIC_INLINE bool gendata_cocsep_get_visited( | ||
| 7 | const uint8_t [static COCSEP_VISITEDSIZE], int64_t); | ||
| 8 | STATIC_INLINE void gendata_cocsep_set_visited( | ||
| 9 | uint8_t [static COCSEP_VISITEDSIZE], int64_t); | ||
| 7 | 10 | ||
| 8 | STATIC_INLINE int8_t get_h48_cdata(cube_t, const uint32_t *, uint32_t *); | 11 | STATIC_INLINE int8_t get_h48_cdata( |
| 12 | cube_t, const uint32_t [static COCSEP_TABLESIZE], uint32_t *); | ||
| 9 | 13 | ||
| 10 | STATIC size_t | 14 | STATIC size_t |
| 11 | gendata_cocsep( | 15 | gendata_cocsep( |
| @@ -78,7 +82,7 @@ gendata_cocsep_return_size: | |||
| 78 | } | 82 | } |
| 79 | 83 | ||
| 80 | STATIC uint32_t | 84 | STATIC uint32_t |
| 81 | gendata_cocsep_dfs(cocsep_dfs_arg_t *arg) | 85 | gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1]) |
| 82 | { | 86 | { |
| 83 | uint8_t m; | 87 | uint8_t m; |
| 84 | uint32_t cc, class, ttrep, depth, olddepth, tinv; | 88 | uint32_t cc, class, ttrep, depth, olddepth, tinv; |
| @@ -133,7 +137,10 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t *arg) | |||
| 133 | } | 137 | } |
| 134 | 138 | ||
| 135 | STATIC void | 139 | STATIC void |
| 136 | getdistribution_cocsep(const uint32_t *table, uint64_t distr[static 21]) | 140 | getdistribution_cocsep( |
| 141 | const uint32_t table[static COCSEP_TABLESIZE], | ||
| 142 | uint64_t distr[static 21] | ||
| 143 | ) | ||
| 137 | { | 144 | { |
| 138 | size_t i; | 145 | size_t i; |
| 139 | 146 | ||
| @@ -144,19 +151,29 @@ getdistribution_cocsep(const uint32_t *table, uint64_t distr[static 21]) | |||
| 144 | } | 151 | } |
| 145 | 152 | ||
| 146 | STATIC_INLINE bool | 153 | STATIC_INLINE bool |
| 147 | gendata_cocsep_get_visited(const uint8_t *a, int64_t i) | 154 | gendata_cocsep_get_visited( |
| 155 | const uint8_t a[static COCSEP_VISITEDSIZE], | ||
| 156 | int64_t i | ||
| 157 | ) | ||
| 148 | { | 158 | { |
| 149 | return a[VISITED_IND(i)] & VISITED_MASK(i); | 159 | return a[VISITED_IND(i)] & VISITED_MASK(i); |
| 150 | } | 160 | } |
| 151 | 161 | ||
| 152 | STATIC_INLINE void | 162 | STATIC_INLINE void |
| 153 | gendata_cocsep_set_visited(uint8_t *a, int64_t i) | 163 | gendata_cocsep_set_visited( |
| 164 | uint8_t a[static COCSEP_VISITEDSIZE], | ||
| 165 | int64_t i | ||
| 166 | ) | ||
| 154 | { | 167 | { |
| 155 | a[VISITED_IND(i)] |= VISITED_MASK(i); | 168 | a[VISITED_IND(i)] |= VISITED_MASK(i); |
| 156 | } | 169 | } |
| 157 | 170 | ||
| 158 | STATIC_INLINE int8_t | 171 | STATIC_INLINE int8_t |
| 159 | get_h48_cdata(cube_t cube, const uint32_t *cocsepdata, uint32_t *cdata) | 172 | get_h48_cdata( |
| 173 | cube_t cube, | ||
| 174 | const uint32_t cocsepdata[static COCSEP_TABLESIZE], | ||
| 175 | uint32_t *cdata | ||
| 176 | ) | ||
| 160 | { | 177 | { |
| 161 | int64_t coord; | 178 | int64_t coord; |
| 162 | 179 | ||
diff --git a/src/solvers/h48/gendata_eoesep.h b/src/solvers/h48/gendata_eoesep.h index d887209..4bf5a84 100644 --- a/src/solvers/h48/gendata_eoesep.h +++ b/src/solvers/h48/gendata_eoesep.h | |||
| @@ -12,9 +12,11 @@ STATIC uint32_t gendata_eoesep_marksim(int64_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(const uint8_t *, int64_t); | 15 | STATIC uint8_t get_eoesep_pval( |
| 16 | const uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], int64_t); | ||
| 16 | STATIC uint8_t get_eoesep_pval_cube(const void *, cube_t); | 17 | STATIC uint8_t get_eoesep_pval_cube(const void *, cube_t); |
| 17 | STATIC void set_eoesep_pval(uint8_t *, int64_t, uint8_t); | 18 | STATIC void set_eoesep_pval( |
| 19 | uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], int64_t, uint8_t); | ||
| 18 | 20 | ||
| 19 | STATIC int64_t | 21 | STATIC int64_t |
| 20 | 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]) |
| @@ -247,7 +249,10 @@ gendata_eoesep_next( | |||
| 247 | } | 249 | } |
| 248 | 250 | ||
| 249 | STATIC uint8_t | 251 | STATIC uint8_t |
| 250 | get_eoesep_pval(const uint8_t *table, int64_t i) | 252 | get_eoesep_pval( |
| 253 | const uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], | ||
| 254 | int64_t i | ||
| 255 | ) | ||
| 251 | { | 256 | { |
| 252 | return (table[EOESEP_INDEX(i)] & EOESEP_MASK(i)) >> EOESEP_SHIFT(i); | 257 | return (table[EOESEP_INDEX(i)] & EOESEP_MASK(i)) >> EOESEP_SHIFT(i); |
| 253 | } | 258 | } |
| @@ -267,7 +272,11 @@ get_eoesep_pval_cube(const void *data, cube_t c) | |||
| 267 | } | 272 | } |
| 268 | 273 | ||
| 269 | STATIC void | 274 | STATIC void |
| 270 | set_eoesep_pval(uint8_t *table, int64_t i, uint8_t val) | 275 | set_eoesep_pval( |
| 276 | uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], | ||
| 277 | int64_t i, | ||
| 278 | uint8_t val | ||
| 279 | ) | ||
| 271 | { | 280 | { |
| 272 | table[EOESEP_INDEX(i)] = (table[EOESEP_INDEX(i)] & (~EOESEP_MASK(i))) | 281 | table[EOESEP_INDEX(i)] = (table[EOESEP_INDEX(i)] & (~EOESEP_MASK(i))) |
| 273 | | (val << EOESEP_SHIFT(i)); | 282 | | (val << EOESEP_SHIFT(i)); |
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 2d9a9f7..959264d 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -1,17 +1,17 @@ | |||
| 1 | STATIC uint64_t gendata_h48short(gendata_h48short_arg_t *); | 1 | STATIC uint64_t genddfggta_h48short(gendata_h48short_arg_t [static 1]); |
| 2 | STATIC int64_t gendata_h48(gendata_h48_arg_t *); | 2 | STATIC int64_t gendata_h48(gendata_h48_arg_t [static 1]); |
| 3 | STATIC void gendata_h48h0k4(gendata_h48_arg_t *); | 3 | STATIC void gendata_h48h0k4(gendata_h48_arg_t [static 1]); |
| 4 | STATIC void gendata_h48k2(gendata_h48_arg_t *); | 4 | STATIC void gendata_h48k2(gendata_h48_arg_t [static 1]); |
| 5 | STATIC void gendata_h48k2_realcoord(gendata_h48_arg_t *); | ||
| 6 | 5 | ||
| 7 | STATIC void * gendata_h48h0k4_runthread(void *); | 6 | STATIC void * gendata_h48h0k4_runthread(void *); |
| 8 | STATIC void * gendata_h48k2_runthread(void *); | 7 | STATIC void * gendata_h48k2_runthread(void *); |
| 9 | 8 | ||
| 10 | STATIC_INLINE void gendata_h48_mark_atomic(gendata_h48_mark_t *); | 9 | STATIC_INLINE void gendata_h48_mark_atomic(gendata_h48_mark_t [static 1]); |
| 11 | STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t *); | 10 | STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [static 1]); |
| 12 | STATIC_INLINE bool gendata_h48k2_dfs_stop(cube_t, int8_t, h48k2_dfs_arg_t *); | 11 | STATIC_INLINE bool gendata_h48k2_dfs_stop( |
| 13 | STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); | 12 | cube_t, int8_t, h48k2_dfs_arg_t [static 1]); |
| 14 | STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *); | 13 | STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t [static 1]); |
| 14 | STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t [static 1]); | ||
| 15 | STATIC void getdistribution_h48(const uint8_t *, | 15 | STATIC void getdistribution_h48(const uint8_t *, |
| 16 | uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t, uint8_t); | 16 | uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t, uint8_t); |
| 17 | 17 | ||
| @@ -28,7 +28,7 @@ STATIC_INLINE void set_h48_pval_atomic( | |||
| 28 | size_t gendata_h48_derive(uint8_t, const void *, void *); | 28 | size_t gendata_h48_derive(uint8_t, const void *, void *); |
| 29 | 29 | ||
| 30 | STATIC uint64_t | 30 | STATIC uint64_t |
| 31 | gendata_h48short(gendata_h48short_arg_t *arg) | 31 | gendata_h48short(gendata_h48short_arg_t arg[static 1]) |
| 32 | { | 32 | { |
| 33 | uint8_t i, m; | 33 | uint8_t i, m; |
| 34 | int64_t coord; | 34 | int64_t coord; |
| @@ -62,7 +62,7 @@ gendata_h48short(gendata_h48short_arg_t *arg) | |||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | STATIC int64_t | 64 | STATIC int64_t |
| 65 | gendata_h48(gendata_h48_arg_t *arg) | 65 | gendata_h48(gendata_h48_arg_t arg[static 1]) |
| 66 | { | 66 | { |
| 67 | uint64_t size, cocsepsize, h48size, fallbacksize, fallback2size, of; | 67 | uint64_t size, cocsepsize, h48size, fallbacksize, fallback2size, of; |
| 68 | long long r; | 68 | long long r; |
| @@ -70,11 +70,6 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 70 | tableinfo_t cocsepinfo, h48info, fallbackinfo; | 70 | tableinfo_t cocsepinfo, h48info, fallbackinfo; |
| 71 | gendata_h48_arg_t arg_h0k4; | 71 | gendata_h48_arg_t arg_h0k4; |
| 72 | 72 | ||
| 73 | if (arg == NULL) { | ||
| 74 | LOG("Error computing H48 data: arg is NULL.\n"); | ||
| 75 | return NISSY_ERROR_UNKNOWN; | ||
| 76 | } | ||
| 77 | |||
| 78 | cocsepsize = COCSEP_FULLSIZE; | 73 | cocsepsize = COCSEP_FULLSIZE; |
| 79 | h48size = INFOSIZE + H48_TABLESIZE(arg->h, arg->k); | 74 | h48size = INFOSIZE + H48_TABLESIZE(arg->h, arg->k); |
| 80 | fallbacksize = arg->k == 2 ? INFOSIZE + H48_TABLESIZE(0, 4) : 0; | 75 | fallbacksize = arg->k == 2 ? INFOSIZE + H48_TABLESIZE(0, 4) : 0; |
| @@ -107,8 +102,6 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 107 | 102 | ||
| 108 | if (arg->h == 0 && arg->k == 4) { | 103 | if (arg->h == 0 && arg->k == 4) { |
| 109 | gendata_h48h0k4(arg); | 104 | gendata_h48h0k4(arg); |
| 110 | } else if ((arg->h == 0 || arg->h == 11) && arg->k == 2) { | ||
| 111 | gendata_h48k2_realcoord(arg); | ||
| 112 | } else if (arg->k == 2) { | 105 | } else if (arg->k == 2) { |
| 113 | gendata_h48k2(arg); | 106 | gendata_h48k2(arg); |
| 114 | } else { | 107 | } else { |
| @@ -189,7 +182,7 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 189 | } | 182 | } |
| 190 | 183 | ||
| 191 | STATIC void | 184 | STATIC void |
| 192 | gendata_h48h0k4(gendata_h48_arg_t *arg) | 185 | gendata_h48h0k4(gendata_h48_arg_t arg[static 1]) |
| 193 | { | 186 | { |
| 194 | _Atomic uint8_t *table; | 187 | _Atomic uint8_t *table; |
| 195 | uint8_t val; | 188 | uint8_t val; |
| @@ -325,7 +318,7 @@ gendata_h48h0k4_runthread(void *arg) | |||
| 325 | } | 318 | } |
| 326 | 319 | ||
| 327 | STATIC void | 320 | STATIC void |
| 328 | gendata_h48k2(gendata_h48_arg_t *arg) | 321 | gendata_h48k2(gendata_h48_arg_t arg[static 1]) |
| 329 | { | 322 | { |
| 330 | static const uint8_t shortdepth = 8; | 323 | static const uint8_t shortdepth = 8; |
| 331 | static const uint64_t capacity = 10000019; | 324 | static const uint64_t capacity = 10000019; |
| @@ -483,7 +476,7 @@ gendata_h48k2_runthread(void *arg) | |||
| 483 | } | 476 | } |
| 484 | 477 | ||
| 485 | STATIC void | 478 | STATIC void |
| 486 | gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) | 479 | gendata_h48k2_dfs(h48k2_dfs_arg_t arg[static 1]) |
| 487 | { | 480 | { |
| 488 | int8_t d; | 481 | int8_t d; |
| 489 | uint8_t m[4]; | 482 | uint8_t m[4]; |
| @@ -562,7 +555,7 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) | |||
| 562 | } | 555 | } |
| 563 | 556 | ||
| 564 | STATIC_INLINE void | 557 | STATIC_INLINE void |
| 565 | gendata_h48_mark_atomic(gendata_h48_mark_t *arg) | 558 | gendata_h48_mark_atomic(gendata_h48_mark_t arg[static 1]) |
| 566 | { | 559 | { |
| 567 | uint8_t oldval, newval; | 560 | uint8_t oldval, newval; |
| 568 | int64_t coord, mutex; | 561 | int64_t coord, mutex; |
| @@ -582,7 +575,7 @@ gendata_h48_mark_atomic(gendata_h48_mark_t *arg) | |||
| 582 | } | 575 | } |
| 583 | 576 | ||
| 584 | STATIC_INLINE void | 577 | STATIC_INLINE void |
| 585 | gendata_h48_mark(gendata_h48_mark_t *arg) | 578 | gendata_h48_mark(gendata_h48_mark_t arg[static 1]) |
| 586 | { | 579 | { |
| 587 | uint8_t oldval, newval; | 580 | uint8_t oldval, newval; |
| 588 | int64_t coord, mutex; | 581 | int64_t coord, mutex; |
| @@ -599,7 +592,7 @@ gendata_h48_mark(gendata_h48_mark_t *arg) | |||
| 599 | } | 592 | } |
| 600 | 593 | ||
| 601 | STATIC_INLINE bool | 594 | STATIC_INLINE bool |
| 602 | gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) | 595 | gendata_h48k2_dfs_stop(cube_t cube, int8_t d, h48k2_dfs_arg_t arg[static 1]) |
| 603 | { | 596 | { |
| 604 | uint64_t val; | 597 | uint64_t val; |
| 605 | int64_t coord, mutex; | 598 | int64_t coord, mutex; |
| @@ -613,7 +606,7 @@ gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) | |||
| 613 | pthread_mutex_lock(arg->table_mutex[mutex]); | 606 | pthread_mutex_lock(arg->table_mutex[mutex]); |
| 614 | oldval = get_h48_pval(arg->table, coord, arg->k); | 607 | oldval = get_h48_pval(arg->table, coord, arg->k); |
| 615 | pthread_mutex_unlock(arg->table_mutex[mutex]); | 608 | pthread_mutex_unlock(arg->table_mutex[mutex]); |
| 616 | return oldval <= depth; | 609 | return oldval <= d; |
| 617 | } else { | 610 | } else { |
| 618 | /* With 0 < k < 11 we do not have a "real coordinate". | 611 | /* With 0 < k < 11 we do not have a "real coordinate". |
| 619 | The best we can do is checking if we backtracked to | 612 | The best we can do is checking if we backtracked to |
| @@ -624,22 +617,8 @@ gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) | |||
| 624 | } | 617 | } |
| 625 | } | 618 | } |
| 626 | 619 | ||
| 627 | STATIC void | ||
| 628 | gendata_h48k2_realcoord(gendata_h48_arg_t *arg) | ||
| 629 | { | ||
| 630 | /* TODO */ | ||
| 631 | gendata_h48k2(arg); | ||
| 632 | } | ||
| 633 | |||
| 634 | STATIC void * | ||
| 635 | gendata_h48k2_realcoord_runthread(void *arg) | ||
| 636 | { | ||
| 637 | /* TODO */ | ||
| 638 | return NULL; | ||
| 639 | } | ||
| 640 | |||
| 641 | STATIC tableinfo_t | 620 | STATIC tableinfo_t |
| 642 | makeinfo_h48k2(gendata_h48_arg_t *arg) | 621 | makeinfo_h48k2(gendata_h48_arg_t arg[static 1]) |
| 643 | { | 622 | { |
| 644 | tableinfo_t info; | 623 | tableinfo_t info; |
| 645 | 624 | ||
diff --git a/src/solvers/h48/gendata_types_macros.h b/src/solvers/h48/gendata_types_macros.h index ec6576a..11940d8 100644 --- a/src/solvers/h48/gendata_types_macros.h +++ b/src/solvers/h48/gendata_types_macros.h | |||
| @@ -33,7 +33,7 @@ | |||
| 33 | /* | 33 | /* |
| 34 | TODO: This loop over similar h48 coordinates can be improved by only | 34 | TODO: This loop over similar h48 coordinates can be improved by only |
| 35 | transforming edges, but we need to compose transformations (i.e. conjugate | 35 | transforming edges, but we need to compose transformations (i.e. conjugate |
| 36 | _t by _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 | int64_t VAR_COCSEP = coord_cocsep(ARG_CUBE); \ |
diff --git a/src/solvers/h48/h48.h b/src/solvers/h48/h48.h index d5a67ef..0cfa773 100644 --- a/src/solvers/h48/h48.h +++ b/src/solvers/h48/h48.h | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #include "coordinate_types_macros.h" | ||
| 2 | #include "map_types_macros.h" | ||
| 3 | #include "gendata_types_macros.h" | ||
| 1 | #include "coordinate.h" | 4 | #include "coordinate.h" |
| 2 | #include "map.h" | 5 | #include "map.h" |
| 3 | #include "gendata_types_macros.h" | ||
| 4 | #include "gendata_cocsep.h" | 6 | #include "gendata_cocsep.h" |
| 5 | #include "gendata_eoesep.h" | 7 | #include "gendata_eoesep.h" |
| 6 | #include "gendata_h48.h" | 8 | #include "gendata_h48.h" |
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h index e6903ce..7718794 100644 --- a/src/solvers/h48/map.h +++ b/src/solvers/h48/map.h | |||
| @@ -1,16 +1,13 @@ | |||
| 1 | /* Type definitions and macros are in a separate file for easier testing */ | 1 | STATIC void h48map_create(h48map_t [static 1], uint64_t, uint64_t); |
| 2 | #include "map_types_macros.h" | 2 | STATIC void h48map_clear(h48map_t [static 1]); |
| 3 | 3 | STATIC void h48map_destroy(h48map_t [static 1]); | |
| 4 | STATIC void h48map_create(h48map_t *, uint64_t, uint64_t); | 4 | STATIC uint64_t h48map_lookup(h48map_t [static 1], uint64_t); |
| 5 | STATIC void h48map_clear(h48map_t *); | 5 | STATIC void h48map_insertmin(h48map_t [static 1], uint64_t, uint64_t); |
| 6 | STATIC void h48map_destroy(h48map_t *); | 6 | STATIC uint64_t h48map_value(h48map_t [static 1], uint64_t); |
| 7 | STATIC uint64_t h48map_lookup(h48map_t *, uint64_t); | 7 | STATIC kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); |
| 8 | STATIC void h48map_insertmin(h48map_t *, uint64_t, uint64_t); | ||
| 9 | STATIC uint64_t h48map_value(h48map_t *, uint64_t); | ||
| 10 | STATIC kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); | ||
| 11 | 8 | ||
| 12 | STATIC void | 9 | STATIC void |
| 13 | h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) | 10 | h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) |
| 14 | { | 11 | { |
| 15 | map->capacity = capacity; | 12 | map->capacity = capacity; |
| 16 | map->randomizer = randomizer; | 13 | map->randomizer = randomizer; |
| @@ -20,20 +17,20 @@ h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) | |||
| 20 | } | 17 | } |
| 21 | 18 | ||
| 22 | STATIC void | 19 | STATIC void |
| 23 | h48map_clear(h48map_t *map) | 20 | h48map_clear(h48map_t map[static 1]) |
| 24 | { | 21 | { |
| 25 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); | 22 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); |
| 26 | map->n = 0; | 23 | map->n = 0; |
| 27 | } | 24 | } |
| 28 | 25 | ||
| 29 | STATIC void | 26 | STATIC void |
| 30 | h48map_destroy(h48map_t *map) | 27 | h48map_destroy(h48map_t map[static 1]) |
| 31 | { | 28 | { |
| 32 | free(map->table); | 29 | free(map->table); |
| 33 | } | 30 | } |
| 34 | 31 | ||
| 35 | STATIC_INLINE uint64_t | 32 | STATIC_INLINE uint64_t |
| 36 | h48map_lookup(h48map_t *map, uint64_t x) | 33 | h48map_lookup(h48map_t map[static 1], uint64_t x) |
| 37 | { | 34 | { |
| 38 | uint64_t hash, i; | 35 | uint64_t hash, i; |
| 39 | 36 | ||
| @@ -47,7 +44,7 @@ h48map_lookup(h48map_t *map, uint64_t x) | |||
| 47 | } | 44 | } |
| 48 | 45 | ||
| 49 | STATIC_INLINE void | 46 | STATIC_INLINE void |
| 50 | h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) | 47 | h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val) |
| 51 | { | 48 | { |
| 52 | uint64_t i, oldval, min; | 49 | uint64_t i, oldval, min; |
| 53 | 50 | ||
| @@ -60,13 +57,13 @@ h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) | |||
| 60 | } | 57 | } |
| 61 | 58 | ||
| 62 | STATIC_INLINE uint64_t | 59 | STATIC_INLINE uint64_t |
| 63 | h48map_value(h48map_t *map, uint64_t key) | 60 | h48map_value(h48map_t map[static 1], uint64_t key) |
| 64 | { | 61 | { |
| 65 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; | 62 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; |
| 66 | } | 63 | } |
| 67 | 64 | ||
| 68 | STATIC kvpair_t | 65 | STATIC kvpair_t |
| 69 | h48map_nextkvpair(h48map_t *map, uint64_t *p) | 66 | h48map_nextkvpair(h48map_t map[static 1], uint64_t p[static 1]) |
| 70 | { | 67 | { |
| 71 | kvpair_t kv; | 68 | kvpair_t kv; |
| 72 | uint64_t pair; | 69 | uint64_t pair; |
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index dbd15bb..dcec5a4 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -46,18 +46,18 @@ typedef struct { | |||
| 46 | int8_t *shortest_sol; | 46 | int8_t *shortest_sol; |
| 47 | } dfsarg_solve_h48_maketasks_t; | 47 | } dfsarg_solve_h48_maketasks_t; |
| 48 | 48 | ||
| 49 | STATIC_INLINE bool solve_h48_stop(dfsarg_solve_h48_t *); | 49 | STATIC_INLINE bool solve_h48_stop(dfsarg_solve_h48_t [static 1]); |
| 50 | STATIC int64_t solve_h48_maketasks( | 50 | STATIC int64_t solve_h48_maketasks( |
| 51 | dfsarg_solve_h48_t *, dfsarg_solve_h48_maketasks_t *, | 51 | dfsarg_solve_h48_t [static 1], dfsarg_solve_h48_maketasks_t [static 1], |
| 52 | solve_h48_task_t [static STARTING_CUBES], int *); | 52 | solve_h48_task_t [static STARTING_CUBES], int [static 1]); |
| 53 | STATIC void *solve_h48_runthread(void *); | 53 | STATIC void *solve_h48_runthread(void *); |
| 54 | STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t *); | 54 | STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t [static 1]); |
| 55 | STATIC int64_t solve_h48(cube_t, int8_t, int8_t, uint64_t, int8_t, int8_t, | 55 | STATIC int64_t solve_h48(cube_t, int8_t, int8_t, uint64_t, int8_t, int8_t, |
| 56 | uint64_t, const void *, size_t n, char [n], | 56 | uint64_t, const void *, size_t n, char [n], |
| 57 | long long [static NISSY_SIZE_SOLVE_STATS]); | 57 | long long [static NISSY_SIZE_SOLVE_STATS]); |
| 58 | 58 | ||
| 59 | STATIC_INLINE bool | 59 | STATIC_INLINE bool |
| 60 | solve_h48_stop(dfsarg_solve_h48_t *arg) | 60 | solve_h48_stop(dfsarg_solve_h48_t arg[static 1]) |
| 61 | { | 61 | { |
| 62 | uint32_t data, data_inv; | 62 | uint32_t data, data_inv; |
| 63 | int64_t coord; | 63 | int64_t coord; |
| @@ -145,7 +145,7 @@ solve_h48_stop(dfsarg_solve_h48_t *arg) | |||
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | STATIC int64_t | 147 | STATIC int64_t |
| 148 | solve_h48_dfs(dfsarg_solve_h48_t *arg) | 148 | solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) |
| 149 | { | 149 | { |
| 150 | int64_t ret, n; | 150 | int64_t ret, n; |
| 151 | uint8_t m, nm, lbn, lbi; | 151 | uint8_t m, nm, lbn, lbi; |
| @@ -261,10 +261,10 @@ solve_h48_runthread(void *arg) | |||
| 261 | 261 | ||
| 262 | STATIC int64_t | 262 | STATIC int64_t |
| 263 | solve_h48_maketasks( | 263 | solve_h48_maketasks( |
| 264 | dfsarg_solve_h48_t *solve_arg, | 264 | dfsarg_solve_h48_t solve_arg[static 1], |
| 265 | dfsarg_solve_h48_maketasks_t *maketasks_arg, | 265 | dfsarg_solve_h48_maketasks_t maketasks_arg[static 1], |
| 266 | solve_h48_task_t tasks[static STARTING_CUBES], | 266 | solve_h48_task_t tasks[static STARTING_CUBES], |
| 267 | int *ntasks | 267 | int ntasks[static 1] |
| 268 | ) | 268 | ) |
| 269 | { | 269 | { |
| 270 | int r; | 270 | int r; |
diff --git a/src/solvers/tables.h b/src/solvers/tables.h index 65e7606..db888b5 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h | |||
| @@ -1,11 +1,13 @@ | |||
| 1 | STATIC uint64_t read_unaligned_u64(const char *); | 1 | STATIC uint64_t read_unaligned_u64(const char [static sizeof(uint64_t)]); |
| 2 | STATIC void write_unaligned_u64(char *, uint64_t); | 2 | STATIC void write_unaligned_u64(char [static sizeof(uint64_t)], uint64_t); |
| 3 | STATIC int64_t readtableinfo(uint64_t, const char *, tableinfo_t *); | 3 | STATIC int64_t readtableinfo(size_t n, const char [n], tableinfo_t [static 1]); |
| 4 | STATIC int64_t readtableinfo_n(uint64_t, const char *, uint8_t, tableinfo_t *); | 4 | STATIC int64_t readtableinfo_n( |
| 5 | STATIC int64_t writetableinfo(const tableinfo_t *, uint64_t, char *); | 5 | size_t n, const char [n], uint8_t, tableinfo_t [static 1]); |
| 6 | STATIC int64_t writetableinfo( | ||
| 7 | const tableinfo_t [static 1], size_t n, char [n]); | ||
| 6 | 8 | ||
| 7 | STATIC uint64_t | 9 | STATIC uint64_t |
| 8 | read_unaligned_u64(const char *buf) | 10 | read_unaligned_u64(const char buf[static sizeof(uint64_t)]) |
| 9 | { | 11 | { |
| 10 | uint64_t ret; | 12 | uint64_t ret; |
| 11 | 13 | ||
| @@ -15,13 +17,17 @@ read_unaligned_u64(const char *buf) | |||
| 15 | } | 17 | } |
| 16 | 18 | ||
| 17 | STATIC void | 19 | STATIC void |
| 18 | write_unaligned_u64(char *buf, uint64_t x) | 20 | write_unaligned_u64(char buf[static sizeof(uint64_t)], uint64_t x) |
| 19 | { | 21 | { |
| 20 | memcpy(buf, &x, sizeof(uint64_t)); | 22 | memcpy(buf, &x, sizeof(uint64_t)); |
| 21 | } | 23 | } |
| 22 | 24 | ||
| 23 | STATIC int64_t | 25 | STATIC int64_t |
| 24 | readtableinfo(uint64_t buf_size, const char *buf, tableinfo_t *info) | 26 | readtableinfo( |
| 27 | size_t buf_size, | ||
| 28 | const char buf[buf_size], | ||
| 29 | tableinfo_t info[static 1] | ||
| 30 | ) | ||
| 25 | { | 31 | { |
| 26 | size_t i; | 32 | size_t i; |
| 27 | 33 | ||
| @@ -37,11 +43,6 @@ readtableinfo(uint64_t buf_size, const char *buf, tableinfo_t *info) | |||
| 37 | return NISSY_ERROR_BUFFER_SIZE; | 43 | return NISSY_ERROR_BUFFER_SIZE; |
| 38 | } | 44 | } |
| 39 | 45 | ||
| 40 | if (info == NULL) { | ||
| 41 | LOG("Error reading table info: info struct is NULL\n"); | ||
| 42 | return NISSY_ERROR_UNKNOWN; | ||
| 43 | } | ||
| 44 | |||
| 45 | for (i = 0; i < INFO_DISTRIBUTION_LEN; i++) | 46 | for (i = 0; i < INFO_DISTRIBUTION_LEN; i++) |
| 46 | info->distribution[i] = read_unaligned_u64(OFFSET(buf, | 47 | info->distribution[i] = read_unaligned_u64(OFFSET(buf, |
| 47 | INFO_OFFSET_DISTRIBUTION + i * sizeof(uint64_t))); | 48 | INFO_OFFSET_DISTRIBUTION + i * sizeof(uint64_t))); |
| @@ -67,10 +68,10 @@ readtableinfo(uint64_t buf_size, const char *buf, tableinfo_t *info) | |||
| 67 | 68 | ||
| 68 | STATIC int64_t | 69 | STATIC int64_t |
| 69 | readtableinfo_n( | 70 | readtableinfo_n( |
| 70 | uint64_t buf_size, | 71 | size_t buf_size, |
| 71 | const char *buf, | 72 | const char buf[buf_size], |
| 72 | uint8_t n, | 73 | uint8_t n, |
| 73 | tableinfo_t *info | 74 | tableinfo_t info[static 1] |
| 74 | ) | 75 | ) |
| 75 | { | 76 | { |
| 76 | int64_t ret; | 77 | int64_t ret; |
| @@ -83,22 +84,16 @@ readtableinfo_n( | |||
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | STATIC int64_t | 86 | STATIC int64_t |
| 86 | writetableinfo(const tableinfo_t *info, uint64_t data_size, char *buf) | 87 | writetableinfo( |
| 88 | const tableinfo_t info[static 1], | ||
| 89 | size_t data_size, | ||
| 90 | char buf[data_size] | ||
| 91 | ) | ||
| 87 | { | 92 | { |
| 88 | size_t i; | 93 | size_t i; |
| 89 | bool end; | 94 | bool end; |
| 90 | char *c; | 95 | char *c; |
| 91 | 96 | ||
| 92 | if (buf == NULL) { | ||
| 93 | LOG("Error writing table: buffer is NULL\n"); | ||
| 94 | return NISSY_ERROR_NULL_POINTER; | ||
| 95 | } | ||
| 96 | |||
| 97 | if (info == NULL) { | ||
| 98 | LOG("Error writing table info: provided info is NULL\n"); | ||
| 99 | return NISSY_ERROR_UNKNOWN; | ||
| 100 | } | ||
| 101 | |||
| 102 | if (data_size < info->fullsize) { | 97 | if (data_size < info->fullsize) { |
| 103 | LOG("Error writing table: buffer size is too small " | 98 | LOG("Error writing table: buffer size is too small " |
| 104 | "(given %" PRId64 " but table requires %" PRId64 ")\n", | 99 | "(given %" PRId64 " but table requires %" PRId64 ")\n", |
diff --git a/test/111_h48map/h48map_tests.c b/test/111_h48map/h48map_tests.c index 7fdfb3d..927b157 100644 --- a/test/111_h48map/h48map_tests.c +++ b/test/111_h48map/h48map_tests.c | |||
| @@ -2,11 +2,11 @@ | |||
| 2 | 2 | ||
| 3 | #define MAXPOS 1000 | 3 | #define MAXPOS 1000 |
| 4 | 4 | ||
| 5 | void h48map_create(h48map_t *, uint64_t, uint64_t); | 5 | void h48map_create(h48map_t [static 1], uint64_t, uint64_t); |
| 6 | void h48map_destroy(h48map_t *); | 6 | void h48map_destroy(h48map_t [static 1]); |
| 7 | void h48map_insertmin(h48map_t *, uint64_t, uint64_t); | 7 | void h48map_insertmin(h48map_t [static 1], uint64_t, uint64_t); |
| 8 | uint64_t h48map_value(h48map_t *, uint64_t); | 8 | uint64_t h48map_value(h48map_t [static 1], uint64_t); |
| 9 | kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); | 9 | kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); |
| 10 | 10 | ||
| 11 | char str[STRLENMAX]; | 11 | char str[STRLENMAX]; |
| 12 | 12 | ||
diff --git a/test/112_gendata_h48short/gendata_h48short_tests.c b/test/112_gendata_h48short/gendata_h48short_tests.c index b6ff00e..2ed42c1 100644 --- a/test/112_gendata_h48short/gendata_h48short_tests.c +++ b/test/112_gendata_h48short/gendata_h48short_tests.c | |||
| @@ -2,11 +2,11 @@ | |||
| 2 | 2 | ||
| 3 | #define MAXPOS 200 | 3 | #define MAXPOS 200 |
| 4 | 4 | ||
| 5 | void h48map_create(h48map_t *, uint64_t, uint64_t); | 5 | void h48map_create(h48map_t [static 1], uint64_t, uint64_t); |
| 6 | void h48map_destroy(h48map_t *); | 6 | void h48map_destroy(h48map_t [static 1]); |
| 7 | kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); | 7 | kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); |
| 8 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 8 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 9 | uint64_t gendata_h48short(gendata_h48short_arg_t *); | 9 | uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); |
| 10 | 10 | ||
| 11 | char str[STRLENMAX]; | 11 | char str[STRLENMAX]; |
| 12 | 12 | ||
diff --git a/test/test.h b/test/test.h index 8c117cb..e753977 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include "../src/arch/arch.h" | 12 | #include "../src/arch/arch.h" |
| 13 | #include "../src/solvers/solutions_types_macros.h" | 13 | #include "../src/solvers/solutions_types_macros.h" |
| 14 | #include "../src/solvers/tables_types_macros.h" | 14 | #include "../src/solvers/tables_types_macros.h" |
| 15 | #include "../src/solvers/h48/coordinate_macros.h" | 15 | #include "../src/solvers/h48/coordinate_types_macros.h" |
| 16 | #include "../src/solvers/h48/map_types_macros.h" | 16 | #include "../src/solvers/h48/map_types_macros.h" |
| 17 | #include "../src/solvers/h48/gendata_types_macros.h" | 17 | #include "../src/solvers/h48/gendata_types_macros.h" |
| 18 | #include "../src/solvers/coord/types_macros.h" | 18 | #include "../src/solvers/coord/types_macros.h" |
diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h index 60e7500..039e4d4 100644 --- a/tools/expected_distributions.h +++ b/tools/expected_distributions.h | |||
| @@ -167,7 +167,7 @@ check_table(uint64_t *exp, tableinfo_t *info) | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | static bool | 169 | static bool |
| 170 | check_cocsep(uint64_t data_size, const void *data) | 170 | check_cocsep(size_t data_size, const void *data) |
| 171 | { | 171 | { |
| 172 | tableinfo_t info; | 172 | tableinfo_t info; |
| 173 | 173 | ||
| @@ -189,7 +189,7 @@ unknown_h48(uint8_t h, uint8_t k) | |||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | STATIC bool | 191 | STATIC bool |
| 192 | check_distribution(const char *solver, uint64_t data_size, const void *data) | 192 | check_distribution(const char *solver, size_t data_size, const void *data) |
| 193 | { | 193 | { |
| 194 | const char *str; | 194 | const char *str; |
| 195 | tableinfo_t info = {0}; | 195 | tableinfo_t info = {0}; |
