annotate src/fftw-3.3.5/simd-support/simd-common.h @ 168:ceec0dd9ec9c

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