Skip to content

Commit

Permalink
release Python GIL in numpy loops
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.
  • Loading branch information
ntessore committed Apr 14, 2024
1 parent 9415590 commit df50072
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 df50072

Please sign in to comment.