aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-19 07:32:09 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-19 07:32:09 +0100
commitde04d37e8520079f5bba3b1a87d42313297543db (patch)
treedcbf454949def970c428a9b4627ae04e0e9ad1fb /src
parentd5c60236c06e67e8da45e63843b37e5d619e9d7b (diff)
downloadnissy-core-h48-corner-estimate.tar.gz
nissy-core-h48-corner-estimate.zip
Add coordinate solvers for cornersh48-corner-estimate
Diffstat (limited to '')
-rw-r--r--src/arch/avx2.h12
-rw-r--r--src/arch/common.h1
-rw-r--r--src/arch/neon.h10
-rw-r--r--src/arch/portable.h13
-rw-r--r--src/core/cube.h9
-rw-r--r--src/solvers/coord/common.h12
-rw-r--r--src/solvers/coord/coord.h1
-rw-r--r--src/solvers/coord/corners.h72
-rw-r--r--src/solvers/coord/list.h1
-rw-r--r--src/solvers/coord/types_macros.h1
-rw-r--r--src/solvers/dispatch.h1
-rw-r--r--src/solvers/solvers.h2
12 files changed, 133 insertions, 2 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index 5a62213..b80b0fb 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -160,6 +160,16 @@ coord_co(cube_t c)
160 return ret; 160 return ret;
161} 161}
162 162
163STATIC_INLINE void
164copy_co(cube_t cube[static 1], cube_t co)
165{
166 cube_t coclean;
167
168 coclean = _mm256_and_si256(co, CO2_AVX2);
169 *cube = _mm256_andnot_si256(CO2_AVX2, *cube);
170 *cube = _mm256_or_si256(*cube, coclean);
171}
172
163STATIC_INLINE cube_t 173STATIC_INLINE cube_t
164invcoord_co(uint64_t coord) 174invcoord_co(uint64_t coord)
165{ 175{
@@ -174,7 +184,7 @@ invcoord_co(uint64_t coord)
174 184
175 cc = _mm256_loadu_si256((__m256i *)mem); 185 cc = _mm256_loadu_si256((__m256i *)mem);
176 cube = SOLVED_CUBE; 186 cube = SOLVED_CUBE;
177 copy_corners(&cube, cc); 187 copy_co(&cube, cc);
178 188
179 return cube; 189 return cube;
180} 190}
diff --git a/src/arch/common.h b/src/arch/common.h
index f06f8d7..4412562 100644
--- a/src/arch/common.h
+++ b/src/arch/common.h
@@ -35,6 +35,7 @@ STATIC_INLINE cube_t invcoord_epudsep(uint64_t);
35STATIC_INLINE bool is_eo_even(cube_t); 35STATIC_INLINE bool is_eo_even(cube_t);
36 36
37STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); 37STATIC_INLINE void copy_corners(cube_t [static 1], cube_t);
38STATIC_INLINE void copy_co(cube_t [static 1], cube_t);
38STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); 39STATIC_INLINE void copy_edges(cube_t [static 1], cube_t);
39STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); 40STATIC_INLINE void set_eo(cube_t [static 1], uint64_t);
40 41
diff --git a/src/arch/neon.h b/src/arch/neon.h
index 9871125..f997813 100644
--- a/src/arch/neon.h
+++ b/src/arch/neon.h
@@ -232,6 +232,16 @@ coord_co(cube_t c)
232 return ret; 232 return ret;
233} 233}
234 234
235STATIC_INLINE void
236copy_co(cube_t cube[static 1], cube_t co)
237{
238 uint8x8_t coclean;
239
240 coclean = vand_u8(co.corner, CO2_NEON);
241 cube->corner = vbic_u8(cube->corner, CO2_NEON);
242 cube->corner = vorr_u8(cube->corner, coclean);
243}
244
235STATIC_INLINE cube_t 245STATIC_INLINE cube_t
236invcoord_co(uint64_t coord) 246invcoord_co(uint64_t coord)
237{ 247{
diff --git a/src/arch/portable.h b/src/arch/portable.h
index c7f2de0..4b66fb6 100644
--- a/src/arch/portable.h
+++ b/src/arch/portable.h
@@ -154,6 +154,19 @@ inverse(cube_t cube)
154 return ret; 154 return ret;
155} 155}
156 156
157STATIC_INLINE void
158copy_co(cube_t cube[static 1], cube_t co)
159{
160 uint8_t c;
161 size_t i;
162
163 for (i = 0; i < 8; i++) {
164 c = cube->corner[i] & COBITS;
165 cube->corner[i] ^= c;
166 cube->corner[i] |= co.corner[i] & COBITS;
167 }
168}
169
157STATIC_INLINE uint64_t 170STATIC_INLINE uint64_t
158coord_co(cube_t c) 171coord_co(cube_t c)
159{ 172{
diff --git a/src/core/cube.h b/src/core/cube.h
index 3ba282e..9e79dda 100644
--- a/src/core/cube.h
+++ b/src/core/cube.h
@@ -1,3 +1,5 @@
1STATIC bool cube_true(cube_t);
2
1STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); 3STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]);
2STATIC bool isconsistent(oriented_cube_t); 4STATIC bool isconsistent(oriented_cube_t);
3STATIC bool issolvable(oriented_cube_t); 5STATIC bool issolvable(oriented_cube_t);
@@ -19,6 +21,13 @@ STATIC uint8_t b32tocorner(char);
19STATIC char edgetob32(uint8_t); 21STATIC char edgetob32(uint8_t);
20STATIC char cornertob32(uint8_t); 22STATIC char cornertob32(uint8_t);
21 23
24/* Used e.g. by the CORNERS coordinate, when a function pointer is needed */
25STATIC bool
26cube_true(cube_t cube)
27{
28 return true;
29}
30
22STATIC cube_t 31STATIC cube_t
23cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) 32cubefromarray(uint8_t c[static 8], uint8_t e[static 12])
24{ 33{
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h
index 5f2435d..d154636 100644
--- a/src/solvers/coord/common.h
+++ b/src/solvers/coord/common.h
@@ -14,6 +14,7 @@ STATIC bool coord_is_solved(
14 14
15STATIC cube_t coordinate_merge_ce(cube_t, cube_t); 15STATIC cube_t coordinate_merge_ce(cube_t, cube_t);
16STATIC cube_t coordinate_merge_ec(cube_t, cube_t); 16STATIC cube_t coordinate_merge_ec(cube_t, cube_t);
17STATIC cube_t coordinate_merge_cpco(cube_t, cube_t);
17 18
18STATIC uint64_t 19STATIC uint64_t
19coord_coord_generic( 20coord_coord_generic(
@@ -215,3 +216,14 @@ coordinate_merge_ec(cube_t edges, cube_t corners)
215{ 216{
216 return coordinate_merge_ce(corners, edges); 217 return coordinate_merge_ce(corners, edges);
217} 218}
219
220STATIC cube_t
221coordinate_merge_cpco(cube_t cp, cube_t co)
222{
223 cube_t merged;
224
225 merged = cp;
226 copy_co(&merged, co);
227
228 return merged;
229}
diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h
index db40239..2ef8482 100644
--- a/src/solvers/coord/coord.h
+++ b/src/solvers/coord/coord.h
@@ -8,6 +8,7 @@
8#include "cpepe.h" 8#include "cpepe.h"
9#include "drfin.h" 9#include "drfin.h"
10#include "htr.h" 10#include "htr.h"
11#include "corners.h"
11#include "list.h" 12#include "list.h"
12#include "utils.h" 13#include "utils.h"
13#include "gendata.h" 14#include "gendata.h"
diff --git a/src/solvers/coord/corners.h b/src/solvers/coord/corners.h
new file mode 100644
index 0000000..cc0d9a5
--- /dev/null
+++ b/src/solvers/coord/corners.h
@@ -0,0 +1,72 @@
1#define CLASSES_CP_48 984
2
3STATIC uint64_t coordinate_corners_coord(const cube_t, const unsigned char *);
4STATIC cube_t coordinate_corners_cube(uint64_t, const unsigned char *);
5STATIC bool coordinate_corners_isnasty(uint64_t, const unsigned char *);
6STATIC size_t coordinate_corners_gendata(unsigned char *);
7
8STATIC coord_t coordinate_corners = {
9 .name = "CORNERS",
10 .coord = &coordinate_corners_coord,
11 .cube = &coordinate_corners_cube,
12 .isnasty = &coordinate_corners_isnasty,
13 .gendata = coordinate_corners_gendata,
14 .max = CLASSES_CP_48 * POW_3_7,
15 .trans_mask = TM_ALLTRANS,
16 .moves_mask_gendata = MM18_ALLMOVES,
17 .moves_mask_solve = MM18_ALLMOVES,
18 .is_admissible = &solution_always_valid,
19 .solution_prune = NULL,
20 .is_solvable = &cube_true,
21 .is_solved = NULL,
22 .allow_niss = false,
23 .pruning_distribution = {
24 [0] = 1,
25 [1] = 2,
26 [2] = 9,
27 [3] = 76,
28 [4] = 708,
29 [5] = 5022,
30 [6] = 28248,
31 [7] = 132076,
32 [8] = 505705,
33 [9] = 1102421,
34 [10] = 375380,
35 [11] = 2360,
36 },
37 .pruning_max = 11,
38 .sym = {
39 .classes = CLASSES_CP_48,
40 .max = FACT_8,
41 .coord = &coord_cp,
42 .cube = &invcoord_cp,
43 .max2 = POW_3_7,
44 .coord2 = &coord_co,
45 .cube2 = &invcoord_co,
46 .merge = &coordinate_merge_cpco,
47 },
48};
49
50STATIC uint64_t
51coordinate_corners_coord(const cube_t cube, const unsigned char *data)
52{
53 return coord_coord_generic(&coordinate_corners, cube, data);
54}
55
56STATIC cube_t
57coordinate_corners_cube(uint64_t i, const unsigned char *data)
58{
59 return coord_cube_generic(&coordinate_corners, i, data);
60}
61
62STATIC bool
63coordinate_corners_isnasty(uint64_t i, const unsigned char *data)
64{
65 return coord_isnasty_generic(&coordinate_corners, i, data);
66}
67
68STATIC size_t
69coordinate_corners_gendata(unsigned char *data)
70{
71 return coord_gendata_generic(&coordinate_corners, data);
72}
diff --git a/src/solvers/coord/list.h b/src/solvers/coord/list.h
index 9b59969..f2b7368 100644
--- a/src/solvers/coord/list.h
+++ b/src/solvers/coord/list.h
@@ -6,6 +6,7 @@ coord_t *all_coordinates[] = {
6 &coordinate_drslice, 6 &coordinate_drslice,
7 &coordinate_cpepe, 7 &coordinate_cpepe,
8 &coordinate_htr, 8 &coordinate_htr,
9 &coordinate_corners,
9 NULL 10 NULL
10}; 11};
11 12
diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h
index 98f9822..a9e604c 100644
--- a/src/solvers/coord/types_macros.h
+++ b/src/solvers/coord/types_macros.h
@@ -30,6 +30,7 @@ typedef struct {
30 bool (*is_admissible)(const solution_moves_t[static 1]); 30 bool (*is_admissible)(const solution_moves_t[static 1]);
31 bool (*solution_prune)(const solution_moves_t[static 1]); 31 bool (*solution_prune)(const solution_moves_t[static 1]);
32 bool (*is_solvable)(cube_t); 32 bool (*is_solvable)(cube_t);
33 /* if is_solved is nulle, coord == 0 is used */
33 bool (*is_solved)(uint64_t, const unsigned char *); 34 bool (*is_solved)(uint64_t, const unsigned char *);
34 uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN]; 35 uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN];
35 uint8_t pruning_max; 36 uint8_t pruning_max;
diff --git a/src/solvers/dispatch.h b/src/solvers/dispatch.h
index 71b3947..8147929 100644
--- a/src/solvers/dispatch.h
+++ b/src/solvers/dispatch.h
@@ -65,6 +65,7 @@ const char *solver_aliases[][2] = {
65 { "htr-drud", "coord_HTR_UF" }, 65 { "htr-drud", "coord_HTR_UF" },
66 { "htr-drrl", "coord_HTR_LF" }, 66 { "htr-drrl", "coord_HTR_LF" },
67 { "htr-drfb", "coord_HTR_BU" }, 67 { "htr-drfb", "coord_HTR_BU" },
68 { "corners", "coord_CORNERS_UF" },
68 { NULL, NULL } 69 { NULL, NULL }
69}; 70};
70 71
diff --git a/src/solvers/solvers.h b/src/solvers/solvers.h
index 27ae627..e19b08a 100644
--- a/src/solvers/solvers.h
+++ b/src/solvers/solvers.h
@@ -3,6 +3,6 @@
3#include "tables_types_macros.h" 3#include "tables_types_macros.h"
4#include "tables.h" 4#include "tables.h"
5#include "distribution.h" 5#include "distribution.h"
6#include "h48/h48.h"
7#include "coord/coord.h" 6#include "coord/coord.h"
7#include "h48/h48.h"
8#include "dispatch.h" 8#include "dispatch.h"

Generated with cgit - Back to sebastiano.tronto.net