diff options
author | Julian Taylor <juliantaylor108@gmail.com> | 2014-05-02 13:51:42 +0200 |
---|---|---|
committer | Julian Taylor <juliantaylor108@gmail.com> | 2014-05-02 13:51:42 +0200 |
commit | a0cf18394d5ce33514fdc37093bd2f65ad4b0dde (patch) | |
tree | 054d84643c914f009ccceb394d1fa6b830f602e6 /numpy | |
parent | 4a2783f28b3270e4d5c79e8d0a8b04b97744ac5d (diff) | |
parent | 733f547f363c6d112992d9666e65c6518a21c5fb (diff) | |
download | numpy-a0cf18394d5ce33514fdc37093bd2f65ad4b0dde.tar.gz |
Merge pull request #4580 from juliantaylor/openblas-affinity
ENH: disable OpenBLAS affinity settings
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/numeric.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 778eed8c3..8c569ea15 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1,5 +1,6 @@ from __future__ import division, absolute_import, print_function +import os import sys import warnings import collections @@ -1074,9 +1075,17 @@ def outer(a, b, out=None): return multiply(a.ravel()[:, newaxis], b.ravel()[newaxis,:], out) # try to import blas optimized dot if available +envbak = os.environ.copy() try: # importing this changes the dot function for basic 4 types # to blas-optimized versions. + + # disables openblas affinity setting of the main thread that limits + # python threads or processes to one core + if 'OPENBLAS_MAIN_FREE' not in os.environ: + os.environ['OPENBLAS_MAIN_FREE'] = '1' + if 'GOTOBLAS_MAIN_FREE' not in os.environ: + os.environ['GOTOBLAS_MAIN_FREE'] = '1' from ._dotblas import dot, vdot, inner, alterdot, restoredot except ImportError: # docstrings are in add_newdocs.py @@ -1088,6 +1097,10 @@ except ImportError: pass def restoredot(): pass +finally: + os.environ.clear() + os.environ.update(envbak) + del envbak def tensordot(a, b, axes=2): """ |