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