Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit e95a5fd

Browse files
committed
use os.sched_getaffinity when available
1 parent 6881dfe commit e95a5fd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎numba/core/config.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,12 @@ def avx_default():
367367
DISABLE_HSA = _readenv("NUMBA_DISABLE_HSA", int, 0)
368368

369369
# The default number of threads to use.
370-
NUMBA_DEFAULT_NUM_THREADS = max(1, multiprocessing.cpu_count())
370+
NUMBA_DEFAULT_NUM_THREADS = max(
371+
1,
372+
len(os.sched_getaffinity(0))
373+
if hasattr(os, "sched_getaffinity")
374+
else multiprocessing.cpu_count(),
375+
)
371376

372377
# Numba thread pool size (defaults to number of CPUs on the system).
373378
_NUMBA_NUM_THREADS = _readenv("NUMBA_NUM_THREADS", int,

0 commit comments

Comments
 (0)