diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-03-29 09:28:59 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-03-29 09:28:59 +0100 |
| commit | 9b0be93fb5fe23ae9f1a7a57b9db60561d8673e8 (patch) | |
| tree | 8c6121fdfa40acba1c23b8b17305b9a90fabbe40 /cube.c | |
| parent | 0083a7eb4677542aced3ea2fa335bc9cf1f7b419 (diff) | |
| download | nissy-core-9b0be93fb5fe23ae9f1a7a57b9db60561d8673e8.tar.gz nissy-core-9b0be93fb5fe23ae9f1a7a57b9db60561d8673e8.zip | |
Added coordinate cpsep
Diffstat (limited to 'cube.c')
| -rw-r--r-- | cube.c | 34 |
1 files changed, 33 insertions, 1 deletions
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "cube.h" | 5 | #include "cube.h" |
| 6 | 6 | ||
| 7 | #ifdef DEBUG | 7 | #ifdef DEBUG |
| 8 | |||
| 8 | #include <stdio.h> | 9 | #include <stdio.h> |
| 9 | #define _static | 10 | #define _static |
| 10 | #define _static_inline | 11 | #define _static_inline |
| @@ -15,12 +16,15 @@ | |||
| 15 | DBG_LOG(__VA_ARGS__); \ | 16 | DBG_LOG(__VA_ARGS__); \ |
| 16 | return retval; \ | 17 | return retval; \ |
| 17 | } | 18 | } |
| 19 | |||
| 18 | #else | 20 | #else |
| 21 | |||
| 19 | #define _static static | 22 | #define _static static |
| 20 | #define _static_inline static inline | 23 | #define _static_inline static inline |
| 21 | #define DBG_LOG(...) | 24 | #define DBG_LOG(...) |
| 22 | #define DBG_WARN(condition, ...) | 25 | #define DBG_WARN(condition, ...) |
| 23 | #define DBG_ASSERT(condition, retval, ...) | 26 | #define DBG_ASSERT(condition, retval, ...) |
| 27 | |||
| 24 | #endif | 28 | #endif |
| 25 | 29 | ||
| 26 | /****************************************************************************** | 30 | /****************************************************************************** |
| @@ -495,6 +499,7 @@ typedef __m256i cube_fast_t; | |||
| 495 | 499 | ||
| 496 | #define _co2_avx2 _mm256_set_epi64x(0, 0, 0, 0x6060606060606060) | 500 | #define _co2_avx2 _mm256_set_epi64x(0, 0, 0, 0x6060606060606060) |
| 497 | #define _cocw_avx2 _mm256_set_epi64x(0, 0, 0, 0x2020202020202020) | 501 | #define _cocw_avx2 _mm256_set_epi64x(0, 0, 0, 0x2020202020202020) |
| 502 | #define _cp_avx2 _mm256_set_epi64x(0, 0, 0, 0x0707070707070707) | ||
| 498 | #define _eo_avx2 _mm256_set_epi64x(0x10101010, 0x1010101010101010, 0, 0) | 503 | #define _eo_avx2 _mm256_set_epi64x(0x10101010, 0x1010101010101010, 0, 0) |
| 499 | 504 | ||
| 500 | _static_inline cube_fast_t fastcube( | 505 | _static_inline cube_fast_t fastcube( |
| @@ -511,6 +516,7 @@ _static_inline cube_fast_t invertco_fast(cube_fast_t); | |||
| 511 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | 516 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); |
| 512 | 517 | ||
| 513 | _static_inline int64_t coord_fast_co(cube_fast_t); | 518 | _static_inline int64_t coord_fast_co(cube_fast_t); |
| 519 | _static_inline int64_t coord_fast_csep(cube_fast_t); | ||
| 514 | _static_inline int64_t coord_fast_eo(cube_fast_t); | 520 | _static_inline int64_t coord_fast_eo(cube_fast_t); |
| 515 | 521 | ||
| 516 | _static_inline cube_fast_t | 522 | _static_inline cube_fast_t |
| @@ -641,7 +647,7 @@ compose_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 641 | _static_inline int64_t | 647 | _static_inline int64_t |
| 642 | coord_fast_co(cube_fast_t c) | 648 | coord_fast_co(cube_fast_t c) |
| 643 | { | 649 | { |
| 644 | cube_fast_t co, shifted; | 650 | cube_fast_t co; |
| 645 | int64_t mem[4], ret, i, p; | 651 | int64_t mem[4], ret, i, p; |
| 646 | 652 | ||
| 647 | co = _mm256_and_si256(c, _co2_avx2); | 653 | co = _mm256_and_si256(c, _co2_avx2); |
| @@ -655,6 +661,19 @@ coord_fast_co(cube_fast_t c) | |||
| 655 | } | 661 | } |
| 656 | 662 | ||
| 657 | _static_inline int64_t | 663 | _static_inline int64_t |
| 664 | coord_fast_csep(cube_fast_t c) | ||
| 665 | { | ||
| 666 | cube_fast_t cp, shifted; | ||
| 667 | int64_t mask; | ||
| 668 | |||
| 669 | cp = _mm256_and_si256(c, _cp_avx2); | ||
| 670 | shifted = _mm256_slli_epi32(cp, 5); | ||
| 671 | mask = _mm256_movemask_epi8(shifted); | ||
| 672 | |||
| 673 | return mask & 0x7F; | ||
| 674 | } | ||
| 675 | |||
| 676 | _static_inline int64_t | ||
| 658 | coord_fast_eo(cube_fast_t c) | 677 | coord_fast_eo(cube_fast_t c) |
| 659 | { | 678 | { |
| 660 | cube_fast_t eo, shifted; | 679 | cube_fast_t eo, shifted; |
| @@ -709,6 +728,7 @@ _static_inline cube_fast_t invertco_fast(cube_fast_t); | |||
| 709 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | 728 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); |
| 710 | 729 | ||
| 711 | _static_inline int64_t coord_fast_co(cube_fast_t); | 730 | _static_inline int64_t coord_fast_co(cube_fast_t); |
| 731 | _static_inline int64_t coord_fast_csep(cube_fast_t); | ||
| 712 | _static_inline int64_t coord_fast_eo(cube_fast_t); | 732 | _static_inline int64_t coord_fast_eo(cube_fast_t); |
| 713 | 733 | ||
| 714 | _static_inline cube_fast_t | 734 | _static_inline cube_fast_t |
| @@ -844,6 +864,18 @@ coord_fast_co(cube_fast_t c) | |||
| 844 | } | 864 | } |
| 845 | 865 | ||
| 846 | _static_inline int64_t | 866 | _static_inline int64_t |
| 867 | coord_fast_csep(cube_fast_t c) | ||
| 868 | { | ||
| 869 | int i, p; | ||
| 870 | int64_t ret; | ||
| 871 | |||
| 872 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) | ||
| 873 | ret += p * ((c.corner[i] & _pbits) >> 2U); | ||
| 874 | |||
| 875 | return ret; | ||
| 876 | } | ||
| 877 | |||
| 878 | _static_inline int64_t | ||
| 847 | coord_fast_eo(cube_fast_t c) | 879 | coord_fast_eo(cube_fast_t c) |
| 848 | { | 880 | { |
| 849 | int i, p; | 881 | int i, p; |
