mpimd-csc / flexiblas

FlexiBLAS - A BLAS and LAPACK wrapper library with runtime exchangeable backends. This is only a mirror of https://gitlab.mpi-magdeburg.mpg.de/software/flexiblas-release
https://www.mpi-magdeburg.mpg.de/projects/flexiblas
GNU Lesser General Public License v3.0
36 stars 7 forks source link

Compile all backends without auto-detection #13

Closed epsilon-0 closed 3 years ago

epsilon-0 commented 3 years ago

How would I compile flexiblas with support for all ATLAS, OpenBLAS, MKL and BLIS while not having them present at compile time?

Thanks a lot!!

grisuthedragon commented 3 years ago

The fun fact is, that there is no need to have them at compile time. Just create a file myblas.conf in /etc/flexiblasrc.d (or wherever your system-wide flexiblasrc lies) with the following content:

[NAMEOFTHEBLASLIBRARY]
library = /path/to/the/so/file/containing/the/blas/inferface.so

and check with flexiblas list if they are now available.

The so-file have to contain the a normal NETLIB compatible BLAS interface and must include all its dependencies. If a BLAS symbols does not exists in the so-file it is automatically replaced by its NETLIB implementation.

For ATLAS that means you need the combined so as installed by Debian/Ubuntu as /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3. So the file will look like

[ATLAS]
library = /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3

For OpenBLAS, just use the generated so file.

For BLIS, just use the generated so file, but it have to be compiled with the BLAS wrapper layer. (config option: --enable-blas).

In case of the MKL its a bit tricky, since it consits of at least three so files that have to be combined such that they fit your requirements. Therefore, Intel provides a tool called mklbuilder. In my installation it is located in ${MKLROOT}/tools/build. This is a makefile which can be used to generate a custom single so file variant of the MKL. For example with

make libintel64 export=blas_example_list interface=lp64 parallel=gnu threading=sequential name=flexiblas_mkl_sequential

One can generate such an so-file which includes the sequential version of the MKL as a single so file. This can be used in the config files. (The parallel=gnu is required to tell the makefile to use the GNU Fotran interface instead of the Intel Fortran interface)

For fast tests is is enought to set the the FLEXIBLAS environment variable to the absolute path of a so file which contains the desired BLAS.

As long as the names in the configfiles are unique, many different BLAS libraries of the same vendor could be defined. I use this to switch between OpenBLAS in sequential and OpenMP mode while developing software.

Does this help? I think I write a short readme in the next release abou this.

epsilon-0 commented 3 years ago

Does this help?

Yes, this was very informative! Thanks a lot!

I think I write a short readme in the next release abou this.

I'd really appreciate this as well, thanks! :heart:

grisuthedragon commented 3 years ago

Then I close this issue and some information on this will appear in the next release.