Compiler option matmul speedup

With gfortran you can use the -fexternal-blas compiler flag, which inserts calls to BLAS in place of the intrinsic matmul function above a certain matrix size. In addition you have to link an optimized BLAS library:

Library Link flags Comment
OpenBLAS -lopenblas
BLIS -lblis
Intel oneMKL see Link Line Advisor for OneMKL for Intel processors
Accelerate -framework Accelerate for macOS
AOCL-BLAS -lblis for AMD processors; derived from BLIS
Arm Performance Libraries -larmpl_lp64 for Arm processors
MATLAB BLAS -lmwblas for MATLAB MEX functions
4 Likes