aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cube.c1
-rw-r--r--src/cube_avx2.h48
-rw-r--r--src/cube_portable.h36
-rw-r--r--src/solve_h48.h9
4 files changed, 76 insertions, 18 deletions
diff --git a/src/cube.c b/src/cube.c
index 27d54b4..a6b733e 100644
--- a/src/cube.c
+++ b/src/cube.c
@@ -1,5 +1,6 @@
1#include <inttypes.h> 1#include <inttypes.h>
2#include <stdbool.h> 2#include <stdbool.h>
3#include <stdlib.h> /* TODO: Used only for malloc, remove if possible */
3#include <string.h> 4#include <string.h>
4 5
5#ifdef DEBUG 6#ifdef DEBUG
diff --git a/src/cube_avx2.h b/src/cube_avx2.h
index 42fb9d1..8d1c940 100644
--- a/src/cube_avx2.h
+++ b/src/cube_avx2.h
@@ -23,9 +23,12 @@ _static_inline int64_t coord_fast_co(cube_fast_t);
23_static_inline int64_t coord_fast_csep(cube_fast_t); 23_static_inline int64_t coord_fast_csep(cube_fast_t);
24_static_inline int64_t coord_fast_cocsep(cube_fast_t); 24_static_inline int64_t coord_fast_cocsep(cube_fast_t);
25_static_inline int64_t coord_fast_eo(cube_fast_t); 25_static_inline int64_t coord_fast_eo(cube_fast_t);
26_static_inline void set_eo_fast(cube_fast_t *, int64_t);
27_static_inline int64_t coord_fast_esep(cube_fast_t); 26_static_inline int64_t coord_fast_esep(cube_fast_t);
28 27
28_static_inline void copy_corners_fast(cube_fast_t *, cube_fast_t);
29_static_inline void copy_edges_fast(cube_fast_t *, cube_fast_t);
30_static_inline void set_eo_fast(cube_fast_t *, int64_t);
31
29_static_inline cube_fast_t 32_static_inline cube_fast_t
30fastcube( 33fastcube(
31 uint8_t c_ufr, 34 uint8_t c_ufr,
@@ -199,12 +202,6 @@ coord_fast_eo(cube_fast_t c)
199 return mask >> 17; 202 return mask >> 17;
200} 203}
201 204
202_static_inline void
203set_eo_fast(cube_fast_t *c, int64_t eo)
204{
205 /* TODO */
206}
207
208_static_inline int64_t 205_static_inline int64_t
209coord_fast_esep(cube_fast_t c) 206coord_fast_esep(cube_fast_t c)
210{ 207{
@@ -234,3 +231,40 @@ coord_fast_esep(cube_fast_t c)
234 231
235 return ret1 * 70 + ret2; 232 return ret1 * 70 + ret2;
236} 233}
234
235_static_inline void
236copy_corners_fast(cube_fast_t *dest, cube_fast_t src)
237{
238 *dest = _mm256_blend_epi32(*dest, src, 0x0F);
239}
240
241_static_inline void
242copy_edges_fast(cube_fast_t *dest, cube_fast_t src)
243{
244 *dest = _mm256_blend_epi32(*dest, src, 0xF0);
245}
246
247_static_inline void
248set_eo_fast(cube_fast_t *cube, int64_t eo)
249{
250 int64_t eo12, eotop, eobot;
251 __m256i veo;
252
253 eo12 = (eo << 1) + (_mm_popcnt_u64(eo) % 2);
254 eotop = (eo12 & (1 << 11)) << 17 |
255 (eo12 & (1 << 10)) << 10 |
256 (eo12 & (1 << 9)) << 3 |
257 (eo12 & (1 << 8)) >> 4;
258 eobot = (eo12 & (1 << 7)) << 53 |
259 (eo12 & (1 << 6)) << 46 |
260 (eo12 & (1 << 5)) << 39 |
261 (eo12 & (1 << 4)) << 32 |
262 (eo12 & (1 << 3)) << 25 |
263 (eo12 & (1 << 2)) << 18 |
264 (eo12 & (1 << 1)) << 11 |
265 (eo12 & 1) << 4;
266 veo = _mm256_set_epi64x(eotop, eobot, 0, 0);
267
268 *cube = _mm256_andnot_si256(_eo_avx2, *cube);
269 *cube = _mm256_or_si256(*cube, veo);
270}
diff --git a/src/cube_portable.h b/src/cube_portable.h
index fcd1d55..125c300 100644
--- a/src/cube_portable.h
+++ b/src/cube_portable.h
@@ -17,9 +17,12 @@ _static_inline int64_t coord_fast_co(cube_fast_t);
17_static_inline int64_t coord_fast_csep(cube_fast_t); 17_static_inline int64_t coord_fast_csep(cube_fast_t);
18_static_inline int64_t coord_fast_cocsep(cube_fast_t); 18_static_inline int64_t coord_fast_cocsep(cube_fast_t);
19_static_inline int64_t coord_fast_eo(cube_fast_t); 19_static_inline int64_t coord_fast_eo(cube_fast_t);
20_static_inline void set_eo_fast(cube_fast_t *, int64_t eo);
21_static_inline int64_t coord_fast_esep(cube_fast_t); 20_static_inline int64_t coord_fast_esep(cube_fast_t);
22 21
22_static_inline void copy_corners_fast(cube_fast_t *, cube_fast_t);
23_static_inline void copy_edges_fast(cube_fast_t *, cube_fast_t);
24_static_inline void set_eo_fast(cube_fast_t *, int64_t);
25
23_static_inline cube_fast_t 26_static_inline cube_fast_t
24fastcube( 27fastcube(
25 uint8_t c_ufr, 28 uint8_t c_ufr,
@@ -189,12 +192,6 @@ coord_fast_eo(cube_fast_t c)
189 return ret; 192 return ret;
190} 193}
191 194
192_static_inline void
193_set_eo_fast(cube_fast_t *cube, int64_t eo)
194{
195 /* TODO */
196}
197
198/* 195/*
199We encode the edge separation as a number from 0 to C(12,4)*C(8,4). 196We encode the edge separation as a number from 0 to C(12,4)*C(8,4).
200It can be seen as the composition of two "subset index" coordinates. 197It can be seen as the composition of two "subset index" coordinates.
@@ -229,3 +226,28 @@ coord_fast_esep(cube_fast_t c)
229 226
230 return ret1 * 70 + ret2; 227 return ret1 * 70 + ret2;
231} 228}
229
230_static_inline void
231copy_corners_fast(cube_fast_t *dest, cube_fast_t src)
232{
233 memcpy(&dest->corner, src.corner, sizeof(src.corner));
234}
235
236_static_inline void
237copy_edges_fast(cube_fast_t *dest, cube_fast_t src)
238{
239 memcpy(&dest->edge, src.edge, sizeof(src.edge));
240}
241
242_static_inline void
243set_eo_fast(cube_fast_t *cube, int64_t eo)
244{
245 int i, sum, flip;
246
247 for (sum = 0, i = 1; i < 12; i++, eo >>= 1) {
248 flip = eo % 2;
249 sum += flip;
250 cube->edge[i] = (cube->edge[i] & ~_eobit) | (_eobit * flip);
251 }
252 cube->edge[0] = (cube->edge[0] & ~_eobit) | (_eobit * (sum%2));
253}
diff --git a/src/solve_h48.h b/src/solve_h48.h
index e3e6de1..2fe1d69 100644
--- a/src/solve_h48.h
+++ b/src/solve_h48.h
@@ -88,16 +88,17 @@ invcoord_h48(
88 cube_fast_t ret; 88 cube_fast_t ret;
89 int64_t coclass, ee, esep, eo; 89 int64_t coclass, ee, esep, eo;
90 90
91 DBG_ASSERT(h <= 11, cubetofast(zero),
92 "invcoord_h48: h must be between 0 and 11\n");
93
91 coclass = i / H48_ESIZE; 94 coclass = i / H48_ESIZE;
92 ee = i % H48_ESIZE; 95 ee = i % H48_ESIZE;
93 esep = ee >> h; 96 esep = ee >> h;
94 eo = (ee & ((1<<h)-1)) << (11-h); 97 eo = (ee & ((1<<h)-1)) << (11-h);
95 98
96/* TODO: implement set_stuff methods 99 copy_corners_fast(&ret, crep[coclass]);
97 ret.c = crep[coclass]; 100 copy_edges_fast(&ret, erep[esep]);
98 ret.e = erep[esep];
99 set_eo_fast(&ret, eo); 101 set_eo_fast(&ret, eo);
100*/
101 102
102 return ret; 103 return ret;
103} 104}

Generated with cgit - Back to sebastiano.tronto.net