Skip to content

Commit

Permalink
gh-38: release Python GIL in numpy loops (#39)
Browse files Browse the repository at this point in the history
The Python GIL is now released while numpy evaluates the inner loops of
the vectorised functions. This might help in applications where other
Python code runs in parallel to healpix carrying out large computations.

Closes: #38
  • Loading branch information
ntessore authored Apr 14, 2024
1 parent 4cddf0d commit a13d3c1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/chealpix.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@ PyObject* vectorize(vecfunc func, void* args, npy_intp nin, npy_intp nout,
npy_intp *sizeptr = NpyIter_GetInnerLoopSizePtr(iter);
npy_intp *stride = NpyIter_GetInnerStrideArray(iter);
char **data = NpyIter_GetDataPtrArray(iter);
NPY_BEGIN_THREADS_DEF
if (!iternext)
goto iterfail;
NPY_BEGIN_THREADS_THRESHOLDED(NpyIter_GetIterSize(iter))
do {
func(args, *sizeptr, data, stride);
} while (iternext(iter));
NPY_END_THREADS
}

out = &NpyIter_GetOperandArray(iter)[nin];
Expand Down

0 comments on commit a13d3c1

Please sign in to comment.