How can I use the BLAS implementations included in Apple Accelerate Framework with MATLAB R2023b Update 4?
302 views (last 30 days)
Show older comments
MathWorks Support Team
on 8 Nov 2023
Commented: Mike Croucher
on 13 Dec 2023
How can I use the BLAS implementations included in Apple Accelerate Framework with MATLAB R2023b Update 4?
Accepted Answer
MathWorks Support Team
on 1 Dec 2023
Edited: MathWorks Support Team
on 1 Dec 2023
The BLAS implementation currently used by default in MATLAB on Apple Silicon processors is OpenBLAS. MATLAB is only qualified using the OpenBLAS version that is included with MATLAB.
After working closely with Apple, MacOS 13.3 brought ILP64 compatible BLAS APIs to Apple Accelerate Framework's BLAS.
If you are using an Apple Silicon processor and run on MacOS 13.3 or newer, you may prefer to use the BLAS implementation which is included with MacOS's Apple Accelerate Framework. Starting with MATLAB R2023b Update 4, this library has completed preliminary qualificiation for use with MATLAB and can be selected following the below instructions.
In order to use Apple Accelerate Framework's BLAS (AF_BLAS) with MATLAB, open a command prompt and define the environment variable BLAS_VERSION by running the following command:
$ export BLAS_VERSION=libmwAF_BLAS_ilp64.dylib
Notice that depending on the used MacOS shell, the command to define ENVs might differ.
Once the ENV has been set, start MATLAB from within the same command prompt to use AF_BLAS:
> matlab
To revert the BLAS library MATLAB uses to the default library, close MATLAB and clear the environment variable:
$ unset BLAS_VERSION
To verify that MATLAB is using the desired BLAS library, type the following at the MATLAB prompt:
>> version -blas
In MATLAB R2023b Update 4 this should return:
BLAS: trying environment BLAS_VERSION...
BLAS: loading libmwAF_BLAS_ilp64.dylib
BLAS: loaded libmwAF_BLAS_ilp64.dylib@0xa0a3a390
ans =
'Apple Accelerate BLAS (ILP64)'
The procedure explained above is only active within the used command window. In order to always start MATLAB using AF_BLAS, permanently set these environment variables by adding the ENV BLAS_VERSION with the value described above to your ~/.bashrc.mine, ~/.profile, or similar.
1 Comment
Mike Croucher
on 13 Dec 2023
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!