Chris@42
|
1 /*
|
Chris@42
|
2 * Copyright (c) 2003, 2007-14 Matteo Frigo
|
Chris@42
|
3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
|
Chris@42
|
4 *
|
Chris@42
|
5 * Modifications by Romain Dolbeau & Erik Lindahl, derived from simd-avx.h
|
Chris@42
|
6 * Romain Dolbeau hereby places his modifications in the public domain.
|
Chris@42
|
7 * Erik Lindahl hereby places his modifications in the public domain.
|
Chris@42
|
8 *
|
Chris@42
|
9 * This program is free software; you can redistribute it and/or modify
|
Chris@42
|
10 * it under the terms of the GNU General Public License as published by
|
Chris@42
|
11 * the Free Software Foundation; either version 2 of the License, or
|
Chris@42
|
12 * (at your option) any later version.
|
Chris@42
|
13 *
|
Chris@42
|
14 * This program is distributed in the hope that it will be useful,
|
Chris@42
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@42
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@42
|
17 * GNU General Public License for more details.
|
Chris@42
|
18 *
|
Chris@42
|
19 * You should have received a copy of the GNU General Public License
|
Chris@42
|
20 * along with this program; if not, write to the Free Software
|
Chris@42
|
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Chris@42
|
22 *
|
Chris@42
|
23 */
|
Chris@42
|
24
|
Chris@42
|
25 #if defined(FFTW_LDOUBLE) || defined(FFTW_QUAD)
|
Chris@42
|
26 #error "AVX2 only works in single or double precision"
|
Chris@42
|
27 #endif
|
Chris@42
|
28
|
Chris@42
|
29 #ifdef FFTW_SINGLE
|
Chris@42
|
30 # define DS(d,s) s /* single-precision option */
|
Chris@42
|
31 # define SUFF(name) name ## s
|
Chris@42
|
32 #else
|
Chris@42
|
33 # define DS(d,s) d /* double-precision option */
|
Chris@42
|
34 # define SUFF(name) name ## d
|
Chris@42
|
35 #endif
|
Chris@42
|
36
|
Chris@42
|
37 #define SIMD_SUFFIX _avx2 /* for renaming */
|
Chris@42
|
38 #define VL DS(2, 4) /* SIMD complex vector length */
|
Chris@42
|
39 #define SIMD_VSTRIDE_OKA(x) ((x) == 2)
|
Chris@42
|
40 #define SIMD_STRIDE_OKPAIR SIMD_STRIDE_OK
|
Chris@42
|
41
|
Chris@42
|
42 #if defined(__GNUC__) && !defined(__AVX2__) /* sanity check */
|
Chris@42
|
43 #error "compiling simd-avx2.h without avx2 support"
|
Chris@42
|
44 #endif
|
Chris@42
|
45
|
Chris@42
|
46 #if !defined(HAVE_FMA)
|
Chris@42
|
47 #warning "You should probably enable FMAs with --enable-fma for AVX2"
|
Chris@42
|
48 #endif
|
Chris@42
|
49
|
Chris@42
|
50 #ifdef _MSC_VER
|
Chris@42
|
51 #ifndef inline
|
Chris@42
|
52 #define inline __inline
|
Chris@42
|
53 #endif
|
Chris@42
|
54 #endif
|
Chris@42
|
55
|
Chris@42
|
56 #include <immintrin.h>
|
Chris@42
|
57
|
Chris@42
|
58 typedef DS(__m256d, __m256) V;
|
Chris@42
|
59 #define VADD SUFF(_mm256_add_p)
|
Chris@42
|
60 #define VSUB SUFF(_mm256_sub_p)
|
Chris@42
|
61 #define VMUL SUFF(_mm256_mul_p)
|
Chris@42
|
62 #define VXOR SUFF(_mm256_xor_p)
|
Chris@42
|
63 #define VSHUF SUFF(_mm256_shuffle_p)
|
Chris@42
|
64 #define VPERM1 SUFF(_mm256_permute_p)
|
Chris@42
|
65
|
Chris@42
|
66 #define SHUFVALD(fp0,fp1) \
|
Chris@42
|
67 (((fp1) << 3) | ((fp0) << 2) | ((fp1) << 1) | ((fp0)))
|
Chris@42
|
68 #define SHUFVALS(fp0,fp1,fp2,fp3) \
|
Chris@42
|
69 (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | ((fp0)))
|
Chris@42
|
70
|
Chris@42
|
71 #define VDUPL(x) DS(_mm256_movedup_pd(x), _mm256_moveldup_ps(x))
|
Chris@42
|
72 #define VDUPH(x) DS(_mm256_permute_pd(x,SHUFVALD(1,1)), _mm256_movehdup_ps(x))
|
Chris@42
|
73
|
Chris@42
|
74 #define VLIT(x0, x1) DS(_mm256_set_pd(x0, x1, x0, x1), _mm256_set_ps(x0, x1, x0, x1, x0, x1, x0, x1))
|
Chris@42
|
75 #define DVK(var, val) V var = VLIT(val, val)
|
Chris@42
|
76 #define LDK(x) x
|
Chris@42
|
77
|
Chris@42
|
78 static inline V LDA(const R *x, INT ivs, const R *aligned_like)
|
Chris@42
|
79 {
|
Chris@42
|
80 (void)aligned_like; /* UNUSED */
|
Chris@42
|
81 (void)ivs; /* UNUSED */
|
Chris@42
|
82 return SUFF(_mm256_loadu_p)(x);
|
Chris@42
|
83 }
|
Chris@42
|
84
|
Chris@42
|
85 static inline void STA(R *x, V v, INT ovs, const R *aligned_like)
|
Chris@42
|
86 {
|
Chris@42
|
87 (void)aligned_like; /* UNUSED */
|
Chris@42
|
88 (void)ovs; /* UNUSED */
|
Chris@42
|
89 SUFF(_mm256_storeu_p)(x, v);
|
Chris@42
|
90 }
|
Chris@42
|
91
|
Chris@42
|
92 #if FFTW_SINGLE
|
Chris@42
|
93
|
Chris@42
|
94 #define LOADH(addr, val) _mm_loadh_pi(val, (const __m64 *)(addr))
|
Chris@42
|
95 #define LOADL(addr, val) _mm_loadl_pi(val, (const __m64 *)(addr))
|
Chris@42
|
96 #define STOREH(addr, val) _mm_storeh_pi((__m64 *)(addr), val)
|
Chris@42
|
97 #define STOREL(addr, val) _mm_storel_pi((__m64 *)(addr), val)
|
Chris@42
|
98
|
Chris@42
|
99 static inline V LD(const R *x, INT ivs, const R *aligned_like)
|
Chris@42
|
100 {
|
Chris@42
|
101 __m128 l0, l1, h0, h1;
|
Chris@42
|
102 (void)aligned_like; /* UNUSED */
|
Chris@42
|
103 #if defined(__ICC) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ > 8)
|
Chris@42
|
104 l0 = LOADL(x, SUFF(_mm_undefined_p)());
|
Chris@42
|
105 l1 = LOADL(x + ivs, SUFF(_mm_undefined_p)());
|
Chris@42
|
106 h0 = LOADL(x + 2*ivs, SUFF(_mm_undefined_p)());
|
Chris@42
|
107 h1 = LOADL(x + 3*ivs, SUFF(_mm_undefined_p)());
|
Chris@42
|
108 #else
|
Chris@42
|
109 l0 = LOADL(x, l0);
|
Chris@42
|
110 l1 = LOADL(x + ivs, l1);
|
Chris@42
|
111 h0 = LOADL(x + 2*ivs, h0);
|
Chris@42
|
112 h1 = LOADL(x + 3*ivs, h1);
|
Chris@42
|
113 #endif
|
Chris@42
|
114 l0 = SUFF(_mm_movelh_p)(l0,l1);
|
Chris@42
|
115 h0 = SUFF(_mm_movelh_p)(h0,h1);
|
Chris@42
|
116 return _mm256_insertf128_ps(_mm256_castps128_ps256(l0), h0, 1);
|
Chris@42
|
117 }
|
Chris@42
|
118
|
Chris@42
|
119 static inline void ST(R *x, V v, INT ovs, const R *aligned_like)
|
Chris@42
|
120 {
|
Chris@42
|
121 __m128 h = _mm256_extractf128_ps(v, 1);
|
Chris@42
|
122 __m128 l = _mm256_castps256_ps128(v);
|
Chris@42
|
123 (void)aligned_like; /* UNUSED */
|
Chris@42
|
124 /* WARNING: the extra_iter hack depends upon STOREL occurring
|
Chris@42
|
125 after STOREH */
|
Chris@42
|
126 STOREH(x + 3*ovs, h);
|
Chris@42
|
127 STOREL(x + 2*ovs, h);
|
Chris@42
|
128 STOREH(x + ovs, l);
|
Chris@42
|
129 STOREL(x, l);
|
Chris@42
|
130 }
|
Chris@42
|
131
|
Chris@42
|
132 #define STM2(x, v, ovs, aligned_like) /* no-op */
|
Chris@42
|
133 static inline void STN2(R *x, V v0, V v1, INT ovs)
|
Chris@42
|
134 {
|
Chris@42
|
135 V x0 = VSHUF(v0, v1, SHUFVALS(0, 1, 0, 1));
|
Chris@42
|
136 V x1 = VSHUF(v0, v1, SHUFVALS(2, 3, 2, 3));
|
Chris@42
|
137 __m128 h0 = _mm256_extractf128_ps(x0, 1);
|
Chris@42
|
138 __m128 l0 = _mm256_castps256_ps128(x0);
|
Chris@42
|
139 __m128 h1 = _mm256_extractf128_ps(x1, 1);
|
Chris@42
|
140 __m128 l1 = _mm256_castps256_ps128(x1);
|
Chris@42
|
141 *(__m128 *)(x + 3*ovs) = h1;
|
Chris@42
|
142 *(__m128 *)(x + 2*ovs) = h0;
|
Chris@42
|
143 *(__m128 *)(x + 1*ovs) = l1;
|
Chris@42
|
144 *(__m128 *)(x + 0*ovs) = l0;
|
Chris@42
|
145 }
|
Chris@42
|
146
|
Chris@42
|
147 #define STM4(x, v, ovs, aligned_like) /* no-op */
|
Chris@42
|
148 #define STN4(x, v0, v1, v2, v3, ovs) \
|
Chris@42
|
149 { \
|
Chris@42
|
150 V xxx0, xxx1, xxx2, xxx3; \
|
Chris@42
|
151 V yyy0, yyy1, yyy2, yyy3; \
|
Chris@42
|
152 xxx0 = _mm256_unpacklo_ps(v0, v2); \
|
Chris@42
|
153 xxx1 = _mm256_unpackhi_ps(v0, v2); \
|
Chris@42
|
154 xxx2 = _mm256_unpacklo_ps(v1, v3); \
|
Chris@42
|
155 xxx3 = _mm256_unpackhi_ps(v1, v3); \
|
Chris@42
|
156 yyy0 = _mm256_unpacklo_ps(xxx0, xxx2); \
|
Chris@42
|
157 yyy1 = _mm256_unpackhi_ps(xxx0, xxx2); \
|
Chris@42
|
158 yyy2 = _mm256_unpacklo_ps(xxx1, xxx3); \
|
Chris@42
|
159 yyy3 = _mm256_unpackhi_ps(xxx1, xxx3); \
|
Chris@42
|
160 *(__m128 *)(x + 0 * ovs) = _mm256_castps256_ps128(yyy0); \
|
Chris@42
|
161 *(__m128 *)(x + 4 * ovs) = _mm256_extractf128_ps(yyy0, 1); \
|
Chris@42
|
162 *(__m128 *)(x + 1 * ovs) = _mm256_castps256_ps128(yyy1); \
|
Chris@42
|
163 *(__m128 *)(x + 5 * ovs) = _mm256_extractf128_ps(yyy1, 1); \
|
Chris@42
|
164 *(__m128 *)(x + 2 * ovs) = _mm256_castps256_ps128(yyy2); \
|
Chris@42
|
165 *(__m128 *)(x + 6 * ovs) = _mm256_extractf128_ps(yyy2, 1); \
|
Chris@42
|
166 *(__m128 *)(x + 3 * ovs) = _mm256_castps256_ps128(yyy3); \
|
Chris@42
|
167 *(__m128 *)(x + 7 * ovs) = _mm256_extractf128_ps(yyy3, 1); \
|
Chris@42
|
168 }
|
Chris@42
|
169
|
Chris@42
|
170 #else
|
Chris@42
|
171 static inline __m128d VMOVAPD_LD(const R *x)
|
Chris@42
|
172 {
|
Chris@42
|
173 /* gcc-4.6 miscompiles the combination _mm256_castpd128_pd256(VMOVAPD_LD(x))
|
Chris@42
|
174 into a 256-bit vmovapd, which requires 32-byte aligment instead of
|
Chris@42
|
175 16-byte alignment.
|
Chris@42
|
176
|
Chris@42
|
177 Force the use of vmovapd via asm until compilers stabilize.
|
Chris@42
|
178 */
|
Chris@42
|
179 #if defined(__GNUC__)
|
Chris@42
|
180 __m128d var;
|
Chris@42
|
181 __asm__("vmovapd %1, %0\n" : "=x"(var) : "m"(x[0]));
|
Chris@42
|
182 return var;
|
Chris@42
|
183 #else
|
Chris@42
|
184 return *(const __m128d *)x;
|
Chris@42
|
185 #endif
|
Chris@42
|
186 }
|
Chris@42
|
187
|
Chris@42
|
188 static inline V LD(const R *x, INT ivs, const R *aligned_like)
|
Chris@42
|
189 {
|
Chris@42
|
190 V var;
|
Chris@42
|
191 (void)aligned_like; /* UNUSED */
|
Chris@42
|
192 var = _mm256_castpd128_pd256(VMOVAPD_LD(x));
|
Chris@42
|
193 var = _mm256_insertf128_pd(var, *(const __m128d *)(x+ivs), 1);
|
Chris@42
|
194 return var;
|
Chris@42
|
195 }
|
Chris@42
|
196
|
Chris@42
|
197 static inline void ST(R *x, V v, INT ovs, const R *aligned_like)
|
Chris@42
|
198 {
|
Chris@42
|
199 (void)aligned_like; /* UNUSED */
|
Chris@42
|
200 /* WARNING: the extra_iter hack depends upon the store of the low
|
Chris@42
|
201 part occurring after the store of the high part */
|
Chris@42
|
202 *(__m128d *)(x + ovs) = _mm256_extractf128_pd(v, 1);
|
Chris@42
|
203 *(__m128d *)x = _mm256_castpd256_pd128(v);
|
Chris@42
|
204 }
|
Chris@42
|
205
|
Chris@42
|
206
|
Chris@42
|
207 #define STM2 ST
|
Chris@42
|
208 #define STN2(x, v0, v1, ovs) /* nop */
|
Chris@42
|
209 #define STM4(x, v, ovs, aligned_like) /* no-op */
|
Chris@42
|
210
|
Chris@42
|
211 /* STN4 is a macro, not a function, thanks to Visual C++ developers
|
Chris@42
|
212 deciding "it would be infrequent that people would want to pass more
|
Chris@42
|
213 than 3 [__m128 parameters] by value." Even though the comment
|
Chris@42
|
214 was made about __m128 parameters, it appears to apply to __m256
|
Chris@42
|
215 parameters as well. */
|
Chris@42
|
216 #define STN4(x, v0, v1, v2, v3, ovs) \
|
Chris@42
|
217 { \
|
Chris@42
|
218 V xxx0, xxx1, xxx2, xxx3; \
|
Chris@42
|
219 xxx0 = _mm256_unpacklo_pd(v0, v1); \
|
Chris@42
|
220 xxx1 = _mm256_unpackhi_pd(v0, v1); \
|
Chris@42
|
221 xxx2 = _mm256_unpacklo_pd(v2, v3); \
|
Chris@42
|
222 xxx3 = _mm256_unpackhi_pd(v2, v3); \
|
Chris@42
|
223 STA(x, _mm256_permute2f128_pd(xxx0, xxx2, 0x20), 0, 0); \
|
Chris@42
|
224 STA(x + ovs, _mm256_permute2f128_pd(xxx1, xxx3, 0x20), 0, 0); \
|
Chris@42
|
225 STA(x + 2 * ovs, _mm256_permute2f128_pd(xxx0, xxx2, 0x31), 0, 0); \
|
Chris@42
|
226 STA(x + 3 * ovs, _mm256_permute2f128_pd(xxx1, xxx3, 0x31), 0, 0); \
|
Chris@42
|
227 }
|
Chris@42
|
228 #endif
|
Chris@42
|
229
|
Chris@42
|
230 static inline V FLIP_RI(V x)
|
Chris@42
|
231 {
|
Chris@42
|
232 return VPERM1(x, DS(SHUFVALD(1, 0), SHUFVALS(1, 0, 3, 2)));
|
Chris@42
|
233 }
|
Chris@42
|
234
|
Chris@42
|
235 static inline V VCONJ(V x)
|
Chris@42
|
236 {
|
Chris@42
|
237 V pmpm = VLIT(-0.0, 0.0);
|
Chris@42
|
238 return VXOR(pmpm, x);
|
Chris@42
|
239 }
|
Chris@42
|
240
|
Chris@42
|
241 static inline V VBYI(V x)
|
Chris@42
|
242 {
|
Chris@42
|
243 return FLIP_RI(VCONJ(x));
|
Chris@42
|
244 }
|
Chris@42
|
245
|
Chris@42
|
246 /* FMA support */
|
Chris@42
|
247 #define VFMA SUFF(_mm256_fmadd_p)
|
Chris@42
|
248 #define VFNMS SUFF(_mm256_fnmadd_p)
|
Chris@42
|
249 #define VFMS SUFF(_mm256_fmsub_p)
|
Chris@42
|
250 #define VFMAI(b, c) SUFF(_mm256_addsub_p)(c, FLIP_RI(b)) /* VADD(c, VBYI(b)) */
|
Chris@42
|
251 #define VFNMSI(b, c) VSUB(c, VBYI(b))
|
Chris@42
|
252 #define VFMACONJ(b,c) VADD(VCONJ(b),c)
|
Chris@42
|
253 #define VFMSCONJ(b,c) VSUB(VCONJ(b),c)
|
Chris@42
|
254 #define VFNMSCONJ(b,c) SUFF(_mm256_addsub_p)(c, b) /* VSUB(c, VCONJ(b)) */
|
Chris@42
|
255
|
Chris@42
|
256 static inline V VZMUL(V tx, V sr)
|
Chris@42
|
257 {
|
Chris@42
|
258 /* V tr = VDUPL(tx); */
|
Chris@42
|
259 /* V ti = VDUPH(tx); */
|
Chris@42
|
260 /* tr = VMUL(sr, tr); */
|
Chris@42
|
261 /* sr = VBYI(sr); */
|
Chris@42
|
262 /* return VFMA(ti, sr, tr); */
|
Chris@42
|
263 return SUFF(_mm256_fmaddsub_p)(sr, VDUPL(tx), VMUL(FLIP_RI(sr), VDUPH(tx)));
|
Chris@42
|
264 }
|
Chris@42
|
265
|
Chris@42
|
266 static inline V VZMULJ(V tx, V sr)
|
Chris@42
|
267 {
|
Chris@42
|
268 /* V tr = VDUPL(tx); */
|
Chris@42
|
269 /* V ti = VDUPH(tx); */
|
Chris@42
|
270 /* tr = VMUL(sr, tr); */
|
Chris@42
|
271 /* sr = VBYI(sr); */
|
Chris@42
|
272 /* return VFNMS(ti, sr, tr); */
|
Chris@42
|
273 return SUFF(_mm256_fmsubadd_p)(sr, VDUPL(tx), VMUL(FLIP_RI(sr), VDUPH(tx)));
|
Chris@42
|
274 }
|
Chris@42
|
275
|
Chris@42
|
276 static inline V VZMULI(V tx, V sr)
|
Chris@42
|
277 {
|
Chris@42
|
278 V tr = VDUPL(tx);
|
Chris@42
|
279 V ti = VDUPH(tx);
|
Chris@42
|
280 ti = VMUL(ti, sr);
|
Chris@42
|
281 sr = VBYI(sr);
|
Chris@42
|
282 return VFMS(tr, sr, ti);
|
Chris@42
|
283 /*
|
Chris@42
|
284 * Keep the old version
|
Chris@42
|
285 * (2 permute, 1 shuffle, 1 constant load (L1), 1 xor, 2 fp), since the below FMA one
|
Chris@42
|
286 * would be 2 permute, 1 shuffle, 1 xor (setzero), 3 fp), but with a longer pipeline.
|
Chris@42
|
287 *
|
Chris@42
|
288 * Alternative new fma version:
|
Chris@42
|
289 * return SUFF(_mm256_addsub_p)(SUFF(_mm256_fnmadd_p)(sr, VDUPH(tx), SUFF(_mm256_setzero_p)()),
|
Chris@42
|
290 * VMUL(FLIP_RI(sr), VDUPL(tx)));
|
Chris@42
|
291 */
|
Chris@42
|
292 }
|
Chris@42
|
293
|
Chris@42
|
294 static inline V VZMULIJ(V tx, V sr)
|
Chris@42
|
295 {
|
Chris@42
|
296 /* V tr = VDUPL(tx); */
|
Chris@42
|
297 /* V ti = VDUPH(tx); */
|
Chris@42
|
298 /* ti = VMUL(ti, sr); */
|
Chris@42
|
299 /* sr = VBYI(sr); */
|
Chris@42
|
300 /* return VFMA(tr, sr, ti); */
|
Chris@42
|
301 return SUFF(_mm256_fmaddsub_p)(sr, VDUPH(tx), VMUL(FLIP_RI(sr), VDUPL(tx)));
|
Chris@42
|
302 }
|
Chris@42
|
303
|
Chris@42
|
304 /* twiddle storage #1: compact, slower */
|
Chris@42
|
305 #ifdef FFTW_SINGLE
|
Chris@42
|
306 # define VTW1(v,x) {TW_CEXP, v, x}, {TW_CEXP, v+1, x}, {TW_CEXP, v+2, x}, {TW_CEXP, v+3, x}
|
Chris@42
|
307 #else
|
Chris@42
|
308 # define VTW1(v,x) {TW_CEXP, v, x}, {TW_CEXP, v+1, x}
|
Chris@42
|
309 #endif
|
Chris@42
|
310 #define TWVL1 (VL)
|
Chris@42
|
311
|
Chris@42
|
312 static inline V BYTW1(const R *t, V sr)
|
Chris@42
|
313 {
|
Chris@42
|
314 return VZMUL(LDA(t, 2, t), sr);
|
Chris@42
|
315 }
|
Chris@42
|
316
|
Chris@42
|
317 static inline V BYTWJ1(const R *t, V sr)
|
Chris@42
|
318 {
|
Chris@42
|
319 return VZMULJ(LDA(t, 2, t), sr);
|
Chris@42
|
320 }
|
Chris@42
|
321
|
Chris@42
|
322 /* twiddle storage #2: twice the space, faster (when in cache) */
|
Chris@42
|
323 #ifdef FFTW_SINGLE
|
Chris@42
|
324 # define VTW2(v,x) \
|
Chris@42
|
325 {TW_COS, v, x}, {TW_COS, v, x}, {TW_COS, v+1, x}, {TW_COS, v+1, x}, \
|
Chris@42
|
326 {TW_COS, v+2, x}, {TW_COS, v+2, x}, {TW_COS, v+3, x}, {TW_COS, v+3, x}, \
|
Chris@42
|
327 {TW_SIN, v, -x}, {TW_SIN, v, x}, {TW_SIN, v+1, -x}, {TW_SIN, v+1, x}, \
|
Chris@42
|
328 {TW_SIN, v+2, -x}, {TW_SIN, v+2, x}, {TW_SIN, v+3, -x}, {TW_SIN, v+3, x}
|
Chris@42
|
329 #else
|
Chris@42
|
330 # define VTW2(v,x) \
|
Chris@42
|
331 {TW_COS, v, x}, {TW_COS, v, x}, {TW_COS, v+1, x}, {TW_COS, v+1, x}, \
|
Chris@42
|
332 {TW_SIN, v, -x}, {TW_SIN, v, x}, {TW_SIN, v+1, -x}, {TW_SIN, v+1, x}
|
Chris@42
|
333 #endif
|
Chris@42
|
334 #define TWVL2 (2 * VL)
|
Chris@42
|
335
|
Chris@42
|
336 static inline V BYTW2(const R *t, V sr)
|
Chris@42
|
337 {
|
Chris@42
|
338 const V *twp = (const V *)t;
|
Chris@42
|
339 V si = FLIP_RI(sr);
|
Chris@42
|
340 V tr = twp[0], ti = twp[1];
|
Chris@42
|
341 return VFMA(tr, sr, VMUL(ti, si));
|
Chris@42
|
342 }
|
Chris@42
|
343
|
Chris@42
|
344 static inline V BYTWJ2(const R *t, V sr)
|
Chris@42
|
345 {
|
Chris@42
|
346 const V *twp = (const V *)t;
|
Chris@42
|
347 V si = FLIP_RI(sr);
|
Chris@42
|
348 V tr = twp[0], ti = twp[1];
|
Chris@42
|
349 return VFNMS(ti, si, VMUL(tr, sr));
|
Chris@42
|
350 }
|
Chris@42
|
351
|
Chris@42
|
352 /* twiddle storage #3 */
|
Chris@42
|
353 #define VTW3 VTW1
|
Chris@42
|
354 #define TWVL3 TWVL1
|
Chris@42
|
355
|
Chris@42
|
356 /* twiddle storage for split arrays */
|
Chris@42
|
357 #ifdef FFTW_SINGLE
|
Chris@42
|
358 # define VTWS(v,x) \
|
Chris@42
|
359 {TW_COS, v, x}, {TW_COS, v+1, x}, {TW_COS, v+2, x}, {TW_COS, v+3, x}, \
|
Chris@42
|
360 {TW_COS, v+4, x}, {TW_COS, v+5, x}, {TW_COS, v+6, x}, {TW_COS, v+7, x}, \
|
Chris@42
|
361 {TW_SIN, v, x}, {TW_SIN, v+1, x}, {TW_SIN, v+2, x}, {TW_SIN, v+3, x}, \
|
Chris@42
|
362 {TW_SIN, v+4, x}, {TW_SIN, v+5, x}, {TW_SIN, v+6, x}, {TW_SIN, v+7, x}
|
Chris@42
|
363 #else
|
Chris@42
|
364 # define VTWS(v,x) \
|
Chris@42
|
365 {TW_COS, v, x}, {TW_COS, v+1, x}, {TW_COS, v+2, x}, {TW_COS, v+3, x}, \
|
Chris@42
|
366 {TW_SIN, v, x}, {TW_SIN, v+1, x}, {TW_SIN, v+2, x}, {TW_SIN, v+3, x}
|
Chris@42
|
367 #endif
|
Chris@42
|
368 #define TWVLS (2 * VL)
|
Chris@42
|
369
|
Chris@42
|
370 #define VLEAVE _mm256_zeroupper
|
Chris@42
|
371
|
Chris@42
|
372 #include "simd-common.h"
|