Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 527a2f1

Browse files
Convert arithmetic from C universal intrinsics to C++ using Highway
1 parent 4206d09 commit 527a2f1

File tree

4 files changed

+290
-537
lines changed

4 files changed

+290
-537
lines changed

numpy/_core/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ foreach gen_mtargets : [
885885
],
886886
[
887887
'loops_arithmetic.dispatch.h',
888-
src_file.process('src/umath/loops_arithmetic.dispatch.c.src'),
888+
'src/umath/loops_arithmetic.dispatch.cpp',
889889
[
890890
AVX512_SKX, AVX512F, AVX2, SSE41, SSE2,
891891
NEON,

numpy/_core/src/multiarray/common.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ check_and_adjust_index(npy_intp *index, npy_intp max_item, int axis,
111111
/* Try to be as clear as possible about what went wrong. */
112112
if (axis >= 0) {
113113
PyErr_Format(PyExc_IndexError,
114-
"index %"NPY_INTP_FMT" is out of bounds "
115-
"for axis %d with size %"NPY_INTP_FMT,
114+
"index %" NPY_INTP_FMT " is out of bounds "
115+
"for axis %d with size %" NPY_INTP_FMT,
116116
*index, axis, max_item);
117117
} else {
118118
PyErr_Format(PyExc_IndexError,
119-
"index %"NPY_INTP_FMT" is out of bounds "
120-
"for size %"NPY_INTP_FMT, *index, max_item);
119+
"index %" NPY_INTP_FMT " is out of bounds "
120+
"for size %" NPY_INTP_FMT, *index, max_item);
121121
}
122122
return -1;
123123
}
@@ -172,13 +172,13 @@ check_and_adjust_axis(int *axis, int ndim)
172172
*/
173173
#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
174174
|| (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
175-
&& !defined __clang__) \
175+
&& !defined __clang__) \
176176
|| (defined __clang__ && __clang_major__ < 8))
177-
# define NPY_ALIGNOF(type) offsetof(struct {char c; type v;}, v)
177+
#define NPY_ALIGNOF(type) __alignof__(type)
178178
#else
179-
# define NPY_ALIGNOF(type) _Alignof(type)
179+
#define NPY_ALIGNOF(type) _Alignof(type)
180180
#endif
181-
#define NPY_ALIGNOF_UINT(type) npy_uint_alignment(sizeof(type))
181+
#define NPY_ALIGNOF_UINT(type) NPY_ALIGNOF(type)
182182
/*
183183
* Disable harmless compiler warning "4116: unnamed type definition in
184184
* parentheses" which is caused by the _ALIGN macro.

0 commit comments

Comments
 (0)