annotate src/fftw-3.3.8/simd-support/simd-generic128.h @ 84:08ae793730bd

Add null config files
author Chris Cannam
date Mon, 02 Mar 2020 14:03:47 +0000
parents d0c2a83c1364
children
rev   line source
Chris@82 1 /*
Chris@82 2 * Copyright (c) 2003, 2007-14 Matteo Frigo
Chris@82 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
Chris@82 4 *
Chris@82 5 * Generic128d added by Romain Dolbeau, and turned into simd-generic128.h
Chris@82 6 * with single & double precision by Erik Lindahl.
Chris@82 7 * Romain Dolbeau hereby places his modifications in the public domain.
Chris@82 8 * Erik Lindahl hereby places his modifications in the public domain.
Chris@82 9 *
Chris@82 10 * This program is free software; you can redistribute it and/or modify
Chris@82 11 * it under the terms of the GNU General Public License as published by
Chris@82 12 * the Free Software Foundation; either version 2 of the License, or
Chris@82 13 * (at your option) any later version.
Chris@82 14 *
Chris@82 15 * This program is distributed in the hope that it will be useful,
Chris@82 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@82 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@82 18 * GNU General Public License for more details.
Chris@82 19 *
Chris@82 20 * You should have received a copy of the GNU General Public License
Chris@82 21 * along with this program; if not, write to the Free Software
Chris@82 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Chris@82 23 *
Chris@82 24 */
Chris@82 25
Chris@82 26
Chris@82 27 #if defined(FFTW_LDOUBLE) || defined(FFTW_QUAD)
Chris@82 28 # error "Generic simd128 only works in single or double precision"
Chris@82 29 #endif
Chris@82 30
Chris@82 31 #define SIMD_SUFFIX _generic_simd128 /* for renaming */
Chris@82 32
Chris@82 33 #ifdef FFTW_SINGLE
Chris@82 34 # define DS(d,s) s /* single-precision option */
Chris@82 35 # define VDUPL(x) (V){x[0],x[0],x[2],x[2]}
Chris@82 36 # define VDUPH(x) (V){x[1],x[1],x[3],x[3]}
Chris@82 37 # define DVK(var, val) V var = {val,val,val,val}
Chris@82 38 #else
Chris@82 39 # define DS(d,s) d /* double-precision option */
Chris@82 40 # define VDUPL(x) (V){x[0],x[0]}
Chris@82 41 # define VDUPH(x) (V){x[1],x[1]}
Chris@82 42 # define DVK(var, val) V var = {val, val}
Chris@82 43 #endif
Chris@82 44
Chris@82 45 #define VL DS(1,2) /* SIMD vector length, in term of complex numbers */
Chris@82 46 #define SIMD_VSTRIDE_OKA(x) DS(1,((x) == 2))
Chris@82 47 #define SIMD_STRIDE_OKPAIR SIMD_STRIDE_OK
Chris@82 48
Chris@82 49 typedef DS(double,float) V __attribute__ ((vector_size(16)));
Chris@82 50
Chris@82 51 #define VADD(a,b) ((a)+(b))
Chris@82 52 #define VSUB(a,b) ((a)-(b))
Chris@82 53 #define VMUL(a,b) ((a)*(b))
Chris@82 54
Chris@82 55
Chris@82 56 #define LDK(x) x
Chris@82 57
Chris@82 58 static inline V LDA(const R *x, INT ivs, const R *aligned_like)
Chris@82 59 {
Chris@82 60 (void)aligned_like; /* UNUSED */
Chris@82 61 (void)ivs; /* UNUSED */
Chris@82 62 return *(const V *)x;
Chris@82 63 }
Chris@82 64
Chris@82 65 static inline void STA(R *x, V v, INT ovs, const R *aligned_like)
Chris@82 66 {
Chris@82 67 (void)aligned_like; /* UNUSED */
Chris@82 68 (void)ovs; /* UNUSED */
Chris@82 69 *(V *)x = v;
Chris@82 70 }
Chris@82 71
Chris@82 72 static inline V LD(const R *x, INT ivs, const R *aligned_like)
Chris@82 73 {
Chris@82 74 (void)aligned_like; /* UNUSED */
Chris@82 75 V res;
Chris@82 76 res[0] = x[0];
Chris@82 77 res[1] = x[1];
Chris@82 78 #ifdef FFTW_SINGLE
Chris@82 79 res[2] = x[ivs];
Chris@82 80 res[3] = x[ivs+1];
Chris@82 81 #endif
Chris@82 82 return res;
Chris@82 83 }
Chris@82 84
Chris@82 85 #ifdef FFTW_SINGLE
Chris@82 86 /* ST has to be separate due to the storage hack requiring reverse order */
Chris@82 87 static inline void ST(R *x, V v, INT ovs, const R *aligned_like)
Chris@82 88 {
Chris@82 89 (void)aligned_like; /* UNUSED */
Chris@82 90 (void)ovs; /* UNUSED */
Chris@82 91 *(x + ovs ) = v[2];
Chris@82 92 *(x + ovs + 1) = v[3];
Chris@82 93 *(x ) = v[0];
Chris@82 94 *(x + 1) = v[1];
Chris@82 95 }
Chris@82 96 #else
Chris@82 97 /* FFTW_DOUBLE */
Chris@82 98 # define ST STA
Chris@82 99 #endif
Chris@82 100
Chris@82 101 #ifdef FFTW_SINGLE
Chris@82 102 #define STM2 ST
Chris@82 103 #define STN2(x, v0, v1, ovs) /* nop */
Chris@82 104
Chris@82 105 static inline void STN4(R *x, V v0, V v1, V v2, V v3, INT ovs)
Chris@82 106 {
Chris@82 107 *(x ) = v0[0];
Chris@82 108 *(x + 1) = v1[0];
Chris@82 109 *(x + 2) = v2[0];
Chris@82 110 *(x + 3) = v3[0];
Chris@82 111 *(x + ovs ) = v0[1];
Chris@82 112 *(x + ovs + 1) = v1[1];
Chris@82 113 *(x + ovs + 2) = v2[1];
Chris@82 114 *(x + ovs + 3) = v3[1];
Chris@82 115 *(x + 2 * ovs ) = v0[2];
Chris@82 116 *(x + 2 * ovs + 1) = v1[2];
Chris@82 117 *(x + 2 * ovs + 2) = v2[2];
Chris@82 118 *(x + 2 * ovs + 3) = v3[2];
Chris@82 119 *(x + 3 * ovs ) = v0[3];
Chris@82 120 *(x + 3 * ovs + 1) = v1[3];
Chris@82 121 *(x + 3 * ovs + 2) = v2[3];
Chris@82 122 *(x + 3 * ovs + 3) = v3[3];
Chris@82 123 }
Chris@82 124 #define STM4(x, v, ovs, aligned_like) /* no-op */
Chris@82 125
Chris@82 126
Chris@82 127 #else
Chris@82 128 /* FFTW_DOUBLE */
Chris@82 129
Chris@82 130 #define STM2 STA
Chris@82 131 #define STN2(x, v0, v1, ovs) /* nop */
Chris@82 132
Chris@82 133 static inline void STM4(R *x, V v, INT ovs, const R *aligned_like)
Chris@82 134 {
Chris@82 135 (void)aligned_like; /* UNUSED */
Chris@82 136 *(x) = v[0];
Chris@82 137 *(x+ovs) = v[1];
Chris@82 138 }
Chris@82 139 # define STN4(x, v0, v1, v2, v3, ovs) /* nothing */
Chris@82 140 #endif
Chris@82 141
Chris@82 142
Chris@82 143 static inline V FLIP_RI(V x)
Chris@82 144 {
Chris@82 145 #ifdef FFTW_SINGLE
Chris@82 146 return (V){x[1],x[0],x[3],x[2]};
Chris@82 147 #else
Chris@82 148 return (V){x[1],x[0]};
Chris@82 149 #endif
Chris@82 150 }
Chris@82 151
Chris@82 152 static inline V VCONJ(V x)
Chris@82 153 {
Chris@82 154 #ifdef FFTW_SINGLE
Chris@82 155 return (V){x[0],-x[1],x[2],-x[3]};
Chris@82 156 #else
Chris@82 157 return (V){x[0],-x[1]};
Chris@82 158 #endif
Chris@82 159 }
Chris@82 160
Chris@82 161 static inline V VBYI(V x)
Chris@82 162 {
Chris@82 163 x = VCONJ(x);
Chris@82 164 x = FLIP_RI(x);
Chris@82 165 return x;
Chris@82 166 }
Chris@82 167
Chris@82 168 /* FMA support */
Chris@82 169 #define VFMA(a, b, c) VADD(c, VMUL(a, b))
Chris@82 170 #define VFNMS(a, b, c) VSUB(c, VMUL(a, b))
Chris@82 171 #define VFMS(a, b, c) VSUB(VMUL(a, b), c)
Chris@82 172 #define VFMAI(b, c) VADD(c, VBYI(b))
Chris@82 173 #define VFNMSI(b, c) VSUB(c, VBYI(b))
Chris@82 174 #define VFMACONJ(b,c) VADD(VCONJ(b),c)
Chris@82 175 #define VFMSCONJ(b,c) VSUB(VCONJ(b),c)
Chris@82 176 #define VFNMSCONJ(b,c) VSUB(c, VCONJ(b))
Chris@82 177
Chris@82 178 static inline V VZMUL(V tx, V sr)
Chris@82 179 {
Chris@82 180 V tr = VDUPL(tx);
Chris@82 181 V ti = VDUPH(tx);
Chris@82 182 tr = VMUL(sr, tr);
Chris@82 183 sr = VBYI(sr);
Chris@82 184 return VFMA(ti, sr, tr);
Chris@82 185 }
Chris@82 186
Chris@82 187 static inline V VZMULJ(V tx, V sr)
Chris@82 188 {
Chris@82 189 V tr = VDUPL(tx);
Chris@82 190 V ti = VDUPH(tx);
Chris@82 191 tr = VMUL(sr, tr);
Chris@82 192 sr = VBYI(sr);
Chris@82 193 return VFNMS(ti, sr, tr);
Chris@82 194 }
Chris@82 195
Chris@82 196 static inline V VZMULI(V tx, V sr)
Chris@82 197 {
Chris@82 198 V tr = VDUPL(tx);
Chris@82 199 V ti = VDUPH(tx);
Chris@82 200 ti = VMUL(ti, sr);
Chris@82 201 sr = VBYI(sr);
Chris@82 202 return VFMS(tr, sr, ti);
Chris@82 203 }
Chris@82 204
Chris@82 205 static inline V VZMULIJ(V tx, V sr)
Chris@82 206 {
Chris@82 207 V tr = VDUPL(tx);
Chris@82 208 V ti = VDUPH(tx);
Chris@82 209 ti = VMUL(ti, sr);
Chris@82 210 sr = VBYI(sr);
Chris@82 211 return VFMA(tr, sr, ti);
Chris@82 212 }
Chris@82 213
Chris@82 214 /* twiddle storage #1: compact, slower */
Chris@82 215 #ifdef FFTW_SINGLE
Chris@82 216 # define VTW1(v,x) \
Chris@82 217 {TW_COS, v, x}, {TW_COS, v+1, x}, {TW_SIN, v, x}, {TW_SIN, v+1, x}
Chris@82 218 static inline V BYTW1(const R *t, V sr)
Chris@82 219 {
Chris@82 220 return VZMUL(LDA(t, 2, t), sr);
Chris@82 221 }
Chris@82 222 static inline V BYTWJ1(const R *t, V sr)
Chris@82 223 {
Chris@82 224 return VZMULJ(LDA(t, 2, t), sr);
Chris@82 225 }
Chris@82 226 #else /* !FFTW_SINGLE */
Chris@82 227 # define VTW1(v,x) {TW_CEXP, v, x}
Chris@82 228 static inline V BYTW1(const R *t, V sr)
Chris@82 229 {
Chris@82 230 V tx = LD(t, 1, t);
Chris@82 231 return VZMUL(tx, sr);
Chris@82 232 }
Chris@82 233 static inline V BYTWJ1(const R *t, V sr)
Chris@82 234 {
Chris@82 235 V tx = LD(t, 1, t);
Chris@82 236 return VZMULJ(tx, sr);
Chris@82 237 }
Chris@82 238 #endif
Chris@82 239 #define TWVL1 (VL)
Chris@82 240
Chris@82 241 /* twiddle storage #2: twice the space, faster (when in cache) */
Chris@82 242 #ifdef FFTW_SINGLE
Chris@82 243 # define VTW2(v,x) \
Chris@82 244 {TW_COS, v, x}, {TW_COS, v, x}, {TW_COS, v+1, x}, {TW_COS, v+1, x}, \
Chris@82 245 {TW_SIN, v, -x}, {TW_SIN, v, x}, {TW_SIN, v+1, -x}, {TW_SIN, v+1, x}
Chris@82 246 #else /* !FFTW_SINGLE */
Chris@82 247 # define VTW2(v,x) \
Chris@82 248 {TW_COS, v, x}, {TW_COS, v, x}, {TW_SIN, v, -x}, {TW_SIN, v, x}
Chris@82 249 #endif
Chris@82 250 #define TWVL2 (2 * VL)
Chris@82 251 static inline V BYTW2(const R *t, V sr)
Chris@82 252 {
Chris@82 253 const V *twp = (const V *)t;
Chris@82 254 V si = FLIP_RI(sr);
Chris@82 255 V tr = twp[0], ti = twp[1];
Chris@82 256 return VFMA(tr, sr, VMUL(ti, si));
Chris@82 257 }
Chris@82 258 static inline V BYTWJ2(const R *t, V sr)
Chris@82 259 {
Chris@82 260 const V *twp = (const V *)t;
Chris@82 261 V si = FLIP_RI(sr);
Chris@82 262 V tr = twp[0], ti = twp[1];
Chris@82 263 return VFNMS(ti, si, VMUL(tr, sr));
Chris@82 264 }
Chris@82 265
Chris@82 266 /* twiddle storage #3 */
Chris@82 267 #ifdef FFTW_SINGLE
Chris@82 268 # define VTW3(v,x) {TW_CEXP, v, x}, {TW_CEXP, v+1, x}
Chris@82 269 # define TWVL3 (VL)
Chris@82 270 #else
Chris@82 271 # define VTW3(v,x) VTW1(v,x)
Chris@82 272 # define TWVL3 TWVL1
Chris@82 273 #endif
Chris@82 274
Chris@82 275 /* twiddle storage for split arrays */
Chris@82 276 #ifdef FFTW_SINGLE
Chris@82 277 # define VTWS(v,x) \
Chris@82 278 {TW_COS, v, x}, {TW_COS, v+1, x}, {TW_COS, v+2, x}, {TW_COS, v+3, x}, \
Chris@82 279 {TW_SIN, v, x}, {TW_SIN, v+1, x}, {TW_SIN, v+2, x}, {TW_SIN, v+3, x}
Chris@82 280 #else
Chris@82 281 # define VTWS(v,x) \
Chris@82 282 {TW_COS, v, x}, {TW_COS, v+1, x}, {TW_SIN, v, x}, {TW_SIN, v+1, x}
Chris@82 283 #endif
Chris@82 284 #define TWVLS (2 * VL)
Chris@82 285
Chris@82 286 #define VLEAVE() /* nothing */
Chris@82 287
Chris@82 288 #include "simd-common.h"