8000 Merge pull request #3642 from jseabold/openblas-install · juliantaylor/numpy@b5dab6d · GitHub
[go: up one dir, main page]

Skip to content

Commit b5dab6d

Browse files
committed
Merge pull request numpy#3642 from jseabold/openblas-install
BLD: Allow easy use of openblas.
2 parents 573b3b0 + fb0c7bd commit b5dab6d

File tree

2 files changed

+90
-61
lines changed

2 files changed

+90
-61
lines changed

numpy/distutils/system_info.py

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
lapack_atlas_info
1313
blas_info
1414
lapack_info
15+
openblas_info
1516
blas_opt_info # usage recommended
1617
lapack_opt_info # usage recommended
1718
fftw_info,dfftw_info,sfftw_info
@@ -119,7 +120,6 @@
119120
import warnings
120121
from glob import glob
121122
from functools import reduce
122-
123123
if sys.version_info[0] < 3:
124124
from ConfigParser import NoOptionError, ConfigParser
125125
else:
@@ -298,6 +298,7 @@ def get_info(name, notfound_action=0):
298298
'lapack_atlas': lapack_atlas_info, # use lapack_opt instead
299299
'lapack_atlas_threads': lapack_atlas_threads_info, # ditto
300300
'mkl': mkl_info,
301+
'openblas': openblas_info, # use blas_opt instead
301302
'lapack_mkl': lapack_mkl_info, # use lapack_opt instead
302303
'blas_mkl': blas_mkl_info, # use blas_opt instead
303304
'x11': x11_info,
@@ -1366,7 +1367,22 @@ class lapack_opt_info(system_info):
13661367

13671368
def calc_info(self):
13681369

1369-
if sys.platform == 'darwin' and not os.environ.get('ATLAS', None):
1370+
openblas_info = get_info('openblas')
1371+
if openblas_info:
1372+
self.set_info(**openblas_info)
1373+
return
1374+
1375+
lapack_mkl_info = get_info('lapack_mkl')
1376+
if lapack_mkl_info:
1377+
self.set_info(**lapack_mkl_info)
1378+
return
1379+
1380+
atlas_info = get_info('atlas_threads')
1381+
if not atlas_info:
1382+
atlas_info = get_info('atlas')
1383+
1384+
if sys.platform == 'darwin' and not atlas_info:
1385+
# Use the system lapack from Accelerate or vecLib under OSX
13701386
args = []
13711387
link_args = []
13721388
if get_platform()[-4:] == 'i386' or 'intel' in get_platform() or \
@@ -1394,14 +1410,6 @@ def calc_info(self):
13941410
define_macros=[('NO_ATLAS_INFO', 3)])
13951411
return
13961412

1397-
lapack_mkl_info = get_info('lapack_mkl')
1398-
if lapack_mkl_info:
1399-
self.set_info(**lapack_mkl_info)
1400-
return
1401-
1402-
atlas_info = get_info('atlas_threads')
1403-
if not atlas_info:
1404-
atlas_info = get_info('atlas')
14051413
#atlas_info = {} ## uncomment for testing
14061414
need_lapack = 0
14071415
need_blas = 0
@@ -1455,7 +1463,22 @@ class blas_opt_info(system_info):
14551463

14561464
def calc_info(self):
14571465

1458-
if sys.platform == 'darwin' and not os.environ.get('ATLAS', None):
1466+
blas_mkl_info = get_info('blas_mkl')
1467+
if blas_mkl_info:
1468+
self.set_info(**blas_mkl_info)
1469+
return
1470+
1471+
openblas_info = get_info('openblas')
1472+
if openblas_info:
1473+
self.set_info(**openblas_info)
1474+
return
1475+
1476+
atlas_info = get_info('atlas_blas_threads')
1477+
if not atlas_info:
1478+
atlas_info = get_info('atlas_blas')
1479+
1480+
if sys.platform == 'darwin'and not atlas_info:
1481+
# Use the system BLAS from Accelerate or vecLib under OSX
14591482
args = []
14601483
link_args = []
14611484
if get_platform()[-4:] == 'i386' or 'intel' in get_platform() or \
@@ -1487,14 +1510,6 @@ def calc_info(self):
14871510
define_macros=[('NO_ATLAS_INFO', 3)])
14881511
return
14891512

1490-
blas_mkl_info = get_info('blas_mkl')
1491-
if blas_mkl_info:
1492-
self.set_info(**blas_mkl_info)
1493-
return
1494-
1495-
atlas_info = get_info('atlas_blas_threads')
1496-
if not atlas_info:
1497-
atlas_info = get_info('atlas_blas')
14981513
need_blas = 0
14991514
info = {}
15001515
if atlas_info:
@@ -1537,6 +1552,23 @@ def calc_info(self):
15371552
self.set_info(**info)
15381553

15391554

