cannam@167: /* cannam@167: * Copyright (c) 2003, 2007-14 Matteo Frigo cannam@167: * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology cannam@167: * cannam@167: * This program is free software; you can redistribute it and/or modify cannam@167: * it under the terms of the GNU General Public License as published by cannam@167: * the Free Software Foundation; either version 2 of the License, or cannam@167: * (at your option) any later version. cannam@167: * cannam@167: * This program is distributed in the hope that it will be useful, cannam@167: * but WITHOUT ANY WARRANTY; without even the implied warranty of cannam@167: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the cannam@167: * GNU General Public License for more details. cannam@167: * cannam@167: * You should have received a copy of the GNU General Public License cannam@167: * along with this program; if not, write to the Free Software cannam@167: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA cannam@167: * cannam@167: */ cannam@167: cannam@167: /* detection of alignment. This is complicated because a machine may cannam@167: support multiple SIMD extensions (e.g. SSE2 and AVX) but only one cannam@167: set of alignment contraints. So this alignment stuff cannot be cannam@167: defined in the SIMD header files. Rather than defining a separate cannam@167: set of "machine" header files, we just do this ugly ifdef here. */ cannam@167: #if defined(HAVE_AVX512) cannam@167: # if defined(FFTW_SINGLE) cannam@167: # define ALIGNMENT 8 /* Alignment for the LD/ST macros */ cannam@167: # define ALIGNMENTA 64 /* Alignment for the LDA/STA macros */ cannam@167: # else cannam@167: # define ALIGNMENT 16 /* Alignment for the LD/ST macros */ cannam@167: # define ALIGNMENTA 64 /* Alignment for the LDA/STA macros */ cannam@167: # endif cannam@167: #elif defined(HAVE_SSE2) || defined(HAVE_AVX) || defined(HAVE_AVX2) || (HAVE_AVX_128_FMA) cannam@167: # if defined(FFTW_SINGLE) cannam@167: # define ALIGNMENT 8 /* Alignment for the LD/ST macros */ cannam@167: # define ALIGNMENTA 16 /* Alignment for the LDA/STA macros */ cannam@167: # else cannam@167: # define ALIGNMENT 16 /* Alignment for the LD/ST macros */ cannam@167: # define ALIGNMENTA 16 /* Alignment for the LDA/STA macros */ cannam@167: # endif cannam@167: #elif defined(HAVE_ALTIVEC) cannam@167: # define ALIGNMENT 8 /* Alignment for the LD/ST macros */ cannam@167: # define ALIGNMENTA 16 /* Alignment for the LDA/STA macros */ cannam@167: #elif defined(HAVE_NEON) || defined(HAVE_VSX) cannam@167: # define ALIGNMENT 8 /* Alignment for the LD/ST macros */ cannam@167: # define ALIGNMENTA 8 /* Alignment for the LDA/STA macros */ cannam@167: #elif defined(HAVE_KCVI) cannam@167: # if defined(FFTW_SINGLE) cannam@167: # define ALIGNMENT 8 /* Alignment for the LD/ST macros */ cannam@167: # else cannam@167: # define ALIGNMENT 16 /* Alignment for the LD/ST macros */ cannam@167: # endif cannam@167: # define ALIGNMENTA 64 /* Alignment for the LDA/STA macros */ cannam@167: #elif defined(HAVE_GENERIC_SIMD256) cannam@167: # if defined(FFTW_SINGLE) cannam@167: # define ALIGNMENT 8 cannam@167: # define ALIGNMENTA 32 cannam@167: # else cannam@167: # define ALIGNMENT 16 cannam@167: # define ALIGNMENTA 32 cannam@167: # endif cannam@167: #elif defined(HAVE_GENERIC_SIMD128) cannam@167: # if defined(FFTW_SINGLE) cannam@167: # define ALIGNMENT 8 cannam@167: # define ALIGNMENTA 16 cannam@167: # else cannam@167: # define ALIGNMENT 16 cannam@167: # define ALIGNMENTA 16 cannam@167: # endif cannam@167: #endif cannam@167: cannam@167: #if HAVE_SIMD cannam@167: # ifndef ALIGNMENT cannam@167: # error "ALIGNMENT not defined" cannam@167: # endif cannam@167: # ifndef ALIGNMENTA cannam@167: # error "ALIGNMENTA not defined" cannam@167: # endif cannam@167: #endif cannam@167: cannam@167: /* rename for precision and for SIMD extensions */ cannam@167: #define XSIMD0(name, suffix) CONCAT(name, suffix) cannam@167: #define XSIMD(name) XSIMD0(X(name), SIMD_SUFFIX) cannam@167: #define XSIMD_STRING(x) x STRINGIZE(SIMD_SUFFIX) cannam@167: cannam@167: /* TAINT_BIT is set if pointers are not guaranteed to be multiples of cannam@167: ALIGNMENT */ cannam@167: #define TAINT_BIT 1 cannam@167: cannam@167: /* TAINT_BITA is set if pointers are not guaranteed to be multiples of cannam@167: ALIGNMENTA */ cannam@167: #define TAINT_BITA 2 cannam@167: cannam@167: #define PTRINT(p) ((uintptr_t)(p)) cannam@167: cannam@167: #define ALIGNED(p) \ cannam@167: (((PTRINT(UNTAINT(p)) % ALIGNMENT) == 0) && !(PTRINT(p) & TAINT_BIT)) cannam@167: cannam@167: #define ALIGNEDA(p) \ cannam@167: (((PTRINT(UNTAINT(p)) % ALIGNMENTA) == 0) && !(PTRINT(p) & TAINT_BITA)) cannam@167: cannam@167: #define SIMD_STRIDE_OK(x) (!(((x) * sizeof(R)) % ALIGNMENT)) cannam@167: #define SIMD_STRIDE_OKA(x) (!(((x) * sizeof(R)) % ALIGNMENTA)) cannam@167: #define SIMD_VSTRIDE_OK SIMD_STRIDE_OK cannam@167: