Skip to content

Commit

Permalink
MAINT: set OPENBLAS_THREAD_TIMEOUT on arm64 macOS to avoid performa…
Browse files Browse the repository at this point in the history
…nce issues

Addresses at least part of scipy/scipy#15050,
TBD if that closes it or if we need to rebuild OpenBLAS instead later.
For now (and for the 1.7.3 release) this is the safest and quickest
improvement.
  • Loading branch information
rgommers committed Nov 21, 2021
1 parent d94b566 commit fcd5164
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions _distributor_init.py
Expand Up @@ -10,11 +10,14 @@
"""

import os
import sys
import platform


# on Windows SciPy loads important DLLs
# and the code below aims to alleviate issues with DLL
# path resolution portability with an absolute path DLL load
if os.name == 'nt':
# on Windows SciPy loads important DLLs
# and the code below aims to alleviate issues with DLL
# path resolution portability with an absolute path DLL load
from ctypes import WinDLL
import glob
# convention for storing / loading the DLL from
Expand Down Expand Up @@ -61,3 +64,9 @@
WinDLL(os.path.abspath(filename))
finally:
os.chdir(owd)
elif sys.platform == 'darwin' and platform.machine() == 'arm64':
# On arm64 macOS the OpenBLAS runtimes of NumPy and SciPy don't seem to work
# well together unless this timeout limit is set - it results in very slow
# performance for some linalg functionality.
# See https://github.com/scipy/scipy/issues/15050 for details.
os.environ['OPENBLAS_THREAD_TIMEOUT'] = '1'

0 comments on commit fcd5164

Please sign in to comment.