diff options
author | Qiyu8 <fangchunlin@huawei.com> | 2020-12-15 09:49:19 +0800 |
---|---|---|
committer | Qiyu8 <fangchunlin@huawei.com> | 2020-12-15 09:49:19 +0800 |
commit | a08acd460fbe133b316b5e963a54dfa8208c036e (patch) | |
tree | 92988a0219fa0c341e6ec0c989b6c6ff4873b9f1 | |
parent | 797477d40cbea905a1a4b8bd6c99376f6dc1e1a7 (diff) | |
download | numpy-a08acd460fbe133b316b5e963a54dfa8208c036e.tar.gz |
add ARMV7 macro define header in order to prevent bus error.
-rw-r--r-- | numpy/core/include/numpy/npy_cpu.h | 3 | ||||
-rw-r--r-- | numpy/core/src/multiarray/compiled_base.c | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/numpy/core/include/numpy/npy_cpu.h b/numpy/core/include/numpy/npy_cpu.h index 4dbf9d84e..88f22a248 100644 --- a/numpy/core/include/numpy/npy_cpu.h +++ b/numpy/core/include/numpy/npy_cpu.h @@ -84,6 +84,9 @@ # error Unknown ARM CPU, please report this to numpy maintainers with \ information about your platform (OS, CPU and compiler) #endif + #if !(defined(__aarch64__) || defined(_M_ARM64)) + #define NPY_CPU_ARMV7 + #endif #elif defined(__sh__) && defined(__LITTLE_ENDIAN__) #define NPY_CPU_SH_LE #elif defined(__sh__) && defined(__BIG_ENDIAN__) diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c index 81eb6e623..3b5322c15 100644 --- a/numpy/core/src/multiarray/compiled_base.c +++ b/numpy/core/src/multiarray/compiled_base.c @@ -20,6 +20,11 @@ typedef enum { PACK_ORDER_BIG } PACK_ORDER; +#ifdef NPY_CPU_ARMV7 + #define ISARMV7 1 +#else + #define ISARMV7 0 +#endif /* * Returns -1 if the array is monotonic decreasing, * +1 if the array is monotonic increasing, @@ -1520,7 +1525,7 @@ pack_inner(const char *inptr, bb[2] = npyv_tobits_b8(npyv_cmpneq_u8(v2, v_zero)); bb[3] = npyv_tobits_b8(npyv_cmpneq_u8(v3, v_zero)); if(out_stride == 1 && - npy_is_aligned(outptr, sizeof(npy_uint64))) { + (!ISARMV7 || npy_is_aligned(outptr, sizeof(npy_uint64)))) { npy_uint64 *ptr64 = (npy_uint64*)outptr; #if NPY_SIMD_WIDTH == 16 npy_uint64 bcomp = bb[0] | (bb[1] << 16) | (bb[2] << 32) | (bb[3] << 48); |