FindBLAS — CMake 4.4.3-dirty Documentation

# FindBLAS

Finds the installed Basic Linear Algebra Subprograms (BLAS) Fortran library, which implements the BLAS linear-algebra interface:

    find_package(BLAS [...])

At least one of the `C`, `CXX`, or `Fortran` languages must be enabled.

## Imported Targets

This module provides the following Imported Targets:

`BLAS::BLAS`

  Added in version 3.18.

  Target encapsulating the libraries and usage requirements to use BLAS, available only if BLAS is found.

## Result Variables

This module defines the following variables:

`BLAS_FOUND`

  Boolean indicating whether the library implementing the BLAS interface was found.

`BLAS_LINKER_FLAGS`

  Uncached list of required linker flags (excluding `-l` and `-L`).

`BLAS_LIBRARIES`

  Uncached list of libraries (using full path name) to link against to use BLAS (may be empty if compiler implicitly links BLAS).

`BLAS95_LIBRARIES`

  Uncached list of libraries (using full path name) to link against to use BLAS95 interface.

`BLAS95_FOUND`

  Boolean indicating whether the library implementing the BLAS95 interface was found.

## Input Variables

The following variables may be set to influence this module's behavior:

`BLA_STATIC`

  If `ON`, the static linkage will be used.

`BLA_VENDOR`

  Set to one of the BLAS/LAPACK Vendors to search for BLAS only from the specified vendor. If not set, all vendors are considered.

`BLA_F95`

  If `ON`, the module tries to find the BLAS95 interfaces.

`BLA_PREFER_PKGCONFIG`

  Added in version 3.11.

  If set, `pkg-config` will be used to search for a BLAS library first and if one is found that is preferred

`BLA_PKGCONFIG_BLAS`

  Added in version 3.25.

  If set, the `pkg-config` method will look for this module name instead of just `blas`.

`BLA_SIZEOF_INTEGER`

  Added in version 3.22.

  Specify the BLAS/LAPACK library integer size:

  `4`

    Search for a BLAS/LAPACK with 32-bit integer interfaces.

  `8`

    Search for a BLAS/LAPACK with 64-bit integer interfaces.

  `ANY`

    Search for any BLAS/LAPACK. Most likely, a BLAS/LAPACK with 32-bit integer interfaces will be found.

`BLA_THREAD`

  Added in version 4.1.

  Specify the BLAS/LAPACK threading model:

  `SEQ`

    Sequential model

  `OMP`

    OpenMP model

  `ANY`

    Search for any BLAS/LAPACK, if both are available most likely `OMP` will be found.

  This is currently only supported by NVIDIA NVPL.

## BLAS/LAPACK Vendors

`Generic`

  Generic reference implementation.

`ACML`, `ACML_MP`, `ACML_GPU`

  AMD Core Math Library

`AOCL`, `AOCL_mt`

  Added in version 3.27.

  AMD Optimizing CPU Libraries.

`Apple`, `NAS`

  Apple BLAS (Accelerate), and Apple NAS (vecLib).

`Arm`, `Arm_mp`, `Arm_ilp64`, `Arm_ilp64_mp`

  Added in version 3.18.

  Arm Performance Libraries.

`ATLAS`

  Automatically Tuned Linear Algebra Software.

`CXML`, `DXML`

  Compaq/Digital Extended Math Library.

`EML`, `EML_mt`

  Added in version 3.20.

  Elbrus Math Library.

`FLAME`

  Added in version 3.11.

  BLIS Framework.

`FlexiBLAS`

  Added in version 3.19.

`Fujitsu_SSL2`, `Fujitsu_SSL2BLAMP`, `Fujitsu_SSL2SVE`, `Fujitsu_SSL2BLAMPSVE`

  Added in version 3.20.

  Fujitsu SSL2 serial and parallel blas/lapack with SVE instructions.

`Goto`

  GotoBLAS.

`IBMESSL`, `IBMESSL_SMP`

> IBM Engineering and Scientific Subroutine Library.

`Intel`

  Intel MKL 32 bit and 64 bit obsolete versions.

`Intel10_32`

  Intel MKL v10 32 bit, threaded code.

`Intel10_64lp`

  Intel MKL v10+ 64 bit, threaded code, lp64 model.

`Intel10_64lp_seq`

  Intel MKL v10+ 64 bit, sequential code, lp64 model.

`Intel10_64ilp`

  Added in version 3.13.

  Intel MKL v10+ 64 bit, threaded code, ilp64 model.

`Intel10_64ilp_seq`

  Added in version 3.13.

  Intel MKL v10+ 64 bit, sequential code, ilp64 model.

`Intel10_64_dyn`

  Added in version 3.17.

  Intel MKL v10+ 64 bit, single dynamic library.

`libblastrampoline`

  Added in version 3.30.

  A BLAS/LAPACK demuxing library using PLT trampolines.

`NVPL`

  Added in version 4.1.

  NVIDIA Performance Libraries.

`NVHPC`

  Added in version 3.21.

  NVIDIA HPC SDK.

`OpenBLAS`

  Added in version 3.6.

`PhiPACK`

  Portable High Performance ANSI C (PHiPAC).

`SCSL`, `SCSL_mp`

  Scientific Computing Software Library.

`SGIMATH`

  SGI Scientific Mathematical Library.

`SunPerf`

  Sun Performance Library.

## Intel MKL

To use the Intel MKL implementation of BLAS, a project must enable at least one of the `C` or `CXX` languages. Set `BLA_VENDOR` to an Intel MKL variant either on the command-line as `-DBLA_VENDOR=Intel10_64lp` or in project code:

    set(BLA_VENDOR Intel10_64lp)
    find_package(BLAS)

In order to build a project using Intel MKL, and end user must first establish an Intel MKL environment:

Intel oneAPI

  Source the full Intel environment script:

      . /opt/intel/oneapi/setvars.sh

  Or, source the MKL component environment script:

      . /opt/intel/oneapi/mkl/latest/env/vars.sh

Intel Classic

  Source the full Intel environment script:

      . /opt/intel/bin/compilervars.sh intel64

  Or, source the MKL component environment script:

      . /opt/intel/mkl/bin/mklvars.sh intel64

The above environment scripts set the `MKLROOT` environment variable to the top of the MKL installation. They also add the location of the runtime libraries to the dynamic library loader environment variable for your platform (e.g. `LD_LIBRARY_PATH`). This is necessary for programs linked against MKL to run.

Note

As of Intel oneAPI 2021.2, loading only the MKL component does not make all of its dependencies available. In particular, the `iomp5` library must be available separately, or provided by also loading the compiler component environment:

    . /opt/intel/oneapi/compiler/latest/env/vars.sh

## Examples

Finding BLAS and linking it to a project target:

    find_package(BLAS)
    target_link_libraries(example PRIVATE BLAS::BLAS)