MAINT: handle ``NPY_ALLOW_THREADS`` and related build option better by charris · Pull Request #26036 · numpy/numpy · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions doc/source/reference/c-api/array.rst
5 changes: 5 additions & 0 deletions numpy/_core/include/numpy/_numpyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
#mesondefine NPY_SIZEOF_PY_LONG_LONG
#mesondefine NPY_SIZEOF_LONGLONG

/*
* Defined to 1 or 0. Note that Pyodide hardcodes NPY_NO_SMP (and other defines
* in this header) for better cross-compilation, so don't rename them without a
* good reason.
*/
#mesondefine NPY_NO_SMP

#mesondefine NPY_VISIBILITY_HIDDEN
Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/include/numpy/ndarraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#define NPY_NO_EXPORT NPY_VISIBILITY_HIDDEN

/* Only use thread if configured in config and python supports it */
#if defined WITH_THREAD && !NPY_NO_SMP
/* Always allow threading unless it was explicitly disabled at build time */
#if !NPY_NO_SMP
#define NPY_ALLOW_THREADS 1
#else
#define NPY_ALLOW_THREADS 0
Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ endif
if cc.has_header('sys/endian.h')
cdata.set10('NPY_HAVE_SYS_ENDIAN_H', true)
endif
# Command-line switch; distutils build checked for `NPY_NOSMP` env var instead
# TODO: document this (search for NPY_NOSMP in C API docs)
# Build-time option to disable threading is stored and exposed in numpyconfig.h
# Note: SMP is an old acronym for threading (Symmetric/Shared-memory MultiProcessing)
cdata.set10('NPY_NO_SMP', get_option('disable-threading'))

visibility_hidden = ''
Expand Down
6 changes: 0 additions & 6 deletions numpy/_core/src/common/python_xerbla.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,16 @@ CBLAS_INT BLAS_FUNC(xerbla)(char *srname, CBLAS_INT *info)
char buf[sizeof(format) + 6 + 4]; /* 6 for name, 4 for param. num. */

int len = 0; /* length of subroutine name*/
#ifdef WITH_THREAD
PyGILState_STATE save;
#endif

while( len<6 && srname[len]!='\0' )
len++;
while( len && srname[len-1]==' ' )
len--;
#ifdef WITH_THREAD
save = PyGILState_Ensure();
#endif
PyOS_snprintf(buf, sizeof(buf), format, len, srname, (int)*info);
PyErr_SetString(PyExc_ValueError, buf);
#ifdef WITH_THREAD
PyGILState_Release(save);
#endif

return 0;
}
6 changes: 0 additions & 6 deletions numpy/linalg/lapack_lite/python_xerbla.c