There are
BLAS and LAPACK were originally written in FORTRAN 77. Since then, a number of additional language wrappers have been developed for languages like C, C++, FORTRAN 95, Java, Python, etc... Netlib offers exact implementations of the APIs and they are called "reference" libraries.
In addition, Gentoo provides a number of optimized implementations
of the above linear algebra libraries that will be described
below. You can switch between implementations with the
Gentoo's
It is important to note that if you require, e.g., a well performing BLAS implementation, simply emerging X over Y often is not enough. Rather, you will have to carefully benchmark your applications since performance may depend on many factors, such as hardware or network. If you are simply looking for a well performing and well tested implementation, the reference ebuilds will likely be your best choice.
If best possible performance is not of paramount importance for you and you simply need BLAS and/or LAPACK, just emerge the virtual package:
# emerge lapack
This will install both <><> and <><> the reference packages from
However, if:
... then read on, and be sure to file bugs both to Gentoo and upstream.
There is a number of optimized implementations of these libraries in the Portage tree:
Usually performance gain is noticeable mainly with BLAS, since LAPACK routines depend on BLAS kernels.
We took great care to make sure that each package provides consistent pkg-config files generated by us. Compiling and linking becomes straightforward:
# pkg-config --libs blas(To link with FORTRAN 77 BLAS library) # pkg-config --cflags cblas(To compile against C BLAS library) # pkg-config --libs cblas(To link with C BLAS library) # pkg-config --libs scalapack(To link with the ScaLAPACK library)
You can switch BLAS, CBLAS and LAPACK implementations with
# eselect cblas list Installed CBLAS for library directory lib64 [1] atlas [2] atlas-threads [3] gsl [4] mkl-threads * [5] reference
The implementation marked with an asterisk (*) is the currently selected implementation. To switch implementations, run:
# eselect blas set atlas-threads
To learn more about the
When selecting your linear algebra profiles try to avoid mixing different implementations since we don't have any mechanism to enforce reasonable profiles. However, here is a list of well performing profile combinations that have been used successfully in the past:
All the above libraries have been tested with the GNU compiler collections (gcc, gfortran). There are many available C compilers and a few FORTRAN (ifort, Open64) compilers on Gentoo and many other FORTRAN compilers outside of Gentoo ().
# F77=ifort FFLAGS="-O2 -mp1" emerge blas-reference
Depending on your hardware, a small performance gain can be noticed thanks to
vectorization. The
Some of the implementations let you specify the Intel® C compiler as well. Please beware that not all libraries compile with all combinations. You should receive an error during the emerge in case you have chosen an incompatible combination.
As usual for Gentoo, there are many combinations of USE flags and compilers with which you could compile a package. Unfortunately switching compilers between BLAS and LAPACK might not be always compatible. For example:
# USE=ifort emerge acml # eselect blas set acml-ifort-openmp # FC=gfortran FFLAGS="-O2" emerge lapack-reference
This will most likely break things or not even compile.
Try to be consistent in your choice. Stay with the GCC most of the time will avoid you some trouble, unless you want to use the MKL, in which case the Intel compilers make a good combination.
If you need BLAS or LAPACK to develop your own programs, the documentation
becomes pretty handy. Setting the USE="doc" flag for the corresponding BLAS or
LAPACK package will install man pages and quick reference sheets from the
You need two things:
set [R]DEPEND to
econf --with-blas="$(pkg-config --libs blas)"
The Portage tree contains many ebuilds that depend on the
BLAS/CBLAS/LAPACK/BLACS/ScaLAPACK libraries. As there is more than
one possible implementation, the Gentoo Science Project
reorganized all the packages to provide
To work with Gentoo's configuration tools
The easiest way of understanding all this is probably getting inspiration from one of the available packages. Currently the Portage tree provide the following virtual packages:
Package name | virtual/blas | virtual/cblas | virtual/lapack | virtual/lapacke | virtual/blacs | virtual/scalapack |
---|---|---|---|---|---|---|
If you feel inclined to write an ebuild for these, you
are more than welcomed to file it on our