nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

commit 7ff76870242b6906b6f3caf22da3c094822ed140
parent 1bd4691d9cc46ec75adbe899b289a1ebc5460721
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Fri,  1 Aug 2025 23:32:19 +0200

Move is_eo_even to more appropriate module

Diffstat:
Msrc/arch/avx2.h | 14++++++++++++++
Msrc/arch/common.h | 2++
Msrc/arch/neon.h | 18++++++++++++++++--
Msrc/arch/portable.h | 11+++++++++++
Msrc/solvers/coord/eo.h | 14--------------
5 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/src/arch/avx2.h b/src/arch/avx2.h @@ -426,3 +426,17 @@ invcoord_epe(uint64_t i) return _mm256_set_epi64x(a, SOLVED_L, 0, SOLVED_L); } + +STATIC_INLINE bool +is_eo_even(cube_t cube) +{ + uint8_t count; + __m256i e; + + e = _mm256_and_si256(cube, EO_AVX2); + e = _mm256_srli_si256(e, EOSHIFT); + + count = _mm256_reduce_add_epi8(e); + + return count % 2 == 0; +} diff --git a/src/arch/common.h b/src/arch/common.h @@ -30,6 +30,8 @@ STATIC_INLINE uint64_t coord_eo(cube_t); STATIC_INLINE uint64_t coord_esep(cube_t); STATIC_INLINE cube_t invcoord_esep(uint64_t); +STATIC_INLINE bool is_eo_even(cube_t); + STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); diff --git a/src/arch/neon.h b/src/arch/neon.h @@ -1,5 +1,6 @@ -#define CO2_NEON vdup_n_u8(0x60) -#define COCW_NEON vdup_n_u8(0x20) +#define CO2_NEON vdup_n_u8(0x60) +#define COCW_NEON vdup_n_u8(0x20) +#define EO_NEON vdupq_n_u8(0x10) #define PBITS8_NEON vdup_n_u8(PBITS) STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t); @@ -501,3 +502,16 @@ invcoord_epe(uint64_t i) .edge = vcombine_u8(vld1_u8(SOLVED_L), a) }; } + +STATIC_INLINE bool +is_eo_even(cube_t cube) +{ + int8_t count; + uint8x16_t e; + + e = vandq_u8(cube.edge, EO_NEON); + e = vshrq_n_u8(e, EOSHIFT); + count = vaddvq_u8(e); + + return count % 2 == 0; +} diff --git a/src/arch/portable.h b/src/arch/portable.h @@ -356,3 +356,14 @@ invcoord_epe(uint64_t i) return STATIC_CUBE(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, e[0]+8, e[1]+8, e[2]+8, e[3]+8); } + +STATIC_INLINE bool +is_eo_even(cube_t cube) +{ + uint8_t i, count; + + for (i = 0, count = 0; i < 12; i++) + count += (cube.edge[i] & EOBIT) >> EOSHIFT; + + return count % 2 == 0; +} diff --git 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 *); STATIC cube_t coordinate_eo_cube(uint64_t, const unsigned char *); STATIC bool coordinate_eo_isnasty(uint64_t, const unsigned char *); STATIC size_t coordinate_eo_gendata(unsigned char *); -STATIC bool is_eo_even(cube_t); STATIC coord_t coordinate_eo = { .name = "EO", @@ -57,16 +56,3 @@ coordinate_eo_gendata(unsigned char *data) { return 0; } - -STATIC bool -is_eo_even(cube_t cube) -{ - uint8_t c[8], e[12], i, count; - - pieces(&cube, c, e); - - for (i = 0, count = 0; i < 12; i++) - count += (e[i] & EOBIT) >> EOSHIFT; - - return count % 2 == 0; -}