I’m new to autoconf as well as linear algebra libraries. So far as I can tell, LAPACK, ATLAS, OpenBLAS, and KML can co-exist on the filesystem but you can only use one of the libraries at link-time and I would like to let ./configure choose whatever is available or let the user select it with ./configure –something.
Different distributions put things in different directories and it would be nice if autoconf can figure that out.
- LAPACK is -llapack
- ATLAS is -lsatlas -L /usr/lib64/atlas # CentOS
- or -ltatlas for the threaded version
- OpenBLAS is -lopenblas
- or -lopenblasp for the pthread version
- or -lopenblaso for the OpenMP version
Questions:
- Is there already a "proper" way to do this with AC_ macros?
- Do AC_ macros already exist for these libraries?
- How would you setup configure.ac to find the first available library that is installed but default to threaded ATLAS if available?
- How would you setup configure.ac to allow the user to select, for example, the OpenMP version of OpenBLAS?
- Would you use an option like –with-openblas-openmp ?
- What would the configure.ac code look like?
Thank you for your help!
2
Answers
The PSFEX package does this, see https://github.com/astromatic/psfex/blob/master/configure.ac#L285 :
Also note that you will need their macro libraries (available here) which are too big to paste into the answer:
You could use
dlopen()
to dynamically load the library functions that you need. Then you needn’t worry about configure.ac settings since your application would auto-detect the available libraries at runtime.The xnec2c antenna simulator does this using their mathlib.c and mathlib.h implementations for the
zgetrf()
andzgetrs()
calls. It could be extended to support other linear algebra calls as well. Maybe someone will write a unified linear algebra meta-library to dynamically back all the various implementations in one front-end library! (If you do, be sure to tell the xnec2c maintainer so they might use your changes.)The mathlib.c file contains a typedef struct
mathlib_t
that defines the library names, shared object path, and function prefix for each library. It supports shared object library names for autodetecting Ubuntu/Debian, CentOS/RHEL, and openSUSE at runtime; other distributions more-or-less use the same library names, so, effectively, far more than just the above listed distributions are supported:Note that ATLAS and OpenBLAS use different function prefixes:
clapack_
vsLAPACKE_
; so having a wrapper around the different libraries is useful. Xnec2c supports ATLAS, OpenBLAS+LAPACK, and Intel MKL.