summaryrefslogtreecommitdiff
path: root/tools/openblas_support.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/openblas_support.py')
-rw-r--r--tools/openblas_support.py47
1 files changed, 34 insertions, 13 deletions
diff --git a/tools/openblas_support.py b/tools/openblas_support.py
index 964adce6e..1a63d18b4 100644
--- a/tools/openblas_support.py
+++ b/tools/openblas_support.py
@@ -40,7 +40,15 @@ def get_arch():
assert ret in ARCHITECTURES
return ret
-def download_openblas(target, arch):
+def get_ilp64():
+ if os.environ.get("NPY_USE_BLAS_ILP64", "0") == "0":
+ return None
+ if IS_32BIT:
+ raise RuntimeError("NPY_USE_BLAS_ILP64 set on 32-bit arch")
+ return "64_"
+
+def download_openblas(target, arch, ilp64):
+ fnsuffix = {None: "", "64_": "64_"}[ilp64]
filename = ''
if arch == 'arm':
# ARMv8 OpenBLAS built using script available here:
@@ -48,7 +56,7 @@ def download_openblas(target, arch):
# build done on GCC compile farm machine named gcc115
# tarball uploaded manually to an unshared Dropbox location
filename = ('https://www.dropbox.com/s/vdeckao4omss187/'
- 'openblas-{}-armv8.tar.gz?dl=1'.format(OPENBLAS_V))
+ 'openblas{}-{}-armv8.tar.gz?dl=1'.format(fnsuffix, OPENBLAS_V))
typ = 'tar.gz'
elif arch == 'ppc64':
# build script for POWER8 OpenBLAS available here:
@@ -56,25 +64,25 @@ def download_openblas(target, arch):
# built on GCC compile farm machine named gcc112
# manually uploaded tarball to an unshared Dropbox location
filename = ('https://www.dropbox.com/s/yt0d2j86x1j8nh1/'
- 'openblas-{}-ppc64le-power8.tar.gz?dl=1'.format(OPENBLAS_V))
+ 'openblas{}-{}-ppc64le-power8.tar.gz?dl=1'.format(fnsuffix, OPENBLAS_V))
typ = 'tar.gz'
elif arch == 'darwin':
- filename = '{0}/openblas-{1}-macosx_10_9_x86_64-gf_1becaaa.tar.gz'.format(
- RACKSPACE, OPENBLAS_LONG)
+ filename = '{0}/openblas{1}-{2}-macosx_10_9_x86_64-gf_1becaaa.tar.gz'.format(
+ RACKSPACE, fnsuffix, OPENBLAS_LONG)
typ = 'tar.gz'
elif arch == 'windows':
if IS_32BIT:
suffix = 'win32-gcc_7_1_0.zip'
else:
suffix = 'win_amd64-gcc_7_1_0.zip'
- filename = '{0}/openblas-{1}-{2}'.format(RACKSPACE, OPENBLAS_LONG, suffix)
+ filename = '{0}/openblas{1}-{2}-{3}'.format(RACKSPACE, fnsuffix, OPENBLAS_LONG, suffix)
typ = 'zip'
elif arch == 'x86':
if IS_32BIT:
suffix = 'manylinux1_i686.tar.gz'
else:
suffix = 'manylinux1_x86_64.tar.gz'
- filename = '{0}/openblas-{1}-{2}'.format(RACKSPACE, OPENBLAS_LONG, suffix)
+ filename = '{0}/openblas{1}-{2}-{3}'.format(RACKSPACE, fnsuffix, OPENBLAS_LONG, suffix)
typ = 'tar.gz'
if not filename:
return None
@@ -86,7 +94,7 @@ def download_openblas(target, arch):
return None
return typ
-def setup_openblas(arch=get_arch()):
+def setup_openblas(arch=get_arch(), ilp64=get_ilp64()):
'''
Download and setup an openblas library for building. If successful,
the configuration script will find it automatically.
@@ -100,7 +108,7 @@ def setup_openblas(arch=get_arch()):
_, tmp = mkstemp()
if not arch:
raise ValueError('unknown architecture')
- typ = download_openblas(tmp, arch)
+ typ = download_openblas(tmp, arch, ilp64)
if not typ:
return ''
if arch == 'windows':
@@ -180,11 +188,17 @@ def test_setup(arches):
'''
Make sure all the downloadable files exist and can be opened
'''
- for arch in arches:
+ def items():
+ for arch in arches:
+ yield arch, None
+ if arch in ('x86', 'darwin', 'windows'):
+ yield arch, '64_'
+
+ for arch, ilp64 in items():
if arch == '':
continue
try:
- target = setup_openblas(arch)
+ target = setup_openblas(arch, ilp64)
except:
print('Could not setup %s' % arch)
raise
@@ -192,7 +206,7 @@ def test_setup(arches):
raise RuntimeError('Could not setup %s' % arch)
print(target)
-def test_version(expected_version):
+def test_version(expected_version, ilp64=get_ilp64()):
"""
Assert that expected OpenBLAS version is
actually available via NumPy
@@ -201,12 +215,19 @@ def test_version(expected_version):
import ctypes
dll = ctypes.CDLL(numpy.core._multiarray_umath.__file__)
- get_config = dll.openblas_get_config
+ if ilp64 == "64_":
+ get_config = dll.openblas_get_config64_
+ else:
+ get_config = dll.openblas_get_config
get_config.restype=ctypes.c_char_p
res = get_config()
print('OpenBLAS get_config returned', str(res))
check_str = b'OpenBLAS %s' % expected_version[0].encode()
assert check_str in res
+ if ilp64:
+ assert b"USE64BITINT" in res
+ else:
+ assert b"USE64BITINT" not in res
if __name__ == '__main__':
import argparse