aboutsummaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/avx2.h49
-rw-r--r--src/arch/common.h3
-rw-r--r--src/arch/neon.h19
-rw-r--r--src/arch/portable.h42
4 files changed, 84 insertions, 29 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index ebcf84f..4682e33 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -188,6 +188,25 @@ coord_co(cube_t c)
188 return ret; 188 return ret;
189} 189}
190 190
191STATIC_INLINE cube_t
192invcoord_co(int64_t coord)
193{
194 int64_t i, c, p, co, mem[4] = {0};
195 cube_t cube, cc;
196
197 for (i = 0, p = 0, c = coord; i < 8; i++, c /= 3) {
198 co = i == 7 ? ((3 - (p % 3)) % 3) : (c % 3);
199 p += co;
200 mem[0] |= (int64_t)(i + (co << COSHIFT)) << (int64_t)(8 * i);
201 }
202
203 cc = _mm256_loadu_si256((const __m256i *)mem);
204 cube = SOLVED_CUBE;
205 copy_corners(&cube, cc);
206
207 return cube;
208}
209
191STATIC_INLINE int64_t 210STATIC_INLINE int64_t
192coord_csep(cube_t c) 211coord_csep(cube_t c)
193{ 212{
@@ -251,6 +270,21 @@ coord_esep(cube_t c)
251 return ret1 * 70 + ret2; 270 return ret1 * 70 + ret2;
252} 271}
253 272
273STATIC_INLINE cube_t
274invcoord_esep(int64_t esep)
275{
276 cube_t eee, ret;
277 uint8_t mem[32] = {0};
278
279 invcoord_esep_array(esep % 70, esep / 70, mem+16);
280
281 ret = SOLVED_CUBE;
282 eee = _mm256_loadu_si256((__m256i_u *)&mem);
283 copy_edges(&ret, eee);
284
285 return ret;
286}
287
254STATIC_INLINE void 288STATIC_INLINE void
255copy_corners(cube_t dest[static 1], cube_t src) 289copy_corners(cube_t dest[static 1], cube_t src)
256{ 290{
@@ -287,18 +321,3 @@ set_eo(cube_t cube[static 1], int64_t eo)
287 *cube = _mm256_andnot_si256(EO_AVX2, *cube); 321 *cube = _mm256_andnot_si256(EO_AVX2, *cube);
288 *cube = _mm256_or_si256(*cube, veo); 322 *cube = _mm256_or_si256(*cube, veo);
289} 323}
290
291STATIC_INLINE cube_t
292invcoord_esep(int64_t esep)
293{
294 cube_t eee, ret;
295 uint8_t mem[32] = {0};
296
297 invcoord_esep_array(esep % 70, esep / 70, mem+16);
298
299 ret = SOLVED_CUBE;
300 eee = _mm256_loadu_si256((__m256i_u *)&mem);
301 copy_edges(&ret, eee);
302
303 return ret;
304}
diff --git a/src/arch/common.h b/src/arch/common.h
index 5c1efde..e57fba9 100644
--- a/src/arch/common.h
+++ b/src/arch/common.h
@@ -9,15 +9,16 @@ STATIC_INLINE cube_t compose(cube_t, cube_t);
9STATIC_INLINE cube_t inverse(cube_t); 9STATIC_INLINE cube_t inverse(cube_t);
10 10
11STATIC_INLINE int64_t coord_co(cube_t); 11STATIC_INLINE int64_t coord_co(cube_t);
12STATIC_INLINE cube_t invcoord_co(int64_t);
12STATIC_INLINE int64_t coord_csep(cube_t); 13STATIC_INLINE int64_t coord_csep(cube_t);
13STATIC_INLINE int64_t coord_cocsep(cube_t); 14STATIC_INLINE int64_t coord_cocsep(cube_t);
14STATIC_INLINE int64_t coord_eo(cube_t); 15STATIC_INLINE int64_t coord_eo(cube_t);
15STATIC_INLINE int64_t coord_esep(cube_t); 16STATIC_INLINE int64_t coord_esep(cube_t);
17STATIC_INLINE cube_t invcoord_esep(int64_t);
16 18
17STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); 19STATIC_INLINE void copy_corners(cube_t [static 1], cube_t);
18STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); 20STATIC_INLINE void copy_edges(cube_t [static 1], cube_t);
19STATIC_INLINE void set_eo(cube_t [static 1], int64_t); 21STATIC_INLINE void set_eo(cube_t [static 1], int64_t);
20STATIC_INLINE cube_t invcoord_esep(int64_t);
21 22
22STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); 23STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]);
23STATIC_INLINE cube_t invcoord_eoesep(int64_t); 24STATIC_INLINE cube_t invcoord_eoesep(int64_t);
diff --git a/src/arch/neon.h b/src/arch/neon.h
index d5f5f8b..fc0e612 100644
--- a/src/arch/neon.h
+++ b/src/arch/neon.h
@@ -219,6 +219,25 @@ coord_co(cube_t c)
219 return ret; 219 return ret;
220} 220}
221 221
222STATIC_INLINE cube_t
223invcoord_co(int64_t coord)
224{
225 int64_t co, c, i, p;
226 uint8_t mem[8];
227 cube_t cube;
228
229 for (i = 0, p = 0, c = coord; i < 8; i++, c /= 3) {
230 co = i == 7 ? ((3 - (p % 3)) % 3) : (c % 3);
231 p += co;
232 mem[i] = i + (co << COSHIFT);
233 }
234
235 cube.corner = vld1_u8(mem);
236 cube.edge = SOLVED_CUBE.edge;
237
238 return cube;
239}
240
222STATIC_INLINE int64_t 241STATIC_INLINE int64_t
223coord_csep(cube_t c) 242coord_csep(cube_t c)
224{ 243{
diff --git a/src/arch/portable.h b/src/arch/portable.h
index 4ac5fe7..56d3074 100644
--- a/src/arch/portable.h
+++ b/src/arch/portable.h
@@ -144,8 +144,7 @@ inverse(cube_t cube)
144STATIC_INLINE int64_t 144STATIC_INLINE int64_t
145coord_co(cube_t c) 145coord_co(cube_t c)
146{ 146{
147 int i, p; 147 int i, p, ret;
148 int64_t ret;
149 148
150 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) 149 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3)
151 ret += p * (c.corner[i] >> COSHIFT); 150 ret += p * (c.corner[i] >> COSHIFT);
@@ -153,6 +152,23 @@ coord_co(cube_t c)
153 return ret; 152 return ret;
154} 153}
155 154
155STATIC_INLINE cube_t
156invcoord_co(int64_t coord)
157{
158 int64_t i, c, p;
159 cube_t cube;
160
161 cube = SOLVED_CUBE;
162 for (i = 0, p = 0, c = coord; i < 7; i++, c /= 3) {
163 p += c % 3;
164 cube.corner[i] |= (c % 3) << COSHIFT;
165 }
166
167 cube.corner[7] |= ((3 - (p % 3)) % 3) << COSHIFT;
168
169 return cube;
170}
171
156/* 172/*
157For corner separation, we consider the axis (a.k.a. tetrad) each 173For corner separation, we consider the axis (a.k.a. tetrad) each
158corner belongs to as 0 or 1 and we translate this sequence into binary. 174corner belongs to as 0 or 1 and we translate this sequence into binary.
@@ -226,6 +242,17 @@ coord_esep(cube_t c)
226 return ret1 * 70 + ret2; 242 return ret1 * 70 + ret2;
227} 243}
228 244
245STATIC_INLINE cube_t
246invcoord_esep(int64_t esep)
247{
248 cube_t ret;
249
250 ret = SOLVED_CUBE;
251 invcoord_esep_array(esep % 70, esep / 70, ret.edge);
252
253 return ret;
254}
255
229STATIC_INLINE void 256STATIC_INLINE void
230copy_corners(cube_t dest[static 1], cube_t src) 257copy_corners(cube_t dest[static 1], cube_t src)
231{ 258{
@@ -250,14 +277,3 @@ set_eo(cube_t cube[static 1], int64_t eo)
250 } 277 }
251 cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); 278 cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2));
252} 279}
253
254STATIC_INLINE cube_t
255invcoord_esep(int64_t esep)
256{
257 cube_t ret;
258
259 ret = SOLVED_CUBE;
260 invcoord_esep_array(esep % 70, esep / 70, ret.edge);
261
262 return ret;
263}

Generated with cgit - Back to sebastiano.tronto.net