From fcd5164ae33118b70548de895cf746806148dd60 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Sun, 21 Nov 2021 10:05:21 +0100 Subject: [PATCH] MAINT: set `OPENBLAS_THREAD_TIMEOUT` on arm64 macOS to avoid performance issues Addresses at least part of https://github.com/scipy/scipy/issues/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. --- _distributor_init.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/_distributor_init.py b/_distributor_init.py index b339063a..1a6894d9 100644 --- a/_distributor_init.py +++ b/_distributor_init.py @@ -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 @@ -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'