BLD: Allow users to specify BLAS and LAPACK library link order#13132
BLD: Allow users to specify BLAS and LAPACK library link order#13132rgommers merged 7 commits intonumpy:masterfrom
Conversation
|
I would be happy to create a test, but it seems extremely build specific and probably difficult in a testing environment? Do you have a CI just for testing Also, sorry I created a commit with |
Does it? We can also do |
Yeah, it's not really testable on CI. If it passes our existing CI (which uses OpenBLAS and
There's a few things in
No worries. It is ENH anyway arguably, it's a distutils enhancement. |
|
The two CI failures are the same - Building with |
|
Actually, checking that any of |
Only if MKL is not installed.
Agreed, it is probably more meant as a developer thing. And it would also be way easier to have system installed BLAS/LAPACK versions and letting users control this without complicated mixtures of This PR tries to streamline this in a unified way. A second benefit is that the |
I'll have another look during next week! Thanks for both your comments! |
Prior to this enhancement compiling numpy would forcefully check BLAS/LAPACK
libraries in the following order:
BLAS:
- mkl
- blis
- openblas
- atlas
- accelerate
- NetLIB BLAS
- LAPACK
- mkl
- openblas
- atlas
- accelerate
- NetLIB LAPACK
This is problematic if a user want to build using, say, OpenBLAS but MKL is installed.
Even populating the site.cfg correspondingly one would get a successfull build, but
using MKL, if present.
The same applies to OpenBLAS vs. ATLAS etc.
Especially for developers this may be desirable to check performance with various
BLAS/LAPACK libraries.
This fixes the above issues by enabling users to forcefully set the order of loads
via environment variables:
$> export NUMPY_BLAS_ORDER=openblas,mkl,atlas
$> python setup.py config ...
would first try OpenBLAS (if existing), then MKL, and finally ATLAS.
In this case the build would fail if neither of OpenBLAS, MKL or ATLAS is present.
I.e. this can also be easierly used to test whether a linking would work. This
is because specifying a single library forces only one library check and has
no fall-back procedure (as requested by the user!).
The same applies to:
NUMPY_LAPACK_ORDER=openblas,mkl,atlas
This has meant that the blas_opt_info and lapack_opt_info classes in
system_info.py has *completely* changed.
Effectively there is only ONE change:
A fall-back of LAPACK was previously using get_info('blas') to get
the BLAS library to correctly link LAPACK. However, this may be undesirable
when the user has OpenBLAS/BLIS/ATLAS in a BLAS only installation but wants
to use the NetLIB LAPACK. Hence now lapack_opt_info uses get_info('blas_opt')
which does change the fall-back routine slightly. But perhaps for an easier build?
Signed-off-by: Nick Papior <[email protected]>
Also added a test to travis (apparently ATLAS=None... is not tested on circleCI). Signed-off-by: Nick Papior <[email protected]>
When a user requests NPY_BLAS/LAPACK_ORDER they can omit Netlib BLAS/LAPACK. In that case there will not be raised anything. This commit fixes this issue so that there will always be issues raised if the user hasn't requested the basic libraries. Signed-off-by: Nick Papior <[email protected]>
|
@rgommers regarding the Also do you prefer |
|
I see |
|
@charris oh yeah, there it was! 👍 I will fix the bug (in my code ;) )! |
Signed-off-by: Nick Papior <[email protected]>
I don't have strong feelings on that one either way. However, does it make sense for it to be a single value given that we already have |
|
Yes and no, if people want the control its main usage will probably be single value uses. Only in special cases can I see that users want to use it multi-value. You'll also note I have amended the build documentation a bit which I think clarifies its use. |
|
I think this is ready, I think it is fine to keep the names as is. :) |
rgommers
left a comment
There was a problem hiding this comment.
Still need to do some testing, but want to submit my comments already.
Signed-off-by: Nick Papior <[email protected]>
Signed-off-by: Nick Papior <[email protected]>
Signed-off-by: Nick Papior <[email protected]>
rgommers
left a comment
There was a problem hiding this comment.
I like the __doc__ or '' fix, nice and compact.
This all looks good. With distutils it's always hard to be really sure, but let's merge it and see how it does. Nice improvement overall.
Prior to this enhancement compiling numpy would forcefully check BLAS/LAPACK
libraries in the following order:
BLAS:
LAPACK:
This is problematic if a user want to build using, say, OpenBLAS but MKL is installed.
Even populating the site.cfg correspondingly one would get a successful build, but
using MKL, if present.
The same applies to OpenBLAS vs. ATLAS etc.
Especially for developers this may be desirable to check performance with various
BLAS/LAPACK libraries.
This fixes the above issues by enabling users to forcefully set the order of loads
via environment variables:
$> export NUMPY_BLAS_ORDER=openblas,mkl,atlas
$> python setup.py config ...
would first try OpenBLAS (if existing), then MKL, and finally ATLAS.
In this case the build would fail if neither of OpenBLAS, MKL or ATLAS is present.
I.e. this can also be easierly used to test whether a linking would work. This
is because specifying a single library forces only one library check and has
no fall-back procedure (as requested by the user!).
The same applies to:
NUMPY_LAPACK_ORDER=openblas,mkl,atlas
This has meant that the
blas_opt_infoandlapack_opt_infoclasses insystem_info.pyhas completely changed.Effectively there is only ONE change:
A fall-back of LAPACK was previously using
get_info('blas')to getthe BLAS library to correctly link LAPACK. However, this may be undesirable
when the user has OpenBLAS/BLIS/ATLAS in a BLAS only installation but wants
to use the NetLIB LAPACK. Hence now
lapack_opt_infousesget_info('blas_opt')which does change the fall-back routine slightly. But perhaps for an easier build?