aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-07-29 12:12:43 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-07-29 12:12:43 +0200
commitea0387796a349c91032fbcb10f50c6ad8607b0f6 (patch)
treeaed484690d24c0c28c7695d4b5389f2e3c341b96 /src
parent52c21640508c3fc668107778ae027ff4428ebd89 (diff)
downloadnissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.tar.gz
nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.zip
All coordinates unsigned
Diffstat (limited to 'src')
-rw-r--r--src/arch/avx2.h60
-rw-r--r--src/arch/common.h36
-rw-r--r--src/arch/neon.h59
-rw-r--r--src/arch/portable.h32
-rw-r--r--src/core/cube.h24
-rw-r--r--src/solvers/coord/dr.h8
-rw-r--r--src/solvers/coord/dreo.h6
-rw-r--r--src/solvers/coord/eo.h2
-rw-r--r--src/solvers/coord/gendata.h2
-rw-r--r--src/solvers/h48/coordinate.h28
-rw-r--r--src/solvers/h48/coordinate_types_macros.h2
-rw-r--r--src/solvers/h48/gendata_cocsep.h12
-rw-r--r--src/solvers/h48/gendata_eoesep.h42
-rw-r--r--src/solvers/h48/gendata_h48.h42
-rw-r--r--src/solvers/h48/gendata_types_macros.h10
-rw-r--r--src/solvers/h48/map.h2
-rw-r--r--src/solvers/h48/solve.h10
-rw-r--r--src/utils/constants.h18
-rw-r--r--src/utils/math.h39
19 files changed, 215 insertions, 219 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index 7764c6b..24c8280 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -25,8 +25,8 @@
25#define SOLVED_CUBE _mm256_set_epi64x(SOLVED_H, SOLVED_L, 0, SOLVED_L) 25#define SOLVED_CUBE _mm256_set_epi64x(SOLVED_H, SOLVED_L, 0, SOLVED_L)
26 26
27 27
28STATIC_INLINE int64_t permtoindex_8x8(int64_t); 28STATIC_INLINE uint64_t permtoindex_8x8(int64_t);
29STATIC_INLINE int64_t indextoperm_8x8(int64_t); 29STATIC_INLINE int64_t indextoperm_8x8(uint64_t);
30 30
31STATIC_INLINE int 31STATIC_INLINE int
32popcount_u32(uint32_t x) 32popcount_u32(uint32_t x)
@@ -144,11 +144,11 @@ inverse(cube_t c)
144 return invertco(ret); 144 return invertco(ret);
145} 145}
146 146
147STATIC_INLINE int64_t 147STATIC_INLINE uint64_t
148coord_co(cube_t c) 148coord_co(cube_t c)
149{ 149{
150 cube_t co; 150 cube_t co;
151 int64_t mem[4], ret, i, p; 151 uint64_t mem[4], ret, i, p;
152 152
153 co = _mm256_and_si256(c, CO2_AVX2); 153 co = _mm256_and_si256(c, CO2_AVX2);
154 _mm256_storeu_si256((__m256i *)mem, co); 154 _mm256_storeu_si256((__m256i *)mem, co);
@@ -161,15 +161,15 @@ coord_co(cube_t c)
161} 161}
162 162
163STATIC_INLINE cube_t 163STATIC_INLINE cube_t
164invcoord_co(int64_t coord) 164invcoord_co(uint64_t coord)
165{ 165{
166 int64_t i, c, p, co, mem[4] = {0}; 166 uint64_t i, c, p, co, mem[4] = {0};
167 cube_t cube, cc; 167 cube_t cube, cc;
168 168
169 for (i = 0, p = 0, c = coord; i < 8; i++, c /= 3) { 169 for (i = 0, p = 0, c = coord; i < 8; i++, c /= 3) {
170 co = i == 7 ? ((3 - (p % 3)) % 3) : (c % 3); 170 co = i == 7 ? ((3 - (p % 3)) % 3) : (c % 3);
171 p += co; 171 p += co;
172 mem[0] |= (int64_t)(i + (co << COSHIFT)) << (int64_t)(8 * i); 172 mem[0] |= (uint64_t)(i + (co << COSHIFT)) << (uint64_t)(8 * i);
173 } 173 }
174 174
175 cc = _mm256_loadu_si256((const __m256i *)mem); 175 cc = _mm256_loadu_si256((const __m256i *)mem);
@@ -179,43 +179,43 @@ invcoord_co(int64_t coord)
179 return cube; 179 return cube;
180} 180}
181 181
182STATIC_INLINE int64_t 182STATIC_INLINE uint64_t
183coord_csep(cube_t c) 183coord_csep(cube_t c)
184{ 184{
185 cube_t cp, shifted; 185 cube_t cp, shifted;
186 int64_t mask; 186 int mask;
187 187
188 cp = _mm256_and_si256(c, CP_AVX2); 188 cp = _mm256_and_si256(c, CP_AVX2);
189 shifted = _mm256_slli_epi32(cp, 5); 189 shifted = _mm256_slli_epi32(cp, 5);
190 mask = _mm256_movemask_epi8(shifted); 190 mask = _mm256_movemask_epi8(shifted);
191 191
192 return mask & 0x7F; 192 return (uint64_t)(mask & 0x7F);
193} 193}
194 194
195STATIC_INLINE int64_t 195STATIC_INLINE uint64_t
196coord_cocsep(cube_t c) 196coord_cocsep(cube_t c)
197{ 197{
198 return (coord_co(c) << 7) + coord_csep(c); 198 return (coord_co(c) << UINT8_C(7)) + coord_csep(c);
199} 199}
200 200
201STATIC_INLINE int64_t 201STATIC_INLINE uint64_t
202coord_eo(cube_t c) 202coord_eo(cube_t c)
203{ 203{
204 cube_t eo, shifted; 204 cube_t eo, shifted;
205 int64_t mask; 205 int mask;
206 206
207 eo = _mm256_and_si256(c, EO_AVX2); 207 eo = _mm256_and_si256(c, EO_AVX2);
208 shifted = _mm256_slli_epi32(eo, 3); 208 shifted = _mm256_slli_epi32(eo, 3);
209 mask = _mm256_movemask_epi8(shifted); 209 mask = _mm256_movemask_epi8(shifted);
210 210
211 return mask >> 17; 211 return (uint64_t)(mask >> 17);
212} 212}
213 213
214STATIC_INLINE int64_t 214STATIC_INLINE uint64_t
215coord_esep(cube_t c) 215coord_esep(cube_t c)
216{ 216{
217 cube_t ep; 217 cube_t ep;
218 int64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; 218 uint64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1;
219 219
220 ep = _mm256_and_si256(c, EP_AVX2); 220 ep = _mm256_and_si256(c, EP_AVX2);
221 _mm256_storeu_si256((__m256i *)mem, ep); 221 _mm256_storeu_si256((__m256i *)mem, ep);
@@ -243,12 +243,12 @@ coord_esep(cube_t c)
243} 243}
244 244
245STATIC_INLINE cube_t 245STATIC_INLINE cube_t
246invcoord_esep(int64_t esep) 246invcoord_esep(uint64_t esep)
247{ 247{
248 cube_t eee, ret; 248 cube_t eee, ret;
249 uint8_t mem[32] = {0}; 249 uint8_t mem[32] = {0};
250 250
251 invcoord_esep_array(esep % 70, esep / 70, mem+16); 251 invcoord_esep_array(esep % UINT64_C(70), esep / UINT64_C(70), mem+16);
252 252
253 ret = SOLVED_CUBE; 253 ret = SOLVED_CUBE;
254 eee = _mm256_loadu_si256((__m256i_u *)&mem); 254 eee = _mm256_loadu_si256((__m256i_u *)&mem);
@@ -270,9 +270,9 @@ copy_edges(cube_t dest[static 1], cube_t src)
270} 270}
271 271
272STATIC_INLINE void 272STATIC_INLINE void
273set_eo(cube_t cube[static 1], int64_t eo) 273set_eo(cube_t cube[static 1], uint64_t eo)
274{ 274{
275 int64_t eo12, eotop, eobot; 275 uint64_t eo12, eotop, eobot;
276 __m256i veo; 276 __m256i veo;
277 277
278 eo12 = (eo << 1) + (_mm_popcnt_u64(eo) % 2); 278 eo12 = (eo << 1) + (_mm_popcnt_u64(eo) % 2);
@@ -294,17 +294,17 @@ set_eo(cube_t cube[static 1], int64_t eo)
294 *cube = _mm256_or_si256(*cube, veo); 294 *cube = _mm256_or_si256(*cube, veo);
295} 295}
296 296
297STATIC_INLINE int64_t 297STATIC_INLINE uint64_t
298permtoindex_8x8(int64_t a) 298permtoindex_8x8(int64_t a)
299{ 299{
300 int64_t i, c, ret; 300 uint64_t i, c, ret;
301 __m64 cmp; 301 __m64 cmp;
302 302
303 for (i = 0, ret = 0; i < 8; i++) { 303 for (i = 0, ret = 0; i < 8; i++) {
304 cmp = _mm_set1_pi8(a & INT64_C(0xFF)); 304 cmp = _mm_set1_pi8(a & INT64_C(0xFF));
305 a = (a >> INT64_C(8)) | INT64_C(0x0F00000000000000); 305 a = (a >> INT64_C(8)) | INT64_C(0x0F00000000000000);
306 cmp = _mm_cmpgt_pi8(cmp, _mm_cvtsi64_m64(a)); 306 cmp = _mm_cmpgt_pi8(cmp, _mm_cvtsi64_m64(a));
307 c = _mm_popcnt_u64(_mm_cvtm64_si64(cmp)) >> INT64_C(3); 307 c = _mm_popcnt_u64(_mm_cvtm64_si64(cmp)) >> UINT64_C(3);
308 ret += c * factorial[7-i]; 308 ret += c * factorial[7-i];
309 } 309 }
310 310
@@ -312,10 +312,10 @@ permtoindex_8x8(int64_t a)
312} 312}
313 313
314STATIC_INLINE int64_t 314STATIC_INLINE int64_t
315indextoperm_8x8(int64_t p) 315indextoperm_8x8(uint64_t p)
316{ 316{
317 int used; 317 int used;
318 int64_t c, k, i, j, ret; 318 uint64_t c, k, i, j, ret;
319 319
320 for (i = 0, ret = 0, used = 0; i < 8; i++) { 320 for (i = 0, ret = 0, used = 0; i < 8; i++) {
321 k = p / factorial[7-i]; 321 k = p / factorial[7-i];
@@ -332,7 +332,7 @@ indextoperm_8x8(int64_t p)
332 return ret; 332 return ret;
333} 333}
334 334
335STATIC_INLINE int64_t 335STATIC_INLINE uint64_t
336coord_cp(cube_t cube) 336coord_cp(cube_t cube)
337{ 337{
338 cube_t cp; 338 cube_t cp;
@@ -345,12 +345,12 @@ coord_cp(cube_t cube)
345} 345}
346 346
347STATIC_INLINE cube_t 347STATIC_INLINE cube_t
348invcoord_cp(int64_t i) 348invcoord_cp(uint64_t i)
349{ 349{
350 return _mm256_set_epi64x(SOLVED_H, SOLVED_L, 0, indextoperm_8x8(i)); 350 return _mm256_set_epi64x(SOLVED_H, SOLVED_L, 0, indextoperm_8x8(i));
351} 351}
352 352
353STATIC_INLINE int64_t 353STATIC_INLINE uint64_t
354coord_epud(cube_t cube) 354coord_epud(cube_t cube)
355{ 355{
356 cube_t ep; 356 cube_t ep;
@@ -363,7 +363,7 @@ coord_epud(cube_t cube)
363} 363}
364 364
365STATIC_INLINE cube_t 365STATIC_INLINE cube_t
366invcoord_epud(int64_t i) 366invcoord_epud(uint64_t i)
367{ 367{
368 return _mm256_set_epi64x(SOLVED_H, indextoperm_8x8(i), 0, SOLVED_L); 368 return _mm256_set_epi64x(SOLVED_H, indextoperm_8x8(i), 0, SOLVED_L);
369} 369}
diff --git a/src/arch/common.h b/src/arch/common.h
index 3e7867d..6c62a2e 100644
--- a/src/arch/common.h
+++ b/src/arch/common.h
@@ -22,30 +22,30 @@ STATIC_INLINE cube_t compose_corners(cube_t, cube_t);
22STATIC_INLINE cube_t compose(cube_t, cube_t); 22STATIC_INLINE cube_t compose(cube_t, cube_t);
23STATIC_INLINE cube_t inverse(cube_t); 23STATIC_INLINE cube_t inverse(cube_t);
24 24
25STATIC_INLINE int64_t coord_co(cube_t); 25STATIC_INLINE uint64_t coord_co(cube_t);
26STATIC_INLINE cube_t invcoord_co(int64_t); 26STATIC_INLINE cube_t invcoord_co(uint64_t);
27STATIC_INLINE int64_t coord_csep(cube_t); 27STATIC_INLINE uint64_t coord_csep(cube_t);
28STATIC_INLINE int64_t coord_cocsep(cube_t); 28STATIC_INLINE uint64_t coord_cocsep(cube_t);
29STATIC_INLINE int64_t coord_eo(cube_t); 29STATIC_INLINE uint64_t coord_eo(cube_t);
30STATIC_INLINE int64_t coord_esep(cube_t); 30STATIC_INLINE uint64_t coord_esep(cube_t);
31STATIC_INLINE cube_t invcoord_esep(int64_t); 31STATIC_INLINE cube_t invcoord_esep(uint64_t);
32 32
33STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); 33STATIC_INLINE void copy_corners(cube_t [static 1], cube_t);
34STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); 34STATIC_INLINE void copy_edges(cube_t [static 1], cube_t);
35STATIC_INLINE void set_eo(cube_t [static 1], int64_t); 35STATIC_INLINE void set_eo(cube_t [static 1], uint64_t);
36 36
37STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); 37STATIC_INLINE void invcoord_esep_array(uint64_t, uint64_t, uint8_t[static 12]);
38STATIC_INLINE cube_t invcoord_eoesep(int64_t); 38STATIC_INLINE cube_t invcoord_eoesep(uint64_t);
39 39
40STATIC_INLINE int64_t coord_cp(cube_t); 40STATIC_INLINE uint64_t coord_cp(cube_t);
41STATIC_INLINE cube_t invcoord_cp(int64_t); 41STATIC_INLINE cube_t invcoord_cp(uint64_t);
42STATIC_INLINE int64_t coord_epud(cube_t); 42STATIC_INLINE uint64_t coord_epud(cube_t);
43STATIC_INLINE cube_t invcoord_epud(int64_t); 43STATIC_INLINE cube_t invcoord_epud(uint64_t);
44 44
45STATIC_INLINE void 45STATIC_INLINE void
46invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12]) 46invcoord_esep_array(uint64_t set1, uint64_t set2, uint8_t mem[static 12])
47{ 47{
48 int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; 48 uint64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1;
49 uint8_t slice[3] = {0}; 49 uint8_t slice[3] = {0};
50 50
51 for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) 51 for (i = 0, j = 0, k = 4, l = 4; i < 12; i++)
@@ -69,10 +69,10 @@ invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12])
69} 69}
70 70
71STATIC_INLINE cube_t 71STATIC_INLINE cube_t
72invcoord_eoesep(int64_t i) 72invcoord_eoesep(uint64_t i)
73{ 73{
74 cube_t c; 74 cube_t c;
75 int64_t esep, eo; 75 uint64_t esep, eo;
76 76
77 esep = i >> INT64_C(11); 77 esep = i >> INT64_C(11);
78 eo = i % POW_2_11; 78 eo = i % POW_2_11;
diff --git a/src/arch/neon.h b/src/arch/neon.h
index a378cf9..fef6220 100644
--- a/src/arch/neon.h
+++ b/src/arch/neon.h
@@ -29,8 +29,8 @@ STATIC_INLINE uint8x8_t compose_corners_slim(uint8x8_t, uint8x8_t);
29const uint8_t SOLVED_L[8] = {0, 1, 2, 3, 4, 5, 6, 7}; 29const uint8_t SOLVED_L[8] = {0, 1, 2, 3, 4, 5, 6, 7};
30const uint8_t SOLVED_H[8] = {8, 9, 10, 11, 0, 0, 0}; 30const uint8_t SOLVED_H[8] = {8, 9, 10, 11, 0, 0, 0};
31 31
32STATIC_INLINE int64_t permtoindex_8x8(uint8x8_t); 32STATIC_INLINE uint64_t permtoindex_8x8(uint8x8_t);
33STATIC_INLINE uint8x8_t indextoperm_8x8(int64_t); 33STATIC_INLINE uint8x8_t indextoperm_8x8(uint64_t);
34 34
35STATIC_INLINE int 35STATIC_INLINE int
36popcount_u32(uint32_t x) 36popcount_u32(uint32_t x)
@@ -215,16 +215,15 @@ inverse(cube_t cube)
215 return ret; 215 return ret;
216} 216}
217 217
218STATIC_INLINE int64_t 218STATIC_INLINE uint64_t
219coord_co(cube_t c) 219coord_co(cube_t c)
220{ 220{
221 uint64_t i, p, ret;
222
221 // Temp array to store the NEON vector 223 // Temp array to store the NEON vector
222 uint8_t mem[8]; 224 uint8_t mem[8];
223 vst1_u8(mem, c.corner); 225 vst1_u8(mem, c.corner);
224 226
225 int i, p;
226 int64_t ret;
227
228 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) 227 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3)
229 ret += p * (mem[i] >> COSHIFT); 228 ret += p * (mem[i] >> COSHIFT);
230 229
@@ -232,9 +231,9 @@ coord_co(cube_t c)
232} 231}
233 232
234STATIC_INLINE cube_t 233STATIC_INLINE cube_t
235invcoord_co(int64_t coord) 234invcoord_co(uint64_t coord)
236{ 235{
237 int64_t co, c, i, p; 236 uint64_t co, c, i, p;
238 uint8_t mem[8]; 237 uint8_t mem[8];
239 cube_t cube; 238 cube_t cube;
240 239
@@ -250,15 +249,15 @@ invcoord_co(int64_t coord)
250 return cube; 249 return cube;
251} 250}
252 251
253STATIC_INLINE int64_t 252STATIC_INLINE uint64_t
254coord_csep(cube_t c) 253coord_csep(cube_t c)
255{ 254{
255 uint64_t ret, i, p;
256
256 // Temp array to store the NEON vector 257 // Temp array to store the NEON vector
257 uint8_t mem[8]; 258 uint8_t mem[8];
258 vst1_u8(mem, c.corner); 259 vst1_u8(mem, c.corner);
259 260
260 int64_t ret = 0;
261 int i, p;
262 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) 261 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2)
263 ret += p * ((mem[i] & CSEPBIT) >> 2); 262 ret += p * ((mem[i] & CSEPBIT) >> 2);
264 263
@@ -266,23 +265,23 @@ coord_csep(cube_t c)
266 return 0; 265 return 0;
267} 266}
268 267
269STATIC_INLINE int64_t 268STATIC_INLINE uint64_t
270coord_cocsep(cube_t c) 269coord_cocsep(cube_t c)
271{ 270{
272 return (coord_co(c) << 7) + coord_csep(c); 271 return (coord_co(c) << UINT64_C(7)) + coord_csep(c);
273} 272}
274 273
275STATIC_INLINE int64_t 274STATIC_INLINE uint64_t
276coord_eo(cube_t c) 275coord_eo(cube_t c)
277{ 276{
278 int64_t ret = 0; 277 uint64_t ret, p;
279 int64_t p = 1; 278 int i;
280 279
281 // Temp array to store the NEON vector 280 // Temp array to store the NEON vector
282 uint8_t mem[16]; 281 uint8_t mem[16];
283 vst1q_u8(mem, c.edge); 282 vst1q_u8(mem, c.edge);
284 283
285 for (int i = 1; i < 12; i++, p *= 2) 284 for (i = 1, ret = 0, p = 1; i < 12; i++, p *= 2)
286 { 285 {
287 ret += p * (mem[i] >> EOSHIFT); 286 ret += p * (mem[i] >> EOSHIFT);
288 } 287 }
@@ -290,10 +289,10 @@ coord_eo(cube_t c)
290 return ret; 289 return ret;
291} 290}
292 291
293STATIC_INLINE int64_t 292STATIC_INLINE uint64_t
294coord_esep(cube_t c) 293coord_esep(cube_t c)
295{ 294{
296 int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; 295 uint64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1;
297 296
298 // Temp array to store the NEON vector 297 // Temp array to store the NEON vector
299 uint8_t mem[16]; 298 uint8_t mem[16];
@@ -330,7 +329,7 @@ copy_edges(cube_t dst[static 1], cube_t src)
330} 329}
331 330
332STATIC_INLINE void 331STATIC_INLINE void
333set_eo(cube_t cube[static 1], int64_t eo) 332set_eo(cube_t cube[static 1], uint64_t eo)
334{ 333{
335 // Temp array to store the NEON vector 334 // Temp array to store the NEON vector
336 uint8_t mem[16]; 335 uint8_t mem[16];
@@ -351,12 +350,12 @@ set_eo(cube_t cube[static 1], int64_t eo)
351} 350}
352 351
353STATIC_INLINE cube_t 352STATIC_INLINE cube_t
354invcoord_esep(int64_t esep) 353invcoord_esep(uint64_t esep)
355{ 354{
356 cube_t ret; 355 cube_t ret;
357 uint8_t mem[16] = {0}; 356 uint8_t mem[16] = {0};
358 357
359 invcoord_esep_array(esep % 70, esep / 70, mem); 358 invcoord_esep_array(esep % UINT64_C(70), esep / UINT64_C(70), mem);
360 359
361 ret = SOLVED_CUBE; 360 ret = SOLVED_CUBE;
362 ret.edge = vld1q_u8(mem); 361 ret.edge = vld1q_u8(mem);
@@ -364,10 +363,10 @@ invcoord_esep(int64_t esep)
364 return ret; 363 return ret;
365} 364}
366 365
367STATIC_INLINE int64_t 366STATIC_INLINE uint64_t
368permtoindex_8x8(uint8x8_t a) 367permtoindex_8x8(uint8x8_t a)
369{ 368{
370 int64_t i, c, ret; 369 uint64_t i, c, ret;
371 uint8x8_t cmp; 370 uint8x8_t cmp;
372 uint64x1_t anum; 371 uint64x1_t anum;
373 uint8_t or[8] = {0, 0, 0, 0, 0, 0, 0, 0x0F}; 372 uint8_t or[8] = {0, 0, 0, 0, 0, 0, 0, 0x0F};
@@ -387,10 +386,10 @@ permtoindex_8x8(uint8x8_t a)
387} 386}
388 387
389STATIC_INLINE uint8x8_t 388STATIC_INLINE uint8x8_t
390indextoperm_8x8(int64_t p) 389indextoperm_8x8(uint64_t p)
391{ 390{
392 int used; 391 int used;
393 int64_t c, k, i, j; 392 uint64_t c, k, i, j;
394 uint8_t ret[8]; 393 uint8_t ret[8];
395 394
396 for (i = 0, used = 0; i < 8; i++) { 395 for (i = 0, used = 0; i < 8; i++) {
@@ -408,14 +407,14 @@ indextoperm_8x8(int64_t p)
408 return vld1_u8(ret); 407 return vld1_u8(ret);
409} 408}
410 409
411STATIC_INLINE int64_t 410STATIC_INLINE uint64_t
412coord_cp(cube_t cube) 411coord_cp(cube_t cube)
413{ 412{
414 return permtoindex_8x8(vand_u8(cube.corner, PBITS8_NEON)); 413 return permtoindex_8x8(vand_u8(cube.corner, PBITS8_NEON));
415} 414}
416 415
417STATIC_INLINE cube_t 416STATIC_INLINE cube_t
418invcoord_cp(int64_t i) 417invcoord_cp(uint64_t i)
419{ 418{
420 return (cube_t) { 419 return (cube_t) {
421 .corner = indextoperm_8x8(i), 420 .corner = indextoperm_8x8(i),
@@ -423,14 +422,14 @@ invcoord_cp(int64_t i)
423 }; 422 };
424} 423}
425 424
426STATIC_INLINE int64_t 425STATIC_INLINE uint64_t
427coord_epud(cube_t cube) 426coord_epud(cube_t cube)
428{ 427{
429 return permtoindex_8x8(vand_u8(vget_low_u8(cube.edge), PBITS8_NEON)); 428 return permtoindex_8x8(vand_u8(vget_low_u8(cube.edge), PBITS8_NEON));
430} 429}
431 430
432STATIC_INLINE cube_t 431STATIC_INLINE cube_t
433invcoord_epud(int64_t i) 432invcoord_epud(uint64_t i)
434{ 433{
435 return (cube_t) { 434 return (cube_t) {
436 .corner = vld1_u8(SOLVED_L), 435 .corner = vld1_u8(SOLVED_L),
diff --git a/src/arch/portable.h b/src/arch/portable.h
index ec992a8..5acccf2 100644
--- a/src/arch/portable.h
+++ b/src/arch/portable.h
@@ -154,7 +154,7 @@ inverse(cube_t cube)
154 return ret; 154 return ret;
155} 155}
156 156
157STATIC_INLINE int64_t 157STATIC_INLINE uint64_t
158coord_co(cube_t c) 158coord_co(cube_t c)
159{ 159{
160 int i, p, ret; 160 int i, p, ret;
@@ -166,9 +166,9 @@ coord_co(cube_t c)
166} 166}
167 167
168STATIC_INLINE cube_t 168STATIC_INLINE cube_t
169invcoord_co(int64_t coord) 169invcoord_co(uint64_t coord)
170{ 170{
171 int64_t i, c, p; 171 uint64_t i, c, p;
172 cube_t cube; 172 cube_t cube;
173 173
174 cube = SOLVED_CUBE; 174 cube = SOLVED_CUBE;
@@ -189,11 +189,11 @@ Ignoring the last bit, we have a value up to 2^7, but not all values are
189possible. Encoding this as a number from 0 to C(8,4) would save about 40% 189possible. Encoding this as a number from 0 to C(8,4) would save about 40%
190of space, but we are not going to use this coordinate in large tables. 190of space, but we are not going to use this coordinate in large tables.
191*/ 191*/
192STATIC_INLINE int64_t 192STATIC_INLINE uint64_t
193coord_csep(cube_t c) 193coord_csep(cube_t c)
194{ 194{
195 int i, p; 195 int i, p;
196 int64_t ret; 196 uint64_t ret;
197 197
198 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) 198 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2)
199 ret += p * ((c.corner[i] & CSEPBIT) >> 2); 199 ret += p * ((c.corner[i] & CSEPBIT) >> 2);
@@ -201,17 +201,17 @@ coord_csep(cube_t c)
201 return ret; 201 return ret;
202} 202}
203 203
204STATIC_INLINE int64_t 204STATIC_INLINE uint64_t
205coord_cocsep(cube_t c) 205coord_cocsep(cube_t c)
206{ 206{
207 return (coord_co(c) << 7) + coord_csep(c); 207 return (coord_co(c) << 7) + coord_csep(c);
208} 208}
209 209
210STATIC_INLINE int64_t 210STATIC_INLINE uint64_t
211coord_eo(cube_t c) 211coord_eo(cube_t c)
212{ 212{
213 int i, p; 213 int i, p;
214 int64_t ret; 214 uint64_t ret;
215 215
216 for (ret = 0, i = 1, p = 1; i < 12; i++, p *= 2) 216 for (ret = 0, i = 1, p = 1; i < 12; i++, p *= 2)
217 ret += p * (c.edge[i] >> EOSHIFT); 217 ret += p * (c.edge[i] >> EOSHIFT);
@@ -223,10 +223,10 @@ coord_eo(cube_t c)
223We encode the edge separation as a number from 0 to C(12,4)*C(8,4). 223We encode the edge separation as a number from 0 to C(12,4)*C(8,4).
224It can be seen as the composition of two "subset index" coordinates. 224It can be seen as the composition of two "subset index" coordinates.
225*/ 225*/
226STATIC_INLINE int64_t 226STATIC_INLINE uint64_t
227coord_esep(cube_t c) 227coord_esep(cube_t c)
228{ 228{
229 int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; 229 uint64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1;
230 230
231 for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) { 231 for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) {
232 /* Simple version: 232 /* Simple version:
@@ -256,7 +256,7 @@ coord_esep(cube_t c)
256} 256}
257 257
258STATIC_INLINE cube_t 258STATIC_INLINE cube_t
259invcoord_esep(int64_t esep) 259invcoord_esep(uint64_t esep)
260{ 260{
261 cube_t ret; 261 cube_t ret;
262 262
@@ -279,7 +279,7 @@ copy_edges(cube_t dest[static 1], cube_t src)
279} 279}
280 280
281STATIC_INLINE void 281STATIC_INLINE void
282set_eo(cube_t cube[static 1], int64_t eo) 282set_eo(cube_t cube[static 1], uint64_t eo)
283{ 283{
284 uint8_t i, sum, flip; 284 uint8_t i, sum, flip;
285 285
@@ -291,7 +291,7 @@ set_eo(cube_t cube[static 1], int64_t eo)
291 cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); 291 cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2));
292} 292}
293 293
294STATIC_INLINE int64_t 294STATIC_INLINE uint64_t
295coord_cp(cube_t cube) 295coord_cp(cube_t cube)
296{ 296{
297 int i; 297 int i;
@@ -303,7 +303,7 @@ coord_cp(cube_t cube)
303} 303}
304 304
305STATIC_INLINE cube_t 305STATIC_INLINE cube_t
306invcoord_cp(int64_t i) 306invcoord_cp(uint64_t i)
307{ 307{
308 uint8_t c[8]; 308 uint8_t c[8];
309 309
@@ -313,7 +313,7 @@ invcoord_cp(int64_t i)
313 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); 313 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
314} 314}
315 315
316STATIC_INLINE int64_t 316STATIC_INLINE uint64_t
317coord_epud(cube_t cube) 317coord_epud(cube_t cube)
318{ 318{
319 int i; 319 int i;
@@ -325,7 +325,7 @@ coord_epud(cube_t cube)
325} 325}
326 326
327STATIC_INLINE cube_t 327STATIC_INLINE cube_t
328invcoord_epud(int64_t i) 328invcoord_epud(uint64_t i)
329{ 329{
330 uint8_t e[8]; 330 uint8_t e[8];
331 331
diff --git a/src/core/cube.h b/src/core/cube.h
index cdd3946..3ba282e 100644
--- a/src/core/cube.h
+++ b/src/core/cube.h
@@ -5,7 +5,7 @@ STATIC bool issolved(oriented_cube_t);
5STATIC bool iserror(oriented_cube_t); 5STATIC bool iserror(oriented_cube_t);
6STATIC void getcube_fix(long long *, long long *, 6STATIC void getcube_fix(long long *, long long *,
7 long long *, long long *, long long *); 7 long long *, long long *, long long *);
8STATIC cube_t getcube(int64_t, int64_t, int64_t, int64_t); 8STATIC cube_t getcube(uint64_t, uint64_t, uint64_t, uint64_t);
9 9
10STATIC oriented_cube_t readcube(const char *); 10STATIC oriented_cube_t readcube(const char *);
11STATIC int64_t writecube(oriented_cube_t, size_t n, char [n]); 11STATIC int64_t writecube(oriented_cube_t, size_t n, char [n]);
@@ -150,26 +150,26 @@ getcube_fix(
150{ 150{
151 uint8_t e[12], c[8], coarr[8]; 151 uint8_t e[12], c[8], coarr[8];
152 152
153 *ep = (*ep % FACT_12 + FACT_12) % FACT_12; 153 *ep = POSITIVE_MOD(*ep, (long long)FACT_12);
154 *eo = (*eo % POW_2_11 + POW_2_11) % POW_2_11; 154 *eo = POSITIVE_MOD(*eo, (long long)POW_2_11);
155 *cp = (*cp % FACT_8 + FACT_8) % FACT_8; 155 *cp = POSITIVE_MOD(*cp, (long long)FACT_8);
156 *co = (*cp % POW_3_7 + POW_3_7) % POW_3_7; 156 *co = POSITIVE_MOD(*co, (long long)POW_3_7);
157 *orien = (*orien % 24 + 24) % 24; 157 *orien = POSITIVE_MOD(*orien, 24LL);
158 158
159 indextoperm(*ep, 12, e); 159 indextoperm((uint64_t)*ep, 12, e);
160 indextoperm(*cp, 8, c); 160 indextoperm((uint64_t)*cp, 8, c);
161 if (permsign(12, e) != permsign(8, c)) { 161 if (permsign(12, e) != permsign(8, c)) {
162 SWAP(c[0], c[1]); 162 SWAP(c[0], c[1]);
163 *cp = permtoindex(8, c); 163 *cp = (long long)permtoindex(8, c);
164 164
165 sumzerotodigits(*co, 8, 3, coarr); 165 sumzerotodigits((uint64_t)*co, 8, 3, coarr);
166 SWAP(coarr[0], coarr[1]); 166 SWAP(coarr[0], coarr[1]);
167 *co = digitstosumzero(8, coarr, 3); 167 *co = (uint64_t)digitstosumzero(8, coarr, 3);
168 } 168 }
169} 169}
170 170
171STATIC cube_t 171STATIC cube_t
172getcube(int64_t ep, int64_t eo, int64_t cp, int64_t co) 172getcube(uint64_t ep, uint64_t eo, uint64_t cp, uint64_t co)
173{ 173{
174 uint8_t i, earr[12], carr[8], eoarr[12], coarr[8]; 174 uint8_t i, earr[12], carr[8], eoarr[12], coarr[8];
175 175
diff --git a/src/solvers/coord/dr.h b/src/solvers/coord/dr.h
index d986742..7f7af4f 100644
--- a/src/solvers/coord/dr.h
+++ b/src/solvers/coord/dr.h
@@ -12,10 +12,6 @@ STATIC size_t coordinate_dr_gendata(unsigned char *);
12 12
13STATIC bool is_eoco_solvable(cube_t); 13STATIC bool is_eoco_solvable(cube_t);
14 14
15/* TODO: remove the following two when all coordinates are converted to unsigned */
16STATIC uint64_t coord_co_u(cube_t c) { return (uint64_t)coord_co(c); }
17STATIC cube_t invcoord_co_u(uint64_t i) { return invcoord_co((int64_t)i); }
18
19STATIC coord_t coordinate_dr = { 15STATIC coord_t coordinate_dr = {
20 .name = "DR", 16 .name = "DR",
21 .coord = &coordinate_dr_coord, 17 .coord = &coordinate_dr_coord,
@@ -54,8 +50,8 @@ STATIC coord_t coordinate_dr = {
54 .coord = &coord_dreoesep_nosym, 50 .coord = &coord_dreoesep_nosym,
55 .cube = &invcoord_dreoesep_nosym, 51 .cube = &invcoord_dreoesep_nosym,
56 .max2 = POW_3_7, 52 .max2 = POW_3_7,
57 .coord2 = &coord_co_u, 53 .coord2 = &coord_co,
58 .cube2 = &invcoord_co_u, 54 .cube2 = &invcoord_co,
59 .merge = &coordinate_dr_merge, 55 .merge = &coordinate_dr_merge,
60 }, 56 },
61}; 57};
diff --git a/src/solvers/coord/dreo.h b/src/solvers/coord/dreo.h
index f6fa3e9..31f7008 100644
--- a/src/solvers/coord/dreo.h
+++ b/src/solvers/coord/dreo.h
@@ -47,8 +47,8 @@ STATIC coord_t coordinate_dreo = {
47 .coord = &coord_dresep_nosym, 47 .coord = &coord_dresep_nosym,
48 .cube = &invcoord_dresep_nosym, 48 .cube = &invcoord_dresep_nosym,
49 .max2 = POW_3_7, 49 .max2 = POW_3_7,
50 .coord2 = &coord_co_u, 50 .coord2 = &coord_co,
51 .cube2 = &invcoord_co_u, 51 .cube2 = &invcoord_co,
52 .merge = &coordinate_dreo_merge, 52 .merge = &coordinate_dreo_merge,
53 }, 53 },
54}; 54};
@@ -56,7 +56,7 @@ STATIC coord_t coordinate_dreo = {
56STATIC uint64_t 56STATIC uint64_t
57coord_dresep_nosym(cube_t cube) 57coord_dresep_nosym(cube_t cube)
58{ 58{
59 return (uint64_t)coord_esep(cube) / COMB_8_4; 59 return coord_esep(cube) / COMB_8_4;
60} 60}
61 61
62STATIC cube_t 62STATIC cube_t
diff --git a/src/solvers/coord/eo.h b/src/solvers/coord/eo.h
index 7735319..b963832 100644
--- a/src/solvers/coord/eo.h
+++ b/src/solvers/coord/eo.h
@@ -44,7 +44,7 @@ STATIC cube_t
44coordinate_eo_cube(uint64_t c, const unsigned char *data) 44coordinate_eo_cube(uint64_t c, const unsigned char *data)
45{ 45{
46 cube_t cube = SOLVED_CUBE; 46 cube_t cube = SOLVED_CUBE;
47 set_eo(&cube, (int64_t)c); 47 set_eo(&cube, c);
48 return cube; 48 return cube;
49} 49}
50 50
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h
index 7118b08..678bfd7 100644
--- a/src/solvers/coord/gendata.h
+++ b/src/solvers/coord/gendata.h
@@ -29,7 +29,7 @@ gendata_coord_dispatch(
29 return NISSY_ERROR_INVALID_SOLVER; 29 return NISSY_ERROR_INVALID_SOLVER;
30 } 30 }
31 31
32 return (int64_t)gendata_coord(coord, buf); 32 return gendata_coord(coord, buf);
33} 33}
34 34
35STATIC size_t 35STATIC size_t
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 @@
1STATIC_INLINE int64_t coord_h48( 1STATIC_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);
3STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); 3STATIC_INLINE uint64_t coord_h48_edges(cube_t, uint64_t, uint8_t, uint8_t);
4STATIC_INLINE cube_t invcoord_h48( 4STATIC_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
7STATIC_INLINE int64_t 7STATIC_INLINE uint64_t
8coord_h48( 8coord_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
28STATIC_INLINE int64_t 28STATIC_INLINE uint64_t
29coord_h48_edges(cube_t c, int64_t coclass, uint8_t ttrep, uint8_t h) 29coord_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*/
47STATIC_INLINE cube_t 47STATIC_INLINE cube_t
48invcoord_h48( 48invcoord_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 *);
2STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [static 1]); 2STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [static 1]);
3 3
4STATIC_INLINE bool gendata_cocsep_get_visited( 4STATIC_INLINE bool gendata_cocsep_get_visited(
5 const uint8_t [static COCSEP_VISITEDSIZE], int64_t); 5 const uint8_t [static COCSEP_VISITEDSIZE], uint64_t);
6STATIC_INLINE void gendata_cocsep_set_visited( 6STATIC_INLINE void gendata_cocsep_set_visited(
7 uint8_t [static COCSEP_VISITEDSIZE], int64_t); 7 uint8_t [static COCSEP_VISITEDSIZE], uint64_t);
8 8
9STATIC_INLINE int8_t get_h48_cdata( 9STATIC_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])
136STATIC_INLINE bool 136STATIC_INLINE bool
137gendata_cocsep_get_visited( 137gendata_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(
145STATIC_INLINE void 145STATIC_INLINE void
146gendata_cocsep_set_visited( 146gendata_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 @@
1STATIC int64_t coord_eoesep_sym(cube_t, const uint32_t [static ESEP_MAX]); 1STATIC uint64_t coord_eoesep_sym(cube_t, const uint32_t [static ESEP_MAX]);
2STATIC size_t gendata_esep_classes( 2STATIC 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]);
4STATIC size_t gendata_eoesep(unsigned char *, uint8_t); 4STATIC 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]);
9STATIC uint32_t gendata_eoesep_fromdone(uint8_t, uint8_t [static EOESEP_BUF], 9STATIC 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]);
11STATIC uint32_t gendata_eoesep_marksim(int64_t, uint8_t, 11STATIC 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]);
13STATIC bool gendata_eoesep_next(cube_t, uint8_t, 13STATIC 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]);
15STATIC uint8_t get_eoesep_pval( 15STATIC 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);
17STATIC uint8_t get_eoesep_pval_cube(const unsigned char *, cube_t); 17STATIC uint8_t get_eoesep_pval_cube(const unsigned char *, cube_t);
18STATIC void set_eoesep_pval( 18STATIC 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
21STATIC int64_t 21STATIC uint64_t
22coord_eoesep_sym(cube_t c, const uint32_t esep_classes[static ESEP_MAX]) 22coord_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
195STATIC uint32_t 195STATIC uint32_t
196gendata_eoesep_marksim( 196gendata_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(
252STATIC uint8_t 252STATIC uint8_t
253get_eoesep_pval( 253get_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(
261STATIC uint8_t 261STATIC uint8_t
262get_eoesep_pval_cube(const unsigned char *data, cube_t c) 262get_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)
271STATIC void 271STATIC void
272set_eoesep_pval( 272set_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]);
18STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); 18STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *);
19STATIC const unsigned char *get_h48data_constptr(const unsigned char *); 19STATIC const unsigned char *get_h48data_constptr(const unsigned char *);
20 20
21STATIC_INLINE uint8_t get_h48_pval(const unsigned char *, int64_t, uint8_t); 21STATIC_INLINE uint8_t get_h48_pval(const unsigned char *, uint64_t, uint8_t);
22STATIC_INLINE void set_h48_pval(unsigned char *, int64_t, uint8_t, uint8_t); 22STATIC_INLINE void set_h48_pval(unsigned char *, uint64_t, uint8_t, uint8_t);
23STATIC_INLINE uint8_t get_h48_pval_atomic( 23STATIC_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);
25STATIC_INLINE void set_h48_pval_atomic( 25STATIC_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
28STATIC long long 28STATIC long long
29gendata_h48_dispatch( 29gendata_h48_dispatch(
@@ -50,7 +50,7 @@ STATIC uint64_t
50gendata_h48short(gendata_h48short_arg_t arg[static 1]) 50gendata_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
607gendata_h48_mark_atomic(gendata_h48_mark_t arg[static 1]) 607gendata_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
627gendata_h48_mark(gendata_h48_mark_t arg[static 1]) 627gendata_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
644gendata_h48k2_dfs_stop(cube_t cube, int8_t d, h48k2_dfs_arg_t arg[static 1]) 644gendata_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
707STATIC_INLINE uint8_t 707STATIC_INLINE uint8_t
708get_h48_pval(const unsigned char *table, int64_t i, uint8_t k) 708get_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
713STATIC_INLINE uint8_t 713STATIC_INLINE uint8_t
714get_h48_pval_atomic(_Atomic const unsigned char *table, int64_t i, uint8_t k) 714get_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
719STATIC_INLINE void 719STATIC_INLINE void
720set_h48_pval(unsigned char *table, int64_t i, uint8_t k, uint8_t val) 720set_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)
726STATIC_INLINE void 726STATIC_INLINE void
727set_h48_pval_atomic( 727set_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
36VAR_T by VAR_TTREP). 36VAR_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 }
diff --git a/src/utils/constants.h b/src/utils/constants.h
index e328a4c..f90dda3 100644
--- a/src/utils/constants.h
+++ b/src/utils/constants.h
@@ -1,17 +1,17 @@
1#define UINT8_BIT(i) (UINT8_C(1) << (uint8_t)(i)) 1#define UINT8_BIT(i) (UINT8_C(1) << (uint8_t)(i))
2 2
3#define FACTORIAL_MAX INT64_C(12) 3#define FACTORIAL_MAX UINT64_C(12)
4 4
5#define POW_2_11 INT64_C(2048) 5#define POW_2_11 UINT64_C(2048)
6#define POW_3_7 INT64_C(2187) 6#define POW_3_7 UINT64_C(2187)
7#define FACT_12 INT64_C(479001600) 7#define FACT_12 UINT64_C(479001600)
8#define FACT_8 INT64_C(40320) 8#define FACT_8 UINT64_C(40320)
9#define COMB_12_4 INT64_C(495) 9#define COMB_12_4 UINT64_C(495)
10#define COMB_8_4 INT64_C(70) 10#define COMB_8_4 UINT64_C(70)
11 11
12#define UINT8_ERROR UINT8_MAX 12#define UINT8_ERROR UINT8_MAX
13 13
14STATIC int64_t factorial[FACTORIAL_MAX+1] = { 14STATIC uint64_t factorial[FACTORIAL_MAX+1] = {
15 [0] = 1, 15 [0] = 1,
16 [1] = 1, 16 [1] = 1,
17 [2] = 2, 17 [2] = 2,
@@ -27,7 +27,7 @@ STATIC int64_t factorial[FACTORIAL_MAX+1] = {
27 [12] = 479001600, 27 [12] = 479001600,
28}; 28};
29 29
30STATIC int64_t binomial[12][12] = { 30STATIC uint64_t binomial[12][12] = {
31 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 31 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
32 {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 32 {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
33 {1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 33 {1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
diff --git a/src/utils/math.h b/src/utils/math.h
index ebbd63e..f2176b6 100644
--- a/src/utils/math.h
+++ b/src/utils/math.h
@@ -2,12 +2,13 @@
2#define MIN(x, y) ((x) < (y) ? (x) : (y)) 2#define MIN(x, y) ((x) < (y) ? (x) : (y))
3#define MAX(x, y) ((x) > (y) ? (x) : (y)) 3#define MAX(x, y) ((x) > (y) ? (x) : (y))
4#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) 4#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
5#define POSITIVE_MOD(x, y) (((x) % (y) + (y)) % (y))
5 6
6STATIC int64_t permtoindex(size_t, const uint8_t *); 7STATIC uint64_t permtoindex(size_t, const uint8_t *);
7STATIC void indextoperm(int64_t, size_t, uint8_t *); 8STATIC void indextoperm(uint64_t, size_t, uint8_t *);
8STATIC int permsign(size_t, const uint8_t *); 9STATIC int permsign(size_t, const uint8_t *);
9STATIC int64_t digitstosumzero(size_t, const uint8_t *, uint8_t); 10STATIC uint64_t digitstosumzero(size_t, const uint8_t *, uint8_t);
10STATIC void sumzerotodigits(int64_t, size_t, uint8_t, uint8_t *); 11STATIC void sumzerotodigits(uint64_t, size_t, uint8_t, uint8_t *);
11STATIC double intpow(double, uint64_t); 12STATIC double intpow(double, uint64_t);
12 13
13/* This code is only used for assertions in debug mode */ 14/* This code is only used for assertions in debug mode */
@@ -36,14 +37,14 @@ isperm(size_t n, const uint8_t *a)
36} 37}
37#endif 38#endif
38 39
39STATIC int64_t 40STATIC uint64_t
40permtoindex(size_t n, const uint8_t *a) 41permtoindex(size_t n, const uint8_t *a)
41{ 42{
42 size_t i, j; 43 size_t i, j;
43 int64_t c, ret; 44 uint64_t c, ret;
44 45
45 DBG_ASSERT(n <= FACTORIAL_MAX, "Error: cannot compute permtoindex() " 46 DBG_ASSERT(n <= FACTORIAL_MAX, "Error: cannot compute permtoindex() "
46 "for set of size %zu > %" PRId64 "\n", n, FACTORIAL_MAX); 47 "for set of size %zu > %" PRIu64 "\n", n, FACTORIAL_MAX);
47 DBG_ASSERT(isperm(n, a), "Error: cannot compute permtoindex() for " 48 DBG_ASSERT(isperm(n, a), "Error: cannot compute permtoindex() for "
48 "invalid permutation\n"); 49 "invalid permutation\n");
49 50
@@ -57,15 +58,15 @@ permtoindex(size_t n, const uint8_t *a)
57} 58}
58 59
59STATIC void 60STATIC void
60indextoperm(int64_t p, size_t n, uint8_t *r) 61indextoperm(uint64_t p, size_t n, uint8_t *r)
61{ 62{
62 int64_t c, k; 63 uint64_t c, k;
63 size_t i, j, used; 64 size_t i, j, used;
64 65
65 DBG_ASSERT(n <= FACTORIAL_MAX, "Error: cannot compute indextoperm() " 66 DBG_ASSERT(n <= FACTORIAL_MAX, "Error: cannot compute indextoperm() "
66 "for set of size %zu > %" PRId64 "\n", n, FACTORIAL_MAX); 67 "for set of size %zu > %" PRIu64 "\n", n, FACTORIAL_MAX);
67 DBG_ASSERT(p >= 0 && p < factorial[n], "Error: invalid permutation " 68 DBG_ASSERT(p < factorial[n], "Error: invalid permutation index %"
68 "index %" PRId64 " for set of size %zu\n", p, n); 69 PRIu64 " for set of size %zu\n", p, n);
69 70
70 for (i = 0, used = 0; i < n; i++) { 71 for (i = 0, used = 0; i < n; i++) {
71 k = p / factorial[n-i-1]; 72 k = p / factorial[n-i-1];
@@ -94,28 +95,28 @@ permsign(size_t n, const uint8_t *a)
94 return ret % 2; 95 return ret % 2;
95} 96}
96 97
97STATIC int64_t 98STATIC uint64_t
98digitstosumzero(size_t n, const uint8_t *a, uint8_t b) 99digitstosumzero(size_t n, const uint8_t *a, uint8_t b)
99{ 100{
100 int64_t ret, p; 101 uint64_t ret, p;
101 size_t i, sum; 102 size_t i, sum;
102 103
103 DBG_ASSERT((n == 8 && b == 3 ) || (n == 12 && b == 2), 104 DBG_ASSERT((n == 8 && b == 3 ) || (n == 12 && b == 2),
104 "Error: digitstosumzero() called with n=%zu and b=%" PRIu8 105 "Error: digitstosumzero() called with n=%zu and b=%" PRIu8
105 " (use n=8 b=3 or n=12 b=2)\n", n, b); 106 " (use n=8 b=3 or n=12 b=2)\n", n, b);
106 107
107 for (i = 1, ret = 0, p = 1, sum = 0; i < n; i++, p *= (int64_t)b) { 108 for (i = 1, ret = 0, p = 1, sum = 0; i < n; i++, p *= (uint64_t)b) {
108 DBG_ASSERT(a[i] < b, "Error: digit %" PRIu8 109 DBG_ASSERT(a[i] < b, "Error: digit %" PRIu8
109 " > %" PRIu8 "in digitstosumzero()\n", a[i], b); 110 " > %" PRIu8 "in digitstosumzero()\n", a[i], b);
110 sum += a[i]; 111 sum += a[i];
111 ret += p * (int64_t)a[i]; 112 ret += p * (uint64_t)a[i];
112 } 113 }
113 114
114 return ret; 115 return ret;
115} 116}
116 117
117STATIC void 118STATIC void
118sumzerotodigits(int64_t d, size_t n, uint8_t b, uint8_t *a) 119sumzerotodigits(uint64_t d, size_t n, uint8_t b, uint8_t *a)
119{ 120{
120 uint8_t sum; 121 uint8_t sum;
121 size_t i; 122 size_t i;
@@ -124,8 +125,8 @@ sumzerotodigits(int64_t d, size_t n, uint8_t b, uint8_t *a)
124 "Error: sumzerotodigits() called with n=%zu and b=%" PRIu8 125 "Error: sumzerotodigits() called with n=%zu and b=%" PRIu8
125 " (use n=8 b=3 or n=12 b=2)\n", n, b); 126 " (use n=8 b=3 or n=12 b=2)\n", n, b);
126 127
127 for (i = 1, sum = 0; i < n; i++, d /= (int64_t)b) { 128 for (i = 1, sum = 0; i < n; i++, d /= (uint64_t)b) {
128 a[i] = (uint8_t)(d % (int64_t)b); 129 a[i] = (uint8_t)(d % (uint64_t)b);
129 sum += a[i]; 130 sum += a[i];
130 } 131 }
131 a[0] = (b - (sum % b)) % b; 132 a[0] = (b - (sum % b)) % b;

Generated with cgit - Back to sebastiano.tronto.net