-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
BLD, ENH: Enable Accelerate Framework #18874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
======= | ||
WARNING | ||
======= | ||
|
||
This directory (numpy/_build_utils) is *not* part of the public numpy API, | ||
- it is internal build support for numpy. | ||
- it is only present in source distributions or during an in place build | ||
- it is *not* installed with the rest of numpy | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import os | ||
import sys | ||
import re | ||
|
||
__all__ = ['uses_accelerate_framework'] | ||
|
||
def uses_accelerate_framework(info): | ||
""" Returns True if Accelerate framework is used for BLAS/LAPACK """ | ||
# If we're not building on Darwin (macOS), don't use Accelerate | ||
if sys.platform != "darwin": | ||
return False | ||
# If we're building on macOS, but targeting a different platform, | ||
# don't use Accelerate. | ||
if os.getenv('_PYTHON_HOST_PLATFORM', None): | ||
return False | ||
r_accelerate = re.compile("Accelerate") | ||
extra_link_args = info.get('extra_link_args', '') | ||
for arg in extra_link_args: | ||
if r_accelerate.search(arg): | ||
return True | ||
return False |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,22 +375,6 @@ def add_system_root(library_root): | |
so_ext = get_shared_lib_extension() | ||
|
||
|
||
def is_symlink_to_accelerate(filename): | ||
accelpath = '/System/Library/Frameworks/Accelerate.framework' | ||
return (sys.platform == 'darwin' and os.path.islink(filename) and | ||
os.path.realpath(filename).startswith(accelpath)) | ||
|
||
|
||
_accel_msg = ( | ||
'Found {filename}, but that file is a symbolic link to the ' | ||
'MacOS Accelerate framework, which is not supported by NumPy. ' | ||
'You must configure the build to use a different optimized library, ' | ||
'or disable the use of optimized BLAS and LAPACK by setting the ' | ||
'environment variables NPY_BLAS_ORDER="" and NPY_LAPACK_ORDER="" ' | ||
'before building NumPy.' | ||
) | ||
|
||
|
||
def get_standard_file(fname): | ||
"""Returns a list of files named 'fname' from | ||
1) System-wide directory (directory-location of this module) | ||
|
@@ -539,6 +523,7 @@ def get_info(name, notfound_action=0): | |
'blis': blis_info, # use blas_opt instead | ||
'lapack_mkl': lapack_mkl_info, # use lapack_opt instead | ||
'blas_mkl': blas_mkl_info, # use blas_opt instead | ||
'accelerate': accelerate_info, # use blas_opt instead | ||
'openblas64_': openblas64__info, | ||
'openblas64__lapack': openblas64__lapack_info, | ||
'openblas_ilp64': openblas_ilp64_info, | ||
|
@@ -1029,9 +1014,6 @@ def _find_lib(self, lib_dir, lib, exts): | |
for prefix in lib_prefixes: | ||
p = self.combine_paths(lib_dir, prefix + lib + ext) | ||
if p: | ||
# p[0] is the full path to the binary library file. | ||
if is_symlink_to_accelerate(p[0]): | ||
raise RuntimeError(_accel_msg.format(filename=p[0])) | ||
break | ||
if p: | ||
assert len(p) == 1 | ||
|
@@ -1766,10 +1748,18 @@ def get_atlas_version(**config): | |
|
||
class lapack_opt_info(system_info): | ||
notfounderror = LapackNotFoundError | ||
|
||
# List of all known LAPACK libraries, in the default order | ||
lapack_order = ['mkl', 'openblas', 'flame', 'atlas', 'lapack'] | ||
lapack_order = ['accelerate', 'mkl', 'openblas', 'flame', 'atlas', 'lapack'] | ||
rgommers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
order_env_var_name = 'NPY_LAPACK_ORDER' | ||
|
||
def _calc_info_accelerate(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, done =). |
||
info = get_info('accelerate') | ||
if info: | ||
self.set_info(**info) | ||
return True | ||
return False | ||
|
||
def _calc_info_mkl(self): | ||
info = get_info('lapack_mkl') | ||
if info: | ||
|
@@ -1820,13 +1810,6 @@ def _calc_info_atlas(self): | |
return True | ||
return False | ||
|
||
def _calc_info_accelerate(self): | ||
info = get_info('accelerate') | ||
if info: | ||
self.set_info(**info) | ||
return True | ||
return False | ||
|
||
def _get_info_blas(self): | ||
# Default to get the optimized BLAS implementation | ||
info = get_info('blas_opt') | ||
|
@@ -1942,9 +1925,17 @@ class lapack64__opt_info(lapack_ilp64_opt_info): | |
class blas_opt_info(system_info): | ||
notfounderror = BlasNotFoundError | ||
# List of all known BLAS libraries, in the default order | ||
blas_order = ['mkl', 'blis', 'openblas', 'atlas', 'blas'] | ||
|
||
blas_order = ['accelerate', 'mkl', 'blis', 'openblas', 'atlas', 'blas'] | ||
order_env_var_name = 'NPY_BLAS_ORDER' | ||
|
||
def _calc_info_accelerate(self): | ||
info = get_info('accelerate') | ||
if info: | ||
self.set_info(**info) | ||
return True | ||
return False | ||
|
||
def _calc_info_mkl(self): | ||
info = get_info('blas_mkl') | ||
if info: | ||
|
@@ -1979,13 +1970,6 @@ def _calc_info_atlas(self): | |
return True | ||
return False | ||
|
||
def _calc_info_accelerate(self): | ||
info = get_info('accelerate') | ||
if info: | ||
self.set_info(**info) | ||
return True | ||
return False | ||
|
||
def _calc_info_blas(self): | ||
# Warn about a non-optimized BLAS library | ||
warnings.warn(BlasOptNotFoundError.__doc__ or '', stacklevel=3) | ||
|
Uh oh!
There was an error while loading. Please reload this page.