summaryrefslogtreecommitdiff
path: root/numpy/core/setup.py
diff options
context:
space:
mode:
authorSturla Molden <sturla@molden.no>2014-10-27 07:45:57 +0100
committerCharles Harris <charlesr.harris@gmail.com>2015-05-03 12:58:26 -0600
commitcf3077696dd76d88e77173546a0d969eda3a7aa0 (patch)
tree4880f6a00c5a3b16ad3bbb575b8338d8a47a442f /numpy/core/setup.py
parent3782f7e0bfd9ac230b672a1295df580a40e9e109 (diff)
downloadnumpy-cf3077696dd76d88e77173546a0d969eda3a7aa0.tar.gz
BUG: Workaround segfault in Apple Accelerate framework SGEMV
SGEMV in Accelerate framework will segfault on MacOS X version 10.9 (aka Mavericks) if arrays are not aligned to 32 byte boundaries and the CPU supports AVX instructions. This can produce segfaults in np.dot. This patch overshadows the symbols cblas_sgemv, sgemv_ and sgemv exported by Accelerate to produce the correct behavior. The MacOS X version and CPU specs are checked on module import. If Mavericks and AVX are detected the call to SGEMV is emulated with a call to SGEMM if the arrays are not 32 byte aligned. If the exported symbols cannot be overshadowed on module import, a fatal error is produced and the process aborts. All the fixes are in a self-contained C file and do not alter the multiarray C code. The patch is not applied unless NumPy is configured to link with Apple's Accelerate framework.
Diffstat (limited to 'numpy/core/setup.py')
-rw-r--r--numpy/core/setup.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index 11b443cf8..7a82f1e35 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -12,6 +12,7 @@ from os.path import join
from numpy.distutils import log
from distutils.dep_util import newer
from distutils.sysconfig import get_config_var
+from numpy.build_utils.apple_accelerate import uses_accelerate_framework, get_sgemv_fix
from setup_common import *
@@ -838,6 +839,8 @@ def configuration(parent_package='',top_path=None):
multiarray_src.extend([join('src', 'multiarray', 'cblasfuncs.c'),
join('src', 'multiarray', 'python_xerbla.c'),
])
+ if uses_accelerate_framework(blas_info):
+ multiarray_src.extend(get_sgemv_fix())
else:
extra_info = {}