1555+
class openblas_info(blas_info):
1556+
section = 'openblas'
1557+
dir_env_var = 'OPENBLAS'
1558+
_lib_names = ['openblas']
1559+
notfounderror = BlasNotFoundError
1560+
1561+
def calc_info(self):
1562+
lib_dirs = self.get_lib_dirs()
1563+
1564+
openblas_libs = self.get_libs('openblas_libs', self._lib_names)
1565+
info = self.check_libs(lib_dirs, openblas_libs, [])
1566+
if info is None:
1567+
return
1568+
info['language'] = 'f77' # XXX: is it generally true?
1569+
self.set_info(**info)
1570+
1571+
15401572
class blas_src_info(system_info):
15411573
section = 'blas_src'
15421574
dir_env_var = 'BLAS_SRC'

site.cfg.example

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,46 @@
6363
#library_dirs = /usr/local/lib
6464
#include_dirs = /usr/local/include
6565

66-
# Optimized BLAS and LAPACK
67-
# -------------------------
68-
# Use the blas_opt and lapack_opt sections to give any settings that are
69-
# required to link against your chosen BLAS and LAPACK, including the regular
70-
# FORTRAN reference BLAS and also ATLAS. Some other sections still exist for
71-
# linking against certain optimized libraries (e.g. [atlas], [lapack_atlas]),
72-
# however, they are now deprecated and should not be used.
73-
#
74-
# These are typical configurations for ATLAS (assuming that the library and
75-
# include directories have already been set in [DEFAULT]; the include directory
76-
# is important for the BLAS C interface):
77-
#
78-
#[blas_opt]
79-
#libraries = f77blas, cblas, atlas
80-
#
81-
#[lapack_opt]
82-
#libraries = lapack, f77blas, cblas, atlas
83-
#
84-
# If your ATLAS was compiled with pthreads, the names of the libraries might be
85-
# different:
86-
#
87-
#[blas_opt]
88-
#libraries = ptf77blas, ptcblas, atlas
89-
#
90-
#[lapack_opt]
91-
#libraries = lapack, ptf77blas, ptcblas, atlas
66+
# Atlas
67+
# -----
68+
# Atlas is an open source optimized implementation of the BLAS and Lapack
69+
# routines. Numpy will try to build against Atlas by default when available in
70+
# the system library dirs. To build numpy against a custom installation of
71+
# Atlas you can add an explicit section such as the following. Here we assume
72+
# that Atlas was configured with ``prefix=/opt/atlas``.
73+
#
74+
# [atlas]
75+
# library_dirs = /opt/atlas/lib
76+
# include_dirs = /opt/atlas/include
77+
78+
# OpenBLAS
79+
# --------
80+
# OpenBLAS is another open source optimized implementation of BLAS and Lapack
81+
# and can be seen as an alternative to Atlas. To build numpy against OpenBLAS
82+
# instead of Atlas, use this section instead of the above, adjusting as needed
83+
# for your configuration (in the following example we installed OpenBLAS with
84+
# ``make install PREFIX=/opt/OpenBLAS``.
85+
#
86+
# [openblas]
87+
# libraries = openblas
88+
# library_dirs = /opt/OpenBLAS/lib
89+
# include_dirs = /opt/OpenBLAS/include
9290

91+
# MKL
92+
#----
93+
# MKL is Intel's very optimized yet proprietary implementation of BLAS and
94+
# Lapack.
95+
# For recent (9.0.21, for example) mkl, you need to change the names of the
96+
# lapack library. Assuming you installed the mkl in /opt, for a 32 bits cpu:
97+
# [mkl]
98+
# library_dirs = /opt/intel/mkl/9.1.023/lib/32/
99+
# lapack_libs = mkl_lapack
100+
#
101+
# For 10.*, on 32 bits machines:
102+
# [mkl]
103+
# library_dirs = /opt/intel/mkl/10.0.1.014/lib/32/
104+
# lapack_libs = mkl_lapack
105+
# mkl_libs = mkl, guide
93106

94107
# UMFPACK
95108
# -------
@@ -110,7 +123,6 @@
110123
#[umfpack]
111124
#umfpack_libs = umfpack
112125

113-
114126
# FFT libraries
115127
# -------------
116128
# There are two FFT libraries that we can configure here: FFTW (2 and 3) and djbfft.
@@ -128,18 +140,3 @@
128140
#[djbfft]
129141
#include_dirs = /usr/local/djbfft/include
130142
#library_dirs = /usr/local/djbfft/lib
131-
132-
133-
# MKL
134-
#----
135-
# For recent (9.0.21, for example) mkl, you need to change the names of the
136-
# lapack library. Assuming you installed the mkl in /opt, for a 32 bits cpu:
137-
# [mkl]
138-
# library_dirs = /opt/intel/mkl/9.1.023/lib/32/
139-
# lapack_libs = mkl_lapack
140-
#
141-
# For 10.*, on 32 bits machines:
142-
# [mkl]
143-
# library_dirs = /opt/intel/mkl/10.0.1.014/lib/32/
144-
# lapack_libs = mkl_lapack
145-
# mkl_libs = mkl, guide

0 commit comments

Comments
 (0)
0