MCPcopy Create free account
hub / github.com/pydata/numexpr / _detect_nthreads

Function _detect_nthreads

numexpr3/utils.py:41–57  ·  view source on GitHub ↗

Detect number of threads, if set in an environment variable.

()

Source from the content-addressed store, hash-verified

39 _ncores = ncpus
40
41def _detect_nthreads() -> None:
42 """Detect number of threads, if set in an environment variable."""
43 # Otherwise use number of detected cores.
44 global _nthreads, _ncores
45 if 'sparc' in platform.machine():
46 import warnings as __warnings
47 __warnings.warn('''The number of threads have been set to 1 because problems
48related to threading have been reported on some sparc machines.
49The number of threads can be changed using the "set_num_threads"
50function.''')
51 _nthreads = 1
52 elif 'NUMEXPR_NUM_THREADS' in os.environ:
53 _nthreads = int( os.environ['NUMEXPR_NUM_THREADS'] )
54 elif 'OMP_NUM_THREADS' in os.environ:
55 _nthreads = int( os.environ['OMP_NUM_THREADS'] )
56 else:
57 _nthreads = _ncores
58
59# More module initialization
60_detect_ncores()

Callers 1

utils.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…