summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/multiarray/multiarray_tests.c.src8
-rw-r--r--numpy/core/src/umath/simd.inc.src36
2 files changed, 32 insertions, 12 deletions
diff --git a/numpy/core/src/multiarray/multiarray_tests.c.src b/numpy/core/src/multiarray/multiarray_tests.c.src
index a80d3af19..9a2cd0c1b 100644
--- a/numpy/core/src/multiarray/multiarray_tests.c.src
+++ b/numpy/core/src/multiarray/multiarray_tests.c.src
@@ -155,7 +155,7 @@ test_neighborhood_iterator(PyObject* NPY_UNUSED(self), PyObject* args)
for (i = 0; i < 2 * PyArray_NDIM(ax); ++i) {
PyObject* bound;
bound = PySequence_GetItem(b, i);
- if (bounds == NULL) {
+ if (bound == NULL) {
goto clean_itx;
}
if (!PyInt_Check(bound)) {
@@ -314,7 +314,7 @@ test_neighborhood_iterator_oob(PyObject* NPY_UNUSED(self), PyObject* args)
for (i = 0; i < 2 * PyArray_NDIM(ax); ++i) {
PyObject* bound;
bound = PySequence_GetItem(b1, i);
- if (bounds == NULL) {
+ if (bound == NULL) {
goto clean_itx;
}
if (!PyInt_Check(bound)) {
@@ -338,7 +338,7 @@ test_neighborhood_iterator_oob(PyObject* NPY_UNUSED(self), PyObject* args)
for (i = 0; i < 2 * PyArray_NDIM(ax); ++i) {
PyObject* bound;
bound = PySequence_GetItem(b2, i);
- if (bounds == NULL) {
+ if (bound == NULL) {
goto clean_itx;
}
if (!PyInt_Check(bound)) {
@@ -762,7 +762,7 @@ array_indexing(PyObject *NPY_UNUSED(self), PyObject *args)
if (mode == 1) {
if (PySequence_SetItem(arr, i, op) < 0) {
return NULL;
- }
+ }
Py_RETURN_NONE;
}
diff --git a/numpy/core/src/umath/simd.inc.src b/numpy/core/src/umath/simd.inc.src
index 5b111eb0d..55a638d6c 100644
--- a/numpy/core/src/umath/simd.inc.src
+++ b/numpy/core/src/umath/simd.inc.src
@@ -27,6 +27,19 @@
#include <stdlib.h>
#include <string.h> /* for memcpy */
+/* Figure out the right abs function for pointer addresses */
+static NPY_INLINE npy_intp
+abs_intp(npy_intp x)
+{
+#if (NPY_SIZEOF_INTP <= NPY_SIZEOF_INT)
+ return abs(x);
+#elif (NPY_SIZEOF_INTP <= NPY_SIZEOF_LONG)
+ return labs(x);
+#else
+ return llabs(x);
+#endif
+}
+
/*
* stride is equal to element size and input and destination are equal or
* don't overlap within one register
@@ -34,10 +47,11 @@
#define IS_BLOCKABLE_UNARY(esize, vsize) \
(steps[0] == (esize) && steps[0] == steps[1] && \
(npy_is_aligned(args[0], esize) && npy_is_aligned(args[1], esize)) && \
- ((abs(args[1] - args[0]) >= (vsize)) || ((abs(args[1] - args[0]) == 0))))
+ ((abs_intp(args[1] - args[0]) >= (vsize)) || \
+ ((abs_intp(args[1] - args[0]) == 0))))
#define IS_BLOCKABLE_REDUCE(esize, vsize) \
- (steps[1] == (esize) && abs(args[1] - args[0]) >= (vsize) && \
+ (steps[1] == (esize) && abs_intp(args[1] - args[0]) >= (vsize) && \
npy_is_aligned(args[1], (esize)) && \
npy_is_aligned(args[0], (esize)))
@@ -45,20 +59,26 @@
(steps[0] == steps[1] && steps[1] == steps[2] && steps[2] == (esize) && \
npy_is_aligned(args[2], (esize)) && npy_is_aligned(args[1], (esize)) && \
npy_is_aligned(args[0], (esize)) && \
- (abs(args[2] - args[0]) >= (vsize) || abs(args[2] - args[0]) == 0) && \
- (abs(args[2] - args[1]) >= (vsize) || abs(args[2] - args[1]) >= 0))
+ (abs_intp(args[2] - args[0]) >= (vsize) || \
+ abs_intp(args[2] - args[0]) == 0) && \
+ (abs_intp(args[2] - args[1]) >= (vsize) || \
+ abs_intp(args[2] - args[1]) >= 0))
#define IS_BLOCKABLE_BINARY_SCALAR1(esize, vsize) \
(steps[0] == 0 && steps[1] == steps[2] && steps[2] == (esize) && \
npy_is_aligned(args[2], (esize)) && npy_is_aligned(args[1], (esize)) && \
- ((abs(args[2] - args[1]) >= (vsize)) || (abs(args[2] - args[1]) == 0)) && \
- abs(args[2] - args[0]) >= (esize))
+ ((abs_intp(args[2] - args[1]) >= (vsize)) || \
+ (abs_intp(args[2] - args[1]) == 0)) && \
+ abs_intp(args[2] - args[0]) >= (esize))
#define IS_BLOCKABLE_BINARY_SCALAR2(esize, vsize) \
(steps[1] == 0 && steps[0] == steps[2] && steps[2] == (esize) && \
npy_is_aligned(args[2], (esize)) && npy_is_aligned(args[0], (esize)) && \
- ((abs(args[2] - args[0]) >= (vsize)) || (abs(args[2] - args[0]) == 0)) && \
- abs(args[2] - args[1]) >= (esize))
+ ((abs_intp(args[2] - args[0]) >= (vsize)) || \
+ (abs_intp(args[2] - args[0]) == 0)) && \
+ abs_intp(args[2] - args[1]) >= (esize))
+
+#undef abs_intp
#define IS_BLOCKABLE_BINARY_BOOL(esize, vsize) \
(steps[0] == (esize) && steps[0] == steps[1] && steps[2] == (1) && \