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