diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-07-18 06:24:09 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-07-18 06:24:09 +0000 |
commit | b098d6252f944b814663d4dbf9ac4e08c4e15e38 (patch) | |
tree | d2028135b9c5b6d9c95fe9b3fe0b03597964a020 /numpy/core | |
parent | 6e3790036dab34159c6973c64d6e5626db64b829 (diff) | |
download | numpy-b098d6252f944b814663d4dbf9ac4e08c4e15e38.tar.gz |
Fix-up usage of NPY_ALLOW_THREADS. Default is now WITH_THREAD but an environment variable NUMPY_NOSMP can be set which will make the default 0
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/blasdot/_dotblas.c | 23 | ||||
-rw-r--r-- | numpy/core/include/numpy/arrayobject.h | 14 | ||||
-rw-r--r-- | numpy/core/include/numpy/old_defines.h | 2 | ||||
-rw-r--r-- | numpy/core/include/numpy/ufuncobject.h | 10 | ||||
-rw-r--r-- | numpy/core/setup.py | 12 | ||||
-rw-r--r-- | numpy/core/src/arrayobject.c | 28 | ||||
-rw-r--r-- | numpy/core/src/arraytypes.inc.src | 26 | ||||
-rw-r--r-- | numpy/core/src/multiarraymodule.c | 27 | ||||
-rw-r--r-- | numpy/core/src/ufuncobject.c | 30 |
9 files changed, 110 insertions, 62 deletions
diff --git a/numpy/core/blasdot/_dotblas.c b/numpy/core/blasdot/_dotblas.c index 532c9097b..91b50b43b 100644 --- a/numpy/core/blasdot/_dotblas.c +++ b/numpy/core/blasdot/_dotblas.c @@ -356,13 +356,14 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) return PyArray_Return(ret); } - Py_BEGIN_ALLOW_THREADS if (ap2shape == _scalar) { /* Multiplication by a scalar -- Level 1 BLAS */ /* if ap1shape is a matrix and we are not contiguous, then we can't just blast through the entire array using a single striding factor */ + NPY_BEGIN_ALLOW_THREADS + if (typenum == PyArray_DOUBLE) { if (l == 1) { *((double *)ret->data) = *((double *)ap2->data) * \ @@ -487,9 +488,12 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) } } } + NPY_END_ALLOW_THREADS } else if ((ap2shape == _column) && (ap1shape != _matrix)) { int ap1s, ap2s; + NPY_BEGIN_ALLOW_THREADS + ap2s = ap2->strides[0] / ap2->descr->elsize; if (ap1shape == _row) { ap1s = ap1->strides[1] / ap1->descr->elsize; @@ -517,6 +521,7 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) cblas_cdotu_sub(l, (float *)ap1->data, ap1s, (float *)ap2->data, ap2s, (float *)ret->data); } + NPY_END_ALLOW_THREADS } else if (ap1shape == _matrix && ap2shape != _matrix) { /* Matrix vector multiplication -- Level 2 BLAS */ @@ -531,6 +536,7 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) ap1 = (PyArrayObject *)new; if (new == NULL) goto fail; } + NPY_BEGIN_ALLOW_THREADS if (PyArray_ISCONTIGUOUS(ap1)) { Order = CblasRowMajor; lda = (ap1->dimensions[1] > 1 ? ap1->dimensions[1] : 1); @@ -566,6 +572,7 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) (float *)ap2->data, ap2s, zeroF, (float *)ret->data, 1); } + NPY_END_ALLOW_THREADS } else if (ap1shape != _matrix && ap2shape == _matrix) { /* Vector matrix multiplication -- Level 2 BLAS */ @@ -579,6 +586,7 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) ap2 = (PyArrayObject *)new; if (new == NULL) goto fail; } + NPY_BEGIN_ALLOW_THREADS if (PyArray_ISCONTIGUOUS(ap2)) { Order = CblasRowMajor; lda = (ap2->dimensions[1] > 1 ? ap2->dimensions[1] : 1); @@ -617,6 +625,7 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) oneF, (float *)ap2->data, lda, (float *)ap1->data, ap1s, zeroF, (float *)ret->data, 1); } + NPY_END_ALLOW_THREADS } else { /* (ap1->nd == 2 && ap2->nd == 2) */ /* Matrix matrix multiplication -- Level 3 BLAS */ @@ -644,6 +653,8 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) ap1 = (PyArrayObject *)new; if (new == NULL) goto fail; } + + NPY_BEGIN_ALLOW_THREADS Order = CblasRowMajor; Trans1 = CblasNoTrans; @@ -682,9 +693,9 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) (float *)ap2->data, ldb, zeroF, (float *)ret->data, ldc); } + NPY_END_ALLOW_THREADS } - Py_END_ALLOW_THREADS Py_DECREF(ap1); Py_DECREF(ap2); @@ -800,7 +811,7 @@ dotblas_innerproduct(PyObject *dummy, PyObject *args) (prior2 > prior1 ? ap2 : ap1)); if (ret == NULL) goto fail; - Py_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS memset(ret->data, 0, PyArray_NBYTES(ret)); if (ap2->nd == 0) { @@ -933,7 +944,7 @@ dotblas_innerproduct(PyObject *dummy, PyObject *args) zeroF, (float *)ret->data, ldc); } } - Py_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS Py_DECREF(ap1); Py_DECREF(ap2); return PyArray_Return(ret); @@ -1015,7 +1026,7 @@ static PyObject *dotblas_vdot(PyObject *dummy, PyObject *args) { ret = (PyArrayObject *)PyArray_SimpleNew(0, dimensions, typenum); if (ret == NULL) goto fail; - Py_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS /* Dot product between two vectors -- Level 1 BLAS */ if (typenum == PyArray_DOUBLE) { @@ -1035,7 +1046,7 @@ static PyObject *dotblas_vdot(PyObject *dummy, PyObject *args) { (float *)ap2->data, 1, (float *)ret->data); } - Py_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS Py_DECREF(ap1); Py_DECREF(ap2); diff --git a/numpy/core/include/numpy/arrayobject.h b/numpy/core/include/numpy/arrayobject.h index 67f0cb321..8f4f53bf9 100644 --- a/numpy/core/include/numpy/arrayobject.h +++ b/numpy/core/include/numpy/arrayobject.h @@ -982,16 +982,20 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *); #define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, NPY_ALIGNED) -#if defined(ALLOW_THREADS) -#define NPY_BEGIN_THREADS_DEF PyThreadState *_save; +#if NPY_ALLOW_THREADS +#define NPY_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS +#define NPY_END_ALLOW_THREADS Py_END_ALLOW_THREADS +#define NPY_BEGIN_THREADS_DEF PyThreadState *_save=NULL; #define NPY_BEGIN_THREADS _save = PyEval_SaveThread(); -#define NPY_END_THREADS PyEval_RestoreThread(_save); +#define NPY_END_THREADS if (_save) PyEval_RestoreThread(_save); #define NPY_BEGIN_THREADS_DESCR(dtype) if (!((dtype)->hasobject)) NPY_BEGIN_THREADS #define NPY_END_THREADS_DESCR(dtype) if (!((dtype)->hasobject)) NPY_END_THREADS #define NPY_ALLOW_C_API_DEF PyGILState_STATE __save__; #define NPY_ALLOW_C_API __save__ = PyGILState_Ensure(); #define NPY_DISABLE_C_API PyGILState_Release(__save__); #else +#define NPY_BEGIN_ALLOW_THREADS +#define NPY_END_ALLOW_THREADS #define NPY_BEGIN_THREADS_DEF #define NPY_BEGIN_THREADS #define NPY_END_THREADS @@ -1331,7 +1335,7 @@ typedef struct { #define NPY_OPPBYTE NPY_BIG #endif -#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE) +#define PyArray_ISNBO(arg) ((arg) != NPY_OPPBYTE) #define PyArray_IsNativeByteOrder PyArray_ISNBO #define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder) #define PyArray_ISBYTESWAPPED(m) (!PyArray_ISNOTSWAPPED(m)) @@ -1494,7 +1498,7 @@ typedef struct { } while(0) /* Copy should always return contiguous array */ -#define PyArray_Copy(obj) PyArray_NewCopy(obj, PyArray_CORDER) +#define PyArray_Copy(obj) PyArray_NewCopy(obj, NPY_CORDER) #define PyArray_FromObject(op, type, min_depth, max_depth) \ PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \ diff --git a/numpy/core/include/numpy/old_defines.h b/numpy/core/include/numpy/old_defines.h index adb6a008d..1c270e04b 100644 --- a/numpy/core/include/numpy/old_defines.h +++ b/numpy/core/include/numpy/old_defines.h @@ -134,7 +134,7 @@ #define PyArray_NSCALARKINDS NPY_NSCALARKINDS #define PyArray_ANYORDER NPY_ANYORDER -#define PyArray_CORDER NPY_CORDER +#define PyArray_CORDER NPY_CORDER #define PyArray_FORTRANORDER NPY_FORTRANORDER #define PyArray_ORDER NPY_ORDER diff --git a/numpy/core/include/numpy/ufuncobject.h b/numpy/core/include/numpy/ufuncobject.h index 0df3997e3..66162b904 100644 --- a/numpy/core/include/numpy/ufuncobject.h +++ b/numpy/core/include/numpy/ufuncobject.h @@ -164,12 +164,12 @@ typedef struct { } PyUFuncReduceObject; -#if defined(ALLOW_THREADS) -#define LOOP_BEGIN_THREADS if (!(loop->obj)) {_save = PyEval_SaveThread();} -#define LOOP_END_THREADS if (!(loop->obj)) {PyEval_RestoreThread(_save);} +#if NPY_ALLOW_THREADS +#define NPY_LOOP_BEGIN_THREADS if (!(loop->obj)) {_save = PyEval_SaveThread();} +#define NPY_LOOP_END_THREADS if (!(loop->obj)) {PyEval_RestoreThread(_save);} #else -#define LOOP_BEGIN_THREADS -#define LOOP_END_THREADS +#define NPY_LOOP_BEGIN_THREADS +#define NPY_LOOP_END_THREADS #endif #define PyUFunc_One 1 diff --git a/numpy/core/setup.py b/numpy/core/setup.py index fa42f2aaf..aa6450207 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -35,8 +35,16 @@ def configuration(parent_package='',top_path=None): library_dirs = default_lib_dirs) if not result: raise "ERROR: Failed to test configuration" - moredefs = [] - + # Perhaps a fancier check is in order here. + try: + nosmp = os.environ['NPY_NOSMP'] + nosmp = 1 + except KeyError: + nosmp = 0 + if nosmp: + moredefs = [('NPY_ALLOW_THREADS', '0')] + else: + moredefs = [('NPY_ALLOW_THREADS','WITH_THREAD')] # mathlibs = [] tc = testcode_mathlib() diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index c91d46a9e..580932869 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -1242,7 +1242,7 @@ PyArray_NewCopy(PyArrayObject *m1, NPY_ORDER fortran) PyArrayObject *ret; if (fortran == PyArray_ANYORDER) fortran = PyArray_ISFORTRAN(m1); - + Py_INCREF(m1->descr); ret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type, m1->descr, @@ -5076,6 +5076,7 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, goto fail; } */ + memset(data, 0, sd); } } @@ -7114,6 +7115,8 @@ _broadcast_cast(PyArrayObject *out, PyArrayObject *in, PyArray_CopySwapNFunc *ocopyfunc, *icopyfunc; char *obptr; + NPY_BEGIN_THREADS_DEF + delsize = PyArray_ITEMSIZE(out); selsize = PyArray_ITEMSIZE(in); multi = (PyArrayMultiIterObject *)PyArray_MultiIterNew(2, out, in); @@ -7150,6 +7153,12 @@ _broadcast_cast(PyArrayObject *out, PyArrayObject *in, if (in->descr->hasobject) memset(buffers[1], 0, N*selsize); +#if NPY_ALLOW_THREADS + if (!in->descr->hasobject && !out->descr->hasobject) { + NPY_BEGIN_THREADS + } +#endif + while(multi->index < multi->size) { _strided_buffered_cast(multi->iters[0]->dataptr, ostrides, @@ -7161,6 +7170,11 @@ _broadcast_cast(PyArrayObject *out, PyArrayObject *in, castfunc, out, in); PyArray_MultiIter_NEXT(multi); } +#if NPY_ALLOW_THREADS + if (!in->descr->hasobject && !out->descr->hasobject) { + NPY_END_THREADS + } +#endif Py_DECREF(multi); if (in->descr->hasobject) { obptr = buffers[1]; @@ -7197,6 +7211,8 @@ PyArray_CastTo(PyArrayObject *out, PyArrayObject *mp) PyArray_VectorUnaryFunc *castfunc=NULL; int mpsize = PyArray_SIZE(mp); int iswap, oswap; + + NPY_BEGIN_THREADS_DEF if (mpsize == 0) return 0; if (!PyArray_ISWRITEABLE(out)) { @@ -7214,7 +7230,17 @@ PyArray_CastTo(PyArrayObject *out, PyArrayObject *mp) (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out))); if (simple) { + +#if NPY_ALLOW_THREADS + if (!mp->descr->hasobject && !out->descr->hasobject) { + NPY_BEGIN_THREADS } +#endif castfunc(mp->data, out->data, mpsize, mp, out); + +#if NPY_ALLOW_THREADS + if (!mp->descr->hasobject && !out->descr->hasobject) { + NPY_END_THREADS } +#endif return 0; } diff --git a/numpy/core/src/arraytypes.inc.src b/numpy/core/src/arraytypes.inc.src index 1f4ee91d6..c126b8580 100644 --- a/numpy/core/src/arraytypes.inc.src +++ b/numpy/core/src/arraytypes.inc.src @@ -575,13 +575,12 @@ VOID_setitem(PyObject *op, char *ip, PyArrayObject *ap) */ static void @from@_to_@to@(register @fromtyp@ *ip, register @totyp@ *op, register intp n, - PyArrayObject *aip, PyArrayObject *aop) { - Py_BEGIN_ALLOW_THREADS + PyArrayObject *aip, PyArrayObject *aop) +{ while (n--) { *op++ = (@totyp@)*ip; @incr@; } - Py_END_ALLOW_THREADS } /**end repeat**/ @@ -591,12 +590,11 @@ static void */ static void @from@_to_BOOL(register @fromtyp@ *ip, register Bool *op, register intp n, - PyArrayObject *aip, PyArrayObject *aop) { - Py_BEGIN_ALLOW_THREADS + PyArrayObject *aip, PyArrayObject *aop) +{ while (n--) { *op++ = (Bool)(*ip++ != FALSE); } - Py_END_ALLOW_THREADS } /**end repeat**/ @@ -606,13 +604,12 @@ static void */ static void @from@_to_BOOL(register @fromtyp@ *ip, register Bool *op, register intp n, - PyArrayObject *aip, PyArrayObject *aop) { - Py_BEGIN_ALLOW_THREADS + PyArrayObject *aip, PyArrayObject *aop) +{ while (n--) { *op = (Bool)(((*ip).real != FALSE) || ((*ip).imag != FALSE)); op++; ip++; } - Py_END_ALLOW_THREADS } /**end repeat**/ @@ -624,11 +621,9 @@ static void BOOL_to_@to@(register Bool *ip, register @totyp@ *op, register intp n, PyArrayObject *aip, PyArrayObject *aop) { - Py_BEGIN_ALLOW_THREADS while (n--) { *op++ = (@totyp@)(*ip++ != FALSE); } - Py_END_ALLOW_THREADS } /**end repeat**/ @@ -643,12 +638,11 @@ static void @from@_to_@to@(register @fromtyp@ *ip, register @totyp@ *op, register intp n, PyArrayObject *aip, PyArrayObject *aop) { - Py_BEGIN_ALLOW_THREADS while (n--) { *op++ = (@totyp@)*ip++; *op++ = 0.0; } - Py_END_ALLOW_THREADS + } /**end repeat**/ @@ -661,13 +655,13 @@ static void */ static void @from@_to_@to@(register @fromtyp@ *ip, register @totyp@ *op, register intp n, - PyArrayObject *aip, PyArrayObject *aop) { - Py_BEGIN_ALLOW_THREADS + PyArrayObject *aip, PyArrayObject *aop) +{ n <<= 1; while (n--) { *op++ = (@totyp@)*ip++; } - Py_END_ALLOW_THREADS + } /**end repeat**/ diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c index 90553bc6c..f2368ba88 100644 --- a/numpy/core/src/multiarraymodule.c +++ b/numpy/core/src/multiarraymodule.c @@ -2819,7 +2819,7 @@ PyArray_CopyAndTranspose(PyObject *op) return NULL; } /* do 2-d loop */ - Py_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS optr = PyArray_DATA(ret); str2 = elsize*dims[0]; for (i=0; i<dims[0]; i++) { @@ -2831,7 +2831,7 @@ PyArray_CopyAndTranspose(PyObject *op) iptr += str2; } } - Py_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS Py_DECREF(arr); return ret; } @@ -4982,7 +4982,7 @@ PyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, dtype, 1, &n, NULL, NULL, 0, NULL); if (ret == NULL) return NULL; - Py_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS ptr = data; dptr = ret->data; for (index=0; index < n; index++) { @@ -5004,7 +5004,7 @@ PyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, PyArray_DIM(ret,0) = nread; } - Py_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS } else { #define _FILEBUFNUM 4096 @@ -5022,7 +5022,7 @@ PyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, NULL, NULL, 0, NULL); if (ret==NULL) return NULL; - Py_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS totalbytes = bytes = size * dtype->elsize; dptr = ret->data; ptr = data; @@ -5048,7 +5048,7 @@ PyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, nread*ret->descr->elsize); PyArray_DIM(ret,0) = nread; #undef _FILEBUFNUM - Py_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS } } return (PyObject *)ret; @@ -5230,9 +5230,9 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep) NULL, NULL, 0, NULL); if (r==NULL) return NULL; - Py_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS nread = fread(r->data, typecode->elsize, num, fp); - Py_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS } else { /* character reading */ intp i; @@ -5257,7 +5257,7 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep) NULL, NULL, 0, NULL); if (r==NULL) return NULL; - Py_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS dptr = r->data; for (i=0; i < num; i++) { if (done) break; @@ -5266,7 +5266,7 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep) nread += 1; dptr += r->descr->elsize; } - Py_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS if (PyErr_Occurred()) { Py_DECREF(r); return NULL; @@ -5287,7 +5287,7 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep) NULL, NULL, 0, NULL); if (r==NULL) return NULL; - Py_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS totalbytes = bytes = size * typecode->elsize; dptr = r->data; while (!done) { @@ -5313,7 +5313,7 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep) r->data = PyDataMem_RENEW(r->data, nread*r->descr->elsize); PyArray_DIM(r,0) = nread; num = nread; - Py_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS #undef _FILEBUFNUM } if (PyErr_Occurred()) { @@ -6380,6 +6380,9 @@ PyMODINIT_FUNC initmultiarray(void) { s = PyString_FromString("3.0"); PyDict_SetItemString(d, "__version__", s); Py_DECREF(s); + s = PyInt_FromLong(NPY_ALLOW_THREADS); + PyDict_SetItemString(d, "ALLOW_THREADS", s); + Py_DECREF(s); Py_INCREF(&PyArray_Type); PyDict_SetItemString(d, "ndarray", (PyObject *)&PyArray_Type); Py_INCREF(&PyArrayIter_Type); diff --git a/numpy/core/src/ufuncobject.c b/numpy/core/src/ufuncobject.c index 8e7e2a159..573bff639 100644 --- a/numpy/core/src/ufuncobject.c +++ b/numpy/core/src/ufuncobject.c @@ -1430,12 +1430,12 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, { PyUFuncLoopObject *loop; int i; - BEGIN_THREADS_DEF + NPY_BEGIN_THREADS_DEF if (!(loop = construct_loop(self, args, mps))) return -1; if (loop->notimplemented) {ufuncloop_dealloc(loop); return -2;} - LOOP_BEGIN_THREADS + NPY_LOOP_BEGIN_THREADS switch(loop->meth) { case ONE_UFUNCLOOP: @@ -1685,13 +1685,13 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, } } - LOOP_END_THREADS + NPY_LOOP_END_THREADS ufuncloop_dealloc(loop); return 0; fail: - LOOP_END_THREADS + NPY_LOOP_END_THREADS if (loop) ufuncloop_dealloc(loop); return -1; @@ -1988,14 +1988,14 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype) PyUFuncReduceObject *loop; intp i, n; char *dptr; - BEGIN_THREADS_DEF + NPY_BEGIN_THREADS_DEF /* Construct loop object */ loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0, "reduce"); if (!loop) return NULL; - LOOP_BEGIN_THREADS + NPY_LOOP_BEGIN_THREADS switch(loop->meth) { case ZERODIM_REDUCELOOP: /* fprintf(stderr, "ZERO..%d\n", loop->size); */ @@ -2106,7 +2106,7 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype) } } - LOOP_END_THREADS + NPY_LOOP_END_THREADS ret = loop->ret; /* Hang on to this reference -- will be decref'd with loop */ @@ -2115,7 +2115,7 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype) return (PyObject *)ret; fail: - LOOP_END_THREADS + NPY_LOOP_END_THREADS if (loop) ufuncreduce_dealloc(loop); return NULL; @@ -2130,13 +2130,14 @@ PyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, PyUFuncReduceObject *loop; intp i, n; char *dptr; + NPY_BEGIN_THREADS_DEF /* Construct loop object */ loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0, "accumulate"); if (!loop) return NULL; - LOOP_BEGIN_THREADS + NPY_LOOP_BEGIN_THREADS switch(loop->meth) { case ZERODIM_REDUCELOOP: /* Accumulate */ /* fprintf(stderr, "ZERO..%d\n", loop->size); */ @@ -2251,7 +2252,7 @@ PyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, } } - LOOP_END_THREADS + NPY_LOOP_END_THREADS ret = loop->ret; /* Hang on to this reference -- will be decref'd with loop */ Py_INCREF(ret); @@ -2259,7 +2260,7 @@ PyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, return (PyObject *)ret; fail: - LOOP_END_THREADS + NPY_LOOP_END_THREADS if (loop) ufuncreduce_dealloc(loop); return NULL; @@ -2295,6 +2296,7 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, intp mm=arr->dimensions[axis]-1; intp n, i, j; char *dptr; + NPY_BEGIN_THREADS_DEF /* Check for out-of-bounds values in indices array */ for (i=0; i<nn; i++) { @@ -2312,7 +2314,7 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, "reduceat"); if (!loop) return NULL; - LOOP_BEGIN_THREADS + NPY_LOOP_BEGIN_THREADS switch(loop->meth) { /* zero-length index -- return array immediately */ case ZERODIM_REDUCELOOP: @@ -2401,7 +2403,7 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, break; } - LOOP_END_THREADS + NPY_LOOP_END_THREADS ret = loop->ret; /* Hang on to this reference -- will be decref'd with loop */ @@ -2410,7 +2412,7 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, return (PyObject *)ret; fail: - LOOP_END_THREADS + NPY_LOOP_END_THREADS if (loop) ufuncreduce_dealloc(loop); return NULL; |