The BLAS and LAPACK implementation used by default in MATLAB on x86_64 processors is part of the Intel Math Kernel Library, or Intel MKL. MATLAB is only qualified using the version of Intel MKL that is included with MATLAB.
If you are using an AMD processor, you may prefer to use the BLAS and LAPACK implementation which is included in AMD Optimizing CPU Libraries, or AOCL. These libraries are optimized for use on AMD's Zen architecture processors. Starting with MATLAB R2022a, these libraries have completed preliminary qualificiation for use with MATLAB and are shipping alongside MKL on Windows and Linux.
AOCL provides its BLAS implementation as AOCL_LibBlis and its LAPACK implementation as AOCL_LibFLAME, respectively.
Setting MATLAB to use AOCL
In order to use AOCL libraries with MATLAB, open a command prompt and define the environment variables BLAS_VERSION and LAPACK_VERSION by running the following commands:
> set BLAS_VERSION=AOCL-LibBlis-Win-MT-dll.dll
> set LAPACK_VERSION=AOCL-LibFLAME-Win-MT-dll.dll
$ export BLAS_VERSION=libblis-mt.so
$ export LAPACK_VERSION=libflame.so
Notice that depending on the used Linux shell, the command to define ENVs might differ.
Once the ENVs have been set, start MATLAB from within the same command prompt to use the AOCL libraries:
To revert the BLAS and LAPACK libraries MATLAB uses to the default Intel libraries, close MATLAB and clear the environment variables:
> set BLAS_VERSION=
> set LAPACK_VERSION=
$ unset BLAS_VERSION
$ unset LAPACK_VERSION
Verifying the Installation
To verify that MATLAB is using the desired BLAS and/or LAPACK library, type the following at the MATLAB prompt:
>> version -blas, version -lapack
In MATLAB R2022a this should return:
'AOCL BLIS 3.1.0'
'AOCL libFLAME 3.1.1, supports LAPACK 3.10.0'
Switch to use AOCL permanently
The procedure explained above is only active within the used command window. In order to always start MATLAB using AOCL, permanently set these environment variables.
- Click Win-Key
- Click on Settings Symbol
- Search for Edit environment variables for your account.
- Click on New...
- Insert name and value as described above for BLAS_VERSION and LAPACK_VERSION.
Add the ENVs BLAS_VERSION and LAPACK_VERSION with the values described above to your ~/.bashrc.mine, ~/.profile, or similar.