aboutsummaryrefslogtreecommitdiff
path: root/src/arch/avx2.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/avx2.h')
-rw-r--r--src/arch/avx2.h48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index 8d53f8f..2c3371e 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -1,19 +1,19 @@
1#define _co2_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x6060606060606060)) 1#define CO2_AVX2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x6060606060606060))
2#define _cocw_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x2020202020202020)) 2#define COCW_AVX2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x2020202020202020))
3#define _cp_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x0707070707070707)) 3#define CP_AVX2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x0707070707070707))
4#define _ep_avx2 \ 4#define EP_AVX2 \
5 _mm256_set_epi64x(INT64_C(0x0F0F0F0F), INT64_C(0x0F0F0F0F0F0F0F0F), 0, 0) 5 _mm256_set_epi64x(INT64_C(0x0F0F0F0F), INT64_C(0x0F0F0F0F0F0F0F0F), 0, 0)
6#define _eo_avx2 \ 6#define EO_AVX2 \
7 _mm256_set_epi64x(INT64_C(0x10101010), INT64_C(0x1010101010101010), 0, 0) 7 _mm256_set_epi64x(INT64_C(0x10101010), INT64_C(0x1010101010101010), 0, 0)
8 8
9#define static_cube(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ 9#define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \
10 e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ 10 e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \
11 _mm256_set_epi8(0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, \ 11 _mm256_set_epi8(0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, \
12 e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf, \ 12 e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf, \
13 0, 0, 0, 0, 0, 0, 0, 0, \ 13 0, 0, 0, 0, 0, 0, 0, 0, \
14 c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr) 14 c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr)
15#define zero _mm256_set_epi64x(0, 0, 0, 0) 15#define ZERO_CUBE _mm256_set_epi64x(0, 0, 0, 0)
16#define solved static_cube( \ 16#define SOLVED_CUBE STATIC_CUBE( \
17 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) 17 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
18 18
19STATIC void 19STATIC void
@@ -43,11 +43,11 @@ invertco(cube_t c)
43{ 43{
44 cube_t co, shleft, shright, summed, newco, cleanco, ret; 44 cube_t co, shleft, shright, summed, newco, cleanco, ret;
45 45
46 co = _mm256_and_si256(c, _co2_avx2); 46 co = _mm256_and_si256(c, CO2_AVX2);
47 shleft = _mm256_slli_epi32(co, 1); 47 shleft = _mm256_slli_epi32(co, 1);
48 shright = _mm256_srli_epi32(co, 1); 48 shright = _mm256_srli_epi32(co, 1);
49 summed = _mm256_or_si256(shleft, shright); 49 summed = _mm256_or_si256(shleft, shright);
50 newco = _mm256_and_si256(summed, _co2_avx2); 50 newco = _mm256_and_si256(summed, CO2_AVX2);
51 cleanco = _mm256_xor_si256(c, co); 51 cleanco = _mm256_xor_si256(c, co);
52 ret = _mm256_or_si256(cleanco, newco); 52 ret = _mm256_or_si256(cleanco, newco);
53 53
@@ -68,7 +68,7 @@ compose_epcpeo(cube_t c1, cube_t c2)
68 s = _mm256_andnot_si256(b, s); 68 s = _mm256_andnot_si256(b, s);
69 69
70 /* Change EO */ 70 /* Change EO */
71 eo2 = _mm256_and_si256(c2, _eo_avx2); 71 eo2 = _mm256_and_si256(c2, EO_AVX2);
72 s = _mm256_xor_si256(s, eo2); 72 s = _mm256_xor_si256(s, eo2);
73 73
74 return s; 74 return s;
@@ -99,16 +99,16 @@ compose(cube_t c1, cube_t c2)
99 s = compose_epcpeo(c1, c2); 99 s = compose_epcpeo(c1, c2);
100 100
101 /* Change CO */ 101 /* Change CO */
102 co1 = _mm256_and_si256(s, _co2_avx2); 102 co1 = _mm256_and_si256(s, CO2_AVX2);
103 co2 = _mm256_and_si256(c2, _co2_avx2); 103 co2 = _mm256_and_si256(c2, CO2_AVX2);
104 aux = _mm256_add_epi8(co1, co2); 104 aux = _mm256_add_epi8(co1, co2);
105 auy1 = _mm256_add_epi8(aux, _cocw_avx2); 105 auy1 = _mm256_add_epi8(aux, COCW_AVX2);
106 auy2 = _mm256_srli_epi32(auy1, 2); 106 auy2 = _mm256_srli_epi32(auy1, 2);
107 auz1 = _mm256_add_epi8(aux, auy2); 107 auz1 = _mm256_add_epi8(aux, auy2);
108 auz2 = _mm256_and_si256(auz1, _co2_avx2); 108 auz2 = _mm256_and_si256(auz1, CO2_AVX2);
109 109
110 /* Put together */ 110 /* Put together */
111 s = _mm256_andnot_si256(_co2_avx2, s); 111 s = _mm256_andnot_si256(CO2_AVX2, s);
112 s = _mm256_or_si256(s, auz2); 112 s = _mm256_or_si256(s, auz2);
113 113
114 return s; 114 return s;
@@ -157,9 +157,9 @@ inverse(cube_t c)
157 vi = _mm256_shuffle_epi8(vi, vi); 157 vi = _mm256_shuffle_epi8(vi, vi);
158 vi = _mm256_shuffle_epi8(vi, c); 158 vi = _mm256_shuffle_epi8(vi, c);
159 159
160 vo = _mm256_and_si256(c, _mm256_or_si256(_eo_avx2, _co2_avx2)); 160 vo = _mm256_and_si256(c, _mm256_or_si256(EO_AVX2, CO2_AVX2));
161 vo = _mm256_shuffle_epi8(vo, vi); 161 vo = _mm256_shuffle_epi8(vo, vi);
162 vp = _mm256_andnot_si256(_mm256_or_si256(_eo_avx2, _co2_avx2), vi); 162 vp = _mm256_andnot_si256(_mm256_or_si256(EO_AVX2, CO2_AVX2), vi);
163 ret = _mm256_or_si256(vp, vo); 163 ret = _mm256_or_si256(vp, vo);
164 ret = cleanaftershuffle(ret); 164 ret = cleanaftershuffle(ret);
165 165
@@ -172,7 +172,7 @@ coord_co(cube_t c)
172 cube_t co; 172 cube_t co;
173 int64_t mem[4], ret, i, p; 173 int64_t mem[4], ret, i, p;
174 174
175 co = _mm256_and_si256(c, _co2_avx2); 175 co = _mm256_and_si256(c, CO2_AVX2);
176 _mm256_storeu_si256((__m256i *)mem, co); 176 _mm256_storeu_si256((__m256i *)mem, co);
177 177
178 mem[0] >>= 5; 178 mem[0] >>= 5;
@@ -188,7 +188,7 @@ coord_csep(cube_t c)
188 cube_t cp, shifted; 188 cube_t cp, shifted;
189 int64_t mask; 189 int64_t mask;
190 190
191 cp = _mm256_and_si256(c, _cp_avx2); 191 cp = _mm256_and_si256(c, CP_AVX2);
192 shifted = _mm256_slli_epi32(cp, 5); 192 shifted = _mm256_slli_epi32(cp, 5);
193 mask = _mm256_movemask_epi8(shifted); 193 mask = _mm256_movemask_epi8(shifted);
194 194
@@ -207,7 +207,7 @@ coord_eo(cube_t c)
207 cube_t eo, shifted; 207 cube_t eo, shifted;
208 int64_t mask; 208 int64_t mask;
209 209
210 eo = _mm256_and_si256(c, _eo_avx2); 210 eo = _mm256_and_si256(c, EO_AVX2);
211 shifted = _mm256_slli_epi32(eo, 3); 211 shifted = _mm256_slli_epi32(eo, 3);
212 mask = _mm256_movemask_epi8(shifted); 212 mask = _mm256_movemask_epi8(shifted);
213 213
@@ -220,7 +220,7 @@ coord_esep(cube_t c)
220 cube_t ep; 220 cube_t ep;
221 int64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; 221 int64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1;
222 222
223 ep = _mm256_and_si256(c, _ep_avx2); 223 ep = _mm256_and_si256(c, EP_AVX2);
224 _mm256_storeu_si256((__m256i *)mem, ep); 224 _mm256_storeu_si256((__m256i *)mem, ep);
225 225
226 mem[3] <<= 8; 226 mem[3] <<= 8;
@@ -278,7 +278,7 @@ set_eo(cube_t *cube, int64_t eo)
278 (eo12 & 1) << 4; 278 (eo12 & 1) << 4;
279 veo = _mm256_set_epi64x(eotop, eobot, 0, 0); 279 veo = _mm256_set_epi64x(eotop, eobot, 0, 0);
280 280
281 *cube = _mm256_andnot_si256(_eo_avx2, *cube); 281 *cube = _mm256_andnot_si256(EO_AVX2, *cube);
282 *cube = _mm256_or_si256(*cube, veo); 282 *cube = _mm256_or_si256(*cube, veo);
283} 283}
284 284
@@ -290,7 +290,7 @@ invcoord_esep(int64_t esep)
290 290
291 invcoord_esep_array(esep % 70, esep / 70, mem+16); 291 invcoord_esep_array(esep % 70, esep / 70, mem+16);
292 292
293 ret = solved; 293 ret = SOLVED_CUBE;
294 eee = _mm256_loadu_si256((__m256i_u *)&mem); 294 eee = _mm256_loadu_si256((__m256i_u *)&mem);
295 copy_edges(&ret, eee); 295 copy_edges(&ret, eee);
296 296

Generated with cgit - Back to sebastiano.tronto.net