diff options
| author | Chunlin <834352945@qq.com> | 2021-01-06 03:20:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-05 21:20:10 +0200 |
| commit | da887a666ad975ece7fb7465005aa99c0ddef8d2 (patch) | |
| tree | 554700ec26e710fae3a0275cce8179e3bea592ec /numpy/core/include | |
| parent | 444f696f69c98208aab00ecbcec7dfd1689da9fb (diff) | |
| download | numpy-da887a666ad975ece7fb7465005aa99c0ddef8d2.tar.gz | |
MAINT: CPUs that support unaligned access. (#18065)
* add CPUs that support unaligned access.
* add comments demonstrate the common scenoirs of unaligned access.
Diffstat (limited to 'numpy/core/include')
| -rw-r--r-- | numpy/core/include/numpy/npy_common.h | 8 | ||||
| -rw-r--r-- | numpy/core/include/numpy/npy_cpu.h | 14 |
2 files changed, 10 insertions, 12 deletions
diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h index d5a586c56..c8495db8e 100644 --- a/numpy/core/include/numpy/npy_common.h +++ b/numpy/core/include/numpy/npy_common.h @@ -10,14 +10,6 @@ #include <npy_config.h> #endif -// int*, int64* should be propertly aligned on ARMv7 to avoid bus error -#if !defined(NPY_STRONG_ALIGNMENT) && defined(__arm__) && !(defined(__aarch64__) || defined(_M_ARM64)) -#define NPY_STRONG_ALIGNMENT 1 -#endif -#if !defined(NPY_STRONG_ALIGNMENT) -#define NPY_STRONG_ALIGNMENT 0 -#endif - // compile time environment variables #ifndef NPY_RELAXED_STRIDES_CHECKING #define NPY_RELAXED_STRIDES_CHECKING 0 diff --git a/numpy/core/include/numpy/npy_cpu.h b/numpy/core/include/numpy/npy_cpu.h index 4dbf9d84e..065176ac5 100644 --- a/numpy/core/include/numpy/npy_cpu.h +++ b/numpy/core/include/numpy/npy_cpu.h @@ -110,10 +110,16 @@ information about your platform (OS, CPU and compiler) #endif -#if (defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64)) -#define NPY_CPU_HAVE_UNALIGNED_ACCESS 1 -#else -#define NPY_CPU_HAVE_UNALIGNED_ACCESS 0 +/* + * Except for the following architectures, memory access is limited to the natural + * alignment of data types otherwise it may lead to bus error or performance regression. + * For more details about unaligned access, see https://www.kernel.org/doc/Documentation/unaligned-memory-access.txt. +*/ +#if defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64) || defined(__aarch64__) || defined(__powerpc64__) + #define NPY_ALIGNMENT_REQUIRED 0 +#endif +#ifndef NPY_ALIGNMENT_REQUIRED + #define NPY_ALIGNMENT_REQUIRED 1 #endif #endif |
