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