GeezerVison is showing github.com — MAINT: Fix for segfaults with GCC 15 · charris/numpy@75a2e27
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: numpy/_core/include/numpy/npy_cpu.h +1-11Lines changed: 1 addition & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 119 | 119 | information about your platform (OS, CPU and compiler) | 120 | 120 | #endif | 121 | 121 |
| 122 | | -/* | 123 | | - * Except for the following architectures, memory access is limited to the natural | 124 | | - * alignment of data types otherwise it may lead to bus error or performance regression. | 125 | | - * For more details about unaligned access, see https://www.kernel.org/doc/Documentation/unaligned-memory-access.txt. | 126 | | -*/ | 127 | | -#if defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64) || defined(__aarch64__) || defined(__powerpc64__) | 128 | | - #define NPY_ALIGNMENT_REQUIRED 0 | 129 | | -#endif | 130 | | -#ifndef NPY_ALIGNMENT_REQUIRED | 131 | | - #define NPY_ALIGNMENT_REQUIRED 1 | 132 | | -#endif | | 122 | +#define NPY_ALIGNMENT_REQUIRED 1 | 133 | 123 |
| 134 | 124 | #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_CPU_H_ */ |
Collapse file Copy file name to clipboardExpand all lines: numpy/_core/src/multiarray/common.h -23Lines changed: 0 additions & 23 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -230,15 +230,6 @@ npy_uint_alignment(int itemsize) | 230 | 230 | * compared to memchr it returns one stride past end instead of NULL if needle | 231 | 231 | * is not found. | 232 | 232 | */ | 233 | | -#ifdef __clang__ | 234 | | - /* | 235 | | - * The code below currently makes use of !NPY_ALIGNMENT_REQUIRED, which | 236 | | - * should be OK but causes the clang sanitizer to warn. It may make | 237 | | - * sense to modify the code to avoid this "unaligned" access but | 238 | | - * it would be good to carefully check the performance changes. | 239 | | - */ | 240 | | - __attribute__((no_sanitize("alignment"))) | 241 | | -#endif | 242 | 233 | static inline char * | 243 | 234 | npy_memchr(char * haystack, char needle, | 244 | 235 | npy_intp stride, npy_intp size, npy_intp * psubloopsize, int invert) | @@ -258,20 +249,6 @@ npy_memchr(char * haystack, char needle, | 258 | 249 | } | 259 | 250 | } | 260 | 251 | else { | 261 | | - /* usually find elements to skip path */ | 262 | | - if (!NPY_ALIGNMENT_REQUIRED && needle == 0 && stride == 1) { | 263 | | - /* iterate until last multiple of 4 */ | 264 | | - char * block_end = haystack + size - (size % sizeof(unsigned int)); | 265 | | - while (p < block_end) { | 266 | | - unsigned int v = *(unsigned int*)p; | 267 | | - if (v != 0) { | 268 | | - break; | 269 | | - } | 270 | | - p += sizeof(unsigned int); | 271 | | - } | 272 | | - /* handle rest */ | 273 | | - subloopsize = (p - haystack); | 274 | | - } | 275 | 252 | while (subloopsize < size && *p == needle) { | 276 | 253 | subloopsize++; | 277 | 254 | p += stride; | |
Collapse file Copy file name to clipboardExpand all lines: numpy/_core/src/multiarray/compiled_base.c +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1620,8 +1620,7 @@ pack_inner(const char *inptr, | 1620 | 1620 | bb[1] = npyv_tobits_b8(npyv_cmpneq_u8(v1, v_zero)); | 1621 | 1621 | bb[2] = npyv_tobits_b8(npyv_cmpneq_u8(v2, v_zero)); | 1622 | 1622 | bb[3] = npyv_tobits_b8(npyv_cmpneq_u8(v3, v_zero)); | 1623 | | - if(out_stride == 1 && | 1624 | | - (!NPY_ALIGNMENT_REQUIRED || isAligned)) { | | 1623 | + if(out_stride == 1 && isAligned) { | 1625 | 1624 | npy_uint64 *ptr64 = (npy_uint64*)outptr; | 1626 | 1625 | #if NPY_SIMD_WIDTH == 16 | 1627 | 1626 | npy_uint64 bcomp = bb[0] | (bb[1] << 16) | (bb[2] << 32) | (bb[3] << 48); | |
Collapse file Copy file name to clipboardExpand all lines: numpy/_core/src/multiarray/item_selection.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2525,7 +2525,7 @@ count_nonzero_u8(const char *data, npy_intp bstride, npy_uintp len) | 2525 | 2525 | len -= len_m; | 2526 | 2526 | count = len_m - zcount; | 2527 | 2527 | #else | 2528 | | - if (!NPY_ALIGNMENT_REQUIRED || npy_is_aligned(data, sizeof(npy_uint64))) { | | 2528 | + if (npy_is_aligned(data, sizeof(npy_uint64))) { | 2529 | 2529 | int step = 6 * sizeof(npy_uint64); | 2530 | 2530 | int left_bytes = len % step; | 2531 | 2531 | for (const char *end = data + len; data < end - left_bytes; data += step) { | |
Collapse file Copy file name to clipboardExpand all lines: numpy/_core/src/multiarray/lowlevel_strided_loops.c.src +1-5Lines changed: 1 addition & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 33 | 33 | * instructions (16 byte). | 34 | 34 | * So this flag can only be enabled if autovectorization is disabled. | 35 | 35 | */ | 36 | | -#if NPY_ALIGNMENT_REQUIRED | 37 | | -# define NPY_USE_UNALIGNED_ACCESS 0 | 38 | | -#else | 39 | | -# define NPY_USE_UNALIGNED_ACCESS 0 | 40 | | -#endif | | 36 | +#define NPY_USE_UNALIGNED_ACCESS 0 | 41 | 37 |
| 42 | 38 | #define _NPY_NOP1(x) (x) | 43 | 39 | #define _NPY_NOP2(x) (x) | |
|