diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-01 23:32:19 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-01 23:32:19 +0200 |
| commit | 7ff76870242b6906b6f3caf22da3c094822ed140 (patch) | |
| tree | a99748ace111c77a30bb0e615b28cfb7aab0db1e /src/arch | |
| parent | 1bd4691d9cc46ec75adbe899b289a1ebc5460721 (diff) | |
| download | nissy-core-7ff76870242b6906b6f3caf22da3c094822ed140.tar.gz nissy-core-7ff76870242b6906b6f3caf22da3c094822ed140.zip | |
Move is_eo_even to more appropriate module
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/avx2.h | 14 | ||||
| -rw-r--r-- | src/arch/common.h | 2 | ||||
| -rw-r--r-- | src/arch/neon.h | 18 | ||||
| -rw-r--r-- | src/arch/portable.h | 11 |
4 files changed, 43 insertions, 2 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 | |||
| 430 | STATIC_INLINE bool | ||
| 431 | is_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); | |||
| 30 | STATIC_INLINE uint64_t coord_esep(cube_t); | 30 | STATIC_INLINE uint64_t coord_esep(cube_t); |
| 31 | STATIC_INLINE cube_t invcoord_esep(uint64_t); | 31 | STATIC_INLINE cube_t invcoord_esep(uint64_t); |
| 32 | 32 | ||
| 33 | STATIC_INLINE bool is_eo_even(cube_t); | ||
| 34 | |||
| 33 | STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); | 35 | STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); |
| 34 | STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); | 36 | STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); |
| 35 | STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); | 37 | STATIC_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 | ||
| 5 | STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t); | 6 | STATIC_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 | |||
| 506 | STATIC_INLINE bool | ||
| 507 | is_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 | |||
| 360 | STATIC_INLINE bool | ||
| 361 | is_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 | } | ||
