summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Bourque <jay.bourque@continuum.io>2013-07-16 13:28:40 -0500
committerJay Bourque <jay.bourque@continuum.io>2013-08-16 16:39:32 -0500
commit5729685578d52b13096803ce813fcb8990f84561 (patch)
tree7d97c7a011e6d1c6c3a90a7ea5a66a99c3b66779
parent6c249cd038d15a6be00f3d611bccdbcc0fa0ff5e (diff)
downloadnumpy-5729685578d52b13096803ce813fcb8990f84561.tar.gz
Move gil release/aquire outside of loop
-rw-r--r--numpy/core/src/umath/ufunc_object.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c
index 4f7fdd381..bef29f57c 100644
--- a/numpy/core/src/umath/ufunc_object.c
+++ b/numpy/core/src/umath/ufunc_object.c
@@ -5058,7 +5058,7 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
goto fail;
}
- needs_api = NpyIter_IterationNeedsAPI(iter_buffer);
+ needs_api = needs_api | NpyIter_IterationNeedsAPI(iter_buffer);
iternext = NpyIter_GetIterNext(iter_buffer, NULL);
if (iternext == NULL) {
@@ -5066,6 +5066,10 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
goto fail;
}
+ if (!needs_api) {
+ NPY_BEGIN_THREADS;
+ }
+
/*
* Iterate over first and second operands and call ufunc
* for each pair of inputs
@@ -5094,10 +5098,6 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
NpyIter_ResetBasePointers(iter_buffer, dataptr, NULL);
buffer_dataptr = NpyIter_GetDataPtrArray(iter_buffer);
- if (!needs_api) {
- NPY_BEGIN_THREADS;
- }
-
/*
* Even though we'll never loop more than once, call to iternext
* triggers copy from buffer back to output array after innerloop
@@ -5107,10 +5107,6 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
innerloop(buffer_dataptr, count, stride, innerloopdata);
} while (iternext(iter_buffer));
- if (!needs_api) {
- NPY_END_THREADS;
- }
-
PyArray_MapIterNext(iter);
if (iter2 != NULL) {
PyArray_ITER_NEXT(iter2);
@@ -5118,7 +5114,11 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
i--;
}
-
+
+ if (!needs_api) {
+ NPY_END_THREADS;
+ }
+
NpyIter_Deallocate(iter_buffer);
return op1;