arrayfire / arrayfire/arrayfire

More robust CBLAS / LAPACKE detection

Open
#1,579 12 comments 1 reaction 0 assignees View on GitHub
build
Dominant language
C++
Stars
4.9k
Forks
555
Avg merge
1h 24m
Merged PRs (30d)
1

Description

As discussed privately with @pavanky, detection of CBLAS and LAPACKE could get some love. I tried a few things but getting something generic enough proved to be quite tricky. I am opening this issue as a thread to explore the use cases and possible scenarii that the detection should cover.

CMake already has detection for the `BLAS` and `LAPACK` but lacks CBLAS / LAPACKE. The following blog [post](http://nicolas.limare.net/pro/notes/2014/10/31_cblas_clapack_lapacke/) provides some background as to how they all relate to each other. In a nutshell, one should absolutely use the `CBLAS` wrapper specific to the desired BLAS vendor, but this restriction is relaxed for `LAPACKE` (which not all vendor provides btw).

Another thing to consider is the way distributions handle multiple vendors of `BLAS` / `LAPACK`. Debian uses a set of symlinks to switch between different `BLAS` vendors at runtime and uses netlib's LAPACKE regardless, whilst other distros have separated or mutually exclusive install paths for each vendor. Finally, some vendors (`mkl`, `openblas`) can bundle everything (`BLAS` / `CBLAS`, `LAPACK`/`LAPACKE`) in a single binary as opposed to separate ones for `BLAS` and `LAPACK`.

I can see 3 use-cases possible:
1. Detection of a custom installation of BLAS (all patforms).
2. Detection of a system-installed version via `pkg-config` (like `arch-linux` provides).
3. Detection of a system-installed version without `pkg-config` (symlinks ala `Debian`).

For (1), we can roll our own (bad), or use find_package(`BLAS`) and find_package(`LAPACK`) with the `BLA_VENDOR` parameter and existing support for lookup in `LIB` (Windows), `DYLD_LIBRARY_PATH` (Apple) and `LD_LIBRARY_PATH` (Linux). Then, we can look for the location of the vendor specific headers based on the path to the libraries and the value of `BLA_VENDOR`.
For (2), just use the `pkg-config` results directly (like we currently do).
For (3), use find_package(`BLAS`) and find_package(`LAPACK`) and look for the path to `cblas.h` and `lapacke.h` as in (1).

Thoughts?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.