diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-09-05 13:30:21 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-09-05 13:30:21 -0700 |
commit | b5dab6df0c9feef2d0b10ea7c56abd0b1df78abc (patch) | |
tree | ffd033bbc2880f568dd04a97083ded945530ef3f | |
parent | 573b3b0215294a881e3504cec8818ee194679342 (diff) | |
parent | fb0c7bdfd370dae9d580f97ee4ceadbcaced29c5 (diff) | |
download | numpy-b5dab6df0c9feef2d0b10ea7c56abd0b1df78abc.tar.gz |
Merge pull request #3642 from jseabold/openblas-install
BLD: Allow easy use of openblas.
-rw-r--r-- | numpy/distutils/system_info.py | 70 | ||||
-rw-r--r-- | site.cfg.example | 81 |
2 files changed, 90 insertions, 61 deletions
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 8ec1b8446..d9196ea5c 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -12,6 +12,7 @@ classes are available: lapack_atlas_info blas_info lapack_info + openblas_info blas_opt_info # usage recommended lapack_opt_info # usage recommended fftw_info,dfftw_info,sfftw_info @@ -119,7 +120,6 @@ import copy import warnings from glob import glob from functools import reduce - if sys.version_info[0] < 3: from ConfigParser import NoOptionError, ConfigParser else: @@ -298,6 +298,7 @@ def get_info(name, notfound_action=0): 'lapack_atlas': lapack_atlas_info, # use lapack_opt instead 'lapack_atlas_threads': lapack_atlas_threads_info, # ditto 'mkl': mkl_info, + 'openblas': openblas_info, # use blas_opt instead 'lapack_mkl': lapack_mkl_info, # use lapack_opt instead 'blas_mkl': blas_mkl_info, # use blas_opt instead 'x11': x11_info, @@ -1366,7 +1367,22 @@ class lapack_opt_info(system_info): def calc_info(self): - if sys.platform == 'darwin' and not os.environ.get('ATLAS', None): + openblas_info = get_info('openblas') + if openblas_info: + self.set_info(**openblas_info) + return + + lapack_mkl_info = get_info('lapack_mkl') + if lapack_mkl_info: + self.set_info(**lapack_mkl_info) + return + + atlas_info = get_info('atlas_threads') + if not atlas_info: + atlas_info = get_info('atlas') + + if sys.platform == 'darwin' and not atlas_info: + # Use the system lapack from Accelerate or vecLib under OSX args = [] link_args = [] if get_platform()[-4:] == 'i386' or 'intel' in get_platform() or \ @@ -1394,14 +1410,6 @@ class lapack_opt_info(system_info): define_macros=[('NO_ATLAS_INFO', 3)]) return - lapack_mkl_info = get_info('lapack_mkl') - if lapack_mkl_info: - self.set_info(**lapack_mkl_info) - return - - atlas_info = get_info('atlas_threads') - if not atlas_info: - atlas_info = get_info('atlas') #atlas_info = {} ## uncomment for testing need_lapack = 0 need_blas = 0 @@ -1455,7 +1463,22 @@ class blas_opt_info(system_info): def calc_info(self): - if sys.platform == 'darwin' and not os.environ.get('ATLAS', None): + blas_mkl_info = get_info('blas_mkl') + if blas_mkl_info: + self.set_info(**blas_mkl_info) + return + + openblas_info = get_info('openblas') + if openblas_info: + self.set_info(**openblas_info) + return + + atlas_info = get_info('atlas_blas_threads') + if not atlas_info: + atlas_info = get_info('atlas_blas') + + if sys.platform == 'darwin'and not atlas_info: + # Use the system BLAS from Accelerate or vecLib under OSX args = [] link_args = [] if get_platform()[-4:] == 'i386' or 'intel' in get_platform() or \ @@ -1487,14 +1510,6 @@ class blas_opt_info(system_info): define_macros=[('NO_ATLAS_INFO', 3)]) return - blas_mkl_info = get_info('blas_mkl') - if blas_mkl_info: - self.set_info(**blas_mkl_info) - return - - atlas_info = get_info('atlas_blas_threads') - if not atlas_info: - atlas_info = get_info('atlas_blas') need_blas = 0 info = {} if atlas_info: @@ -1537,6 +1552,23 @@ class blas_info(system_info): self.set_info(**info) +class openblas_info(blas_info): + section = 'openblas' + dir_env_var = 'OPENBLAS' + _lib_names = ['openblas'] + notfounderror = BlasNotFoundError + + def calc_info(self): + lib_dirs = self.get_lib_dirs() + + openblas_libs = self.get_libs('openblas_libs', self._lib_names) + info = self.check_libs(lib_dirs, openblas_libs, []) + if info is None: + return + info['language'] = 'f77' # XXX: is it generally true? + self.set_info(**info) + + class blas_src_info(system_info): section = 'blas_src' dir_env_var = 'BLAS_SRC' diff --git a/site.cfg.example b/site.cfg.example index 89d108739..4cf4a33a4 100644 --- a/site.cfg.example +++ b/site.cfg.example @@ -63,33 +63,46 @@ #library_dirs = /usr/local/lib #include_dirs = /usr/local/include -# Optimized BLAS and LAPACK -# ------------------------- -# Use the blas_opt and lapack_opt sections to give any settings that are -# required to link against your chosen BLAS and LAPACK, including the regular -# FORTRAN reference BLAS and also ATLAS. Some other sections still exist for -# linking against certain optimized libraries (e.g. [atlas], [lapack_atlas]), -# however, they are now deprecated and should not be used. -# -# These are typical configurations for ATLAS (assuming that the library and -# include directories have already been set in [DEFAULT]; the include directory -# is important for the BLAS C interface): -# -#[blas_opt] -#libraries = f77blas, cblas, atlas -# -#[lapack_opt] -#libraries = lapack, f77blas, cblas, atlas -# -# If your ATLAS was compiled with pthreads, the names of the libraries might be -# different: -# -#[blas_opt] -#libraries = ptf77blas, ptcblas, atlas -# -#[lapack_opt] -#libraries = lapack, ptf77blas, ptcblas, atlas +# Atlas +# ----- +# Atlas is an open source optimized implementation of the BLAS and Lapack +# routines. Numpy will try to build against Atlas by default when available in +# the system library dirs. To build numpy against a custom installation of +# Atlas you can add an explicit section such as the following. Here we assume +# that Atlas was configured with ``prefix=/opt/atlas``. +# +# [atlas] +# library_dirs = /opt/atlas/lib +# include_dirs = /opt/atlas/include + +# OpenBLAS +# -------- +# OpenBLAS is another open source optimized implementation of BLAS and Lapack +# and can be seen as an alternative to Atlas. To build numpy against OpenBLAS +# instead of Atlas, use this section instead of the above, adjusting as needed +# for your configuration (in the following example we installed OpenBLAS with +# ``make install PREFIX=/opt/OpenBLAS``. +# +# [openblas] +# libraries = openblas +# library_dirs = /opt/OpenBLAS/lib +# include_dirs = /opt/OpenBLAS/include +# MKL +#---- +# MKL is Intel's very optimized yet proprietary implementation of BLAS and +# Lapack. +# For recent (9.0.21, for example) mkl, you need to change the names of the +# lapack library. Assuming you installed the mkl in /opt, for a 32 bits cpu: +# [mkl] +# library_dirs = /opt/intel/mkl/9.1.023/lib/32/ +# lapack_libs = mkl_lapack +# +# For 10.*, on 32 bits machines: +# [mkl] +# library_dirs = /opt/intel/mkl/10.0.1.014/lib/32/ +# lapack_libs = mkl_lapack +# mkl_libs = mkl, guide # UMFPACK # ------- @@ -110,7 +123,6 @@ #[umfpack] #umfpack_libs = umfpack - # FFT libraries # ------------- # There are two FFT libraries that we can configure here: FFTW (2 and 3) and djbfft. @@ -128,18 +140,3 @@ #[djbfft] #include_dirs = /usr/local/djbfft/include #library_dirs = /usr/local/djbfft/lib - - -# MKL -#---- -# For recent (9.0.21, for example) mkl, you need to change the names of the -# lapack library. Assuming you installed the mkl in /opt, for a 32 bits cpu: -# [mkl] -# library_dirs = /opt/intel/mkl/9.1.023/lib/32/ -# lapack_libs = mkl_lapack -# -# For 10.*, on 32 bits machines: -# [mkl] -# library_dirs = /opt/intel/mkl/10.0.1.014/lib/32/ -# lapack_libs = mkl_lapack -# mkl_libs = mkl, guide |