Handle different versions of BLAS and LAPACK
Description
Beside being implementations, BLAS and LAPACK are also API standard for basic linear algebra operations (such as vector and matrix multiplication).
Many implementations of these API exist. The reference implementation of BLAS and LAPACK is very stable but is not as fast as optimized ones such as ATLAS and OpenBLAS.
Implementations of BLAS:
blas - BLAS or BLAS-reference
atlas - Automatically Tuned Linear Algebra Software
openblas - OpenBLAS, an optimized BLAS based on GotoBLAS2
gsl - GNU Scientific Library
eigen2 - Eigen
- Intel MKL - Non-free
- AMD ACML - Non-free
- Sun Performance Library - Non-free
- ...
Implementations of LAPACK:
lapack - Reference LAPACK
- LAPACK++
- ATLAS provides an optimized subset of LAPACK + code from
How to switch from an implementation to the other
It is just trivial. It can be used like any other software using update-alternatives.
BLAS
update-alternatives --config libblas.so.3
Example:
There are 3 choices for the alternative libblas.so.3 (providing /usr/lib/libblas.so.3). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/openblas-base/libopenblas.so.0 40 auto mode 1 /usr/lib/atlas-base/atlas/libblas.so.3 35 manual mode 2 /usr/lib/libblas/libblas.so.3 10 manual mode 3 /usr/lib/openblas-base/libopenblas.so.0 40 manual mode
LAPACK
update-alternatives --config liblapack.so.3
Example:
There are 2 choices for the alternative liblapack.so.3 (providing /usr/lib/liblapack.so.3). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/lapack/liblapack.so.3 10 auto mode 1 /usr/lib/atlas-base/atlas/liblapack.so.3 5 manual mode 2 /usr/lib/lapack/liblapack.so.3 10 manual mode
Note that even though the LAPACK implementation of ATLAS is more powerful than Netlib's reference LAPACK, it is given a lower priority (as a workaround for 624318 and its clones). The optimized LAPACK can still be manually chosen.
Getting the best performance out of ATLAS and OpenBLAS
The binary packages of ATLAS and OpenBLAS distributed by Debian are generic packages, which are not optimized for your specific machine.
The optimal way of using these two packages is to recompile them locally on the machines on which they are to be used. See the README.Debian file of the respective packages for details on how to achieve that easily.
TODO
- Doing like gentoo: providing .pc files ?
- Check for other implementations (CUBLAS, MKL in non-free, ACML in non-free)
