Detect number of threads, if set in an environment variable.
()
| 39 | _ncores = ncpus |
| 40 | |
| 41 | def _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 |
| 48 | related to threading have been reported on some sparc machines. |
| 49 | The number of threads can be changed using the "set_num_threads" |
| 50 | function.''') |
| 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() |
no outgoing calls
no test coverage detected
searching dependent graphs…