aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-08-01 23:32:19 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-08-01 23:32:19 +0200
commit7ff76870242b6906b6f3caf22da3c094822ed140 (patch)
treea99748ace111c77a30bb0e615b28cfb7aab0db1e
parent1bd4691d9cc46ec75adbe899b289a1ebc5460721 (diff)
downloadnissy-core-7ff76870242b6906b6f3caf22da3c094822ed140.tar.gz
nissy-core-7ff76870242b6906b6f3caf22da3c094822ed140.zip
Move is_eo_even to more appropriate module
Diffstat (limited to '')
-rw-r--r--src/arch/avx2.h14
-rw-r--r--src/arch/common.h2
-rw-r--r--src/arch/neon.h18
-rw-r--r--src/arch/portable.h11
-rw-r--r--src/solvers/coord/eo.h14
5 files changed, 43 insertions, 16 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index 3fb46c9..cb9c0cd 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -426,3 +426,17 @@ invcoord_epe(uint64_t i)
426 426
427 return _mm256_set_epi64x(a, SOLVED_L, 0, SOLVED_L); 427 return _mm256_set_epi64x(a, SOLVED_L, 0, SOLVED_L);
428} 428}
429
430STATIC_INLINE bool
431is_eo_even(cube_t cube)
432{
433 uint8_t count;
434 __m256i e;
435
436 e = _mm256_and_si256(cube, EO_AVX2);
437 e = _mm256_srli_si256(e, EOSHIFT);
438
439 count = _mm256_reduce_add_epi8(e);
440
441 return count % 2 == 0;
442}
diff --git a/src/arch/common.h b/src/arch/common.h
index 1c8c0b0..d76b65f 100644
--- a/src/arch/common.h
+++ b/src/arch/common.h
@@ -30,6 +30,8 @@ STATIC_INLINE uint64_t coord_eo(cube_t);
30STATIC_INLINE uint64_t coord_esep(cube_t); 30STATIC_INLINE uint64_t coord_esep(cube_t);
31STATIC_INLINE cube_t invcoord_esep(uint64_t); 31STATIC_INLINE cube_t invcoord_esep(uint64_t);
32 32
33STATIC_INLINE bool is_eo_even(cube_t);
34
33STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); 35STATIC_INLINE void copy_corners(cube_t [static 1], cube_t);
34STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); 36STATIC_INLINE void copy_edges(cube_t [static 1], cube_t);
35STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); 37STATIC_INLINE void set_eo(cube_t [static 1], uint64_t);
diff --git a/src/arch/neon.h b/src/arch/neon.h
index 5723b60..2c35c58 100644
--- a/src/arch/neon.h
+++ b/src/arch/neon.h
@@ -1,5 +1,6 @@
1#define CO2_NEON vdup_n_u8(0x60) 1#define CO2_NEON vdup_n_u8(0x60)
2#define COCW_NEON vdup_n_u8(0x20) 2#define COCW_NEON vdup_n_u8(0x20)
3#define EO_NEON vdupq_n_u8(0x10)
3#define PBITS8_NEON vdup_n_u8(PBITS) 4#define PBITS8_NEON vdup_n_u8(PBITS)
4 5
5STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t); 6STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t);
@@ -501,3 +502,16 @@ invcoord_epe(uint64_t i)
501 .edge = vcombine_u8(vld1_u8(SOLVED_L), a) 502 .edge = vcombine_u8(vld1_u8(SOLVED_L), a)
502 }; 503 };
503} 504}
505
506STATIC_INLINE bool
507is_eo_even(cube_t cube)
508{
509 int8_t count;
510 uint8x16_t e;
511
512 e = vandq_u8(cube.edge, EO_NEON);
513 e = vshrq_n_u8(e, EOSHIFT);
514 count = vaddvq_u8(e);
515
516 return count % 2 == 0;
517}
diff --git a/src/arch/portable.h b/src/arch/portable.h
index 26001ee..d673f15 100644
--- a/src/arch/portable.h
+++ b/src/arch/portable.h
@@ -356,3 +356,14 @@ invcoord_epe(uint64_t i)
356 return STATIC_CUBE(0, 1, 2, 3, 4, 5, 6, 7, 356 return STATIC_CUBE(0, 1, 2, 3, 4, 5, 6, 7,
357 0, 1, 2, 3, 4, 5, 6, 7, e[0]+8, e[1]+8, e[2]+8, e[3]+8); 357 0, 1, 2, 3, 4, 5, 6, 7, e[0]+8, e[1]+8, e[2]+8, e[3]+8);
358} 358}
359
360STATIC_INLINE bool
361is_eo_even(cube_t cube)
362{
363 uint8_t i, count;
364
365 for (i = 0, count = 0; i < 12; i++)
366 count += (cube.edge[i] & EOBIT) >> EOSHIFT;
367
368 return count % 2 == 0;
369}
diff --git a/src/solvers/coord/eo.h b/src/solvers/coord/eo.h
index 2d45a4f..5c823a1 100644
--- a/src/solvers/coord/eo.h
+++ b/src/solvers/coord/eo.h
@@ -2,7 +2,6 @@ STATIC uint64_t coordinate_eo_coord(cube_t, const unsigned char *);
2STATIC cube_t coordinate_eo_cube(uint64_t, const unsigned char *); 2STATIC cube_t coordinate_eo_cube(uint64_t, const unsigned char *);
3STATIC bool coordinate_eo_isnasty(uint64_t, const unsigned char *); 3STATIC bool coordinate_eo_isnasty(uint64_t, const unsigned char *);
4STATIC size_t coordinate_eo_gendata(unsigned char *); 4STATIC size_t coordinate_eo_gendata(unsigned char *);
5STATIC bool is_eo_even(cube_t);
6 5
7STATIC coord_t coordinate_eo = { 6STATIC coord_t coordinate_eo = {
8 .name = "EO", 7 .name = "EO",
@@ -57,16 +56,3 @@ coordinate_eo_gendata(unsigned char *data)
57{ 56{
58 return 0; 57 return 0;
59} 58}
60
61STATIC bool
62is_eo_even(cube_t cube)
63{
64 uint8_t c[8], e[12], i, count;
65
66 pieces(&cube, c, e);
67
68 for (i = 0, count = 0; i < 12; i++)
69 count += (e[i] & EOBIT) >> EOSHIFT;
70
71 return count % 2 == 0;
72}

Generated with cgit - Back to sebastiano.tronto.net