comparison src/fftw-3.3.5/simd-support/simd-common.h @ 42:2cd0e3b3e1fd

Current fftw source
author Chris Cannam
date Tue, 18 Oct 2016 13:40:26 +0100
parents
children
comparison
equal deleted inserted replaced
41:481f5f8c5634 42:2cd0e3b3e1fd
1 /*
2 * Copyright (c) 2003, 2007-14 Matteo Frigo
3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21 /* detection of alignment. This is complicated because a machine may
22 support multiple SIMD extensions (e.g. SSE2 and AVX) but only one
23 set of alignment contraints. So this alignment stuff cannot be
24 defined in the SIMD header files. Rather than defining a separate
25 set of "machine" header files, we just do this ugly ifdef here. */
26 #if defined(HAVE_AVX512)
27 # if defined(FFTW_SINGLE)
28 # define ALIGNMENT 8 /* Alignment for the LD/ST macros */
29 # define ALIGNMENTA 64 /* Alignment for the LDA/STA macros */
30 # else
31 # define ALIGNMENT 16 /* Alignment for the LD/ST macros */
32 # define ALIGNMENTA 64 /* Alignment for the LDA/STA macros */
33 # endif
34 #elif defined(HAVE_SSE2) || defined(HAVE_AVX) || defined(HAVE_AVX2) || (HAVE_AVX_128_FMA)
35 # if defined(FFTW_SINGLE)
36 # define ALIGNMENT 8 /* Alignment for the LD/ST macros */
37 # define ALIGNMENTA 16 /* Alignment for the LDA/STA macros */
38 # else
39 # define ALIGNMENT 16 /* Alignment for the LD/ST macros */
40 # define ALIGNMENTA 16 /* Alignment for the LDA/STA macros */
41 # endif
42 #elif defined(HAVE_ALTIVEC)
43 # define ALIGNMENT 8 /* Alignment for the LD/ST macros */
44 # define ALIGNMENTA 16 /* Alignment for the LDA/STA macros */
45 #elif defined(HAVE_NEON) || defined(HAVE_VSX)
46 # define ALIGNMENT 8 /* Alignment for the LD/ST macros */
47 # define ALIGNMENTA 8 /* Alignment for the LDA/STA macros */
48 #elif defined(HAVE_KCVI)
49 # if defined(FFTW_SINGLE)
50 # define ALIGNMENT 8 /* Alignment for the LD/ST macros */
51 # else
52 # define ALIGNMENT 16 /* Alignment for the LD/ST macros */
53 # endif
54 # define ALIGNMENTA 64 /* Alignment for the LDA/STA macros */
55 #elif defined(HAVE_GENERIC_SIMD256)
56 # if defined(FFTW_SINGLE)
57 # define ALIGNMENT 8
58 # define ALIGNMENTA 32
59 # else
60 # define ALIGNMENT 16
61 # define ALIGNMENTA 32
62 # endif
63 #elif defined(HAVE_GENERIC_SIMD128)
64 # if defined(FFTW_SINGLE)
65 # define ALIGNMENT 8
66 # define ALIGNMENTA 16
67 # else
68 # define ALIGNMENT 16
69 # define ALIGNMENTA 16
70 # endif
71 #endif
72
73 #if HAVE_SIMD
74 # ifndef ALIGNMENT
75 # error "ALIGNMENT not defined"
76 # endif
77 # ifndef ALIGNMENTA
78 # error "ALIGNMENTA not defined"
79 # endif
80 #endif
81
82 /* rename for precision and for SIMD extensions */
83 #define XSIMD0(name, suffix) CONCAT(name, suffix)
84 #define XSIMD(name) XSIMD0(X(name), SIMD_SUFFIX)
85 #define XSIMD_STRING(x) x STRINGIZE(SIMD_SUFFIX)
86
87 /* TAINT_BIT is set if pointers are not guaranteed to be multiples of
88 ALIGNMENT */
89 #define TAINT_BIT 1
90
91 /* TAINT_BITA is set if pointers are not guaranteed to be multiples of
92 ALIGNMENTA */
93 #define TAINT_BITA 2
94
95 #define PTRINT(p) ((uintptr_t)(p))
96
97 #define ALIGNED(p) \
98 (((PTRINT(UNTAINT(p)) % ALIGNMENT) == 0) && !(PTRINT(p) & TAINT_BIT))
99
100 #define ALIGNEDA(p) \
101 (((PTRINT(UNTAINT(p)) % ALIGNMENTA) == 0) && !(PTRINT(p) & TAINT_BITA))
102
103 #define SIMD_STRIDE_OK(x) (!(((x) * sizeof(R)) % ALIGNMENT))
104 #define SIMD_STRIDE_OKA(x) (!(((x) * sizeof(R)) % ALIGNMENTA))
105 #define SIMD_VSTRIDE_OK SIMD_STRIDE_OK
106