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