LinearAlgebra.inv matrix inversion slower than MATLAB?

The MKL.jl experience is particularly nice on Julia >= 1.7 where it is based on libblastrampoline (and MKL_jll.jl). In this case, you can simply compare the performance of inv from OpenBLAS and MKL:

julia> using LinearAlgebra

julia> using BenchmarkTools

julia> A = rand(4000,4000);

julia> BLAS.get_config()
LinearAlgebra.BLAS.LBTConfig
Libraries:
└ [ILP64] libopenblas64_.0.3.13.dylib

julia> @btime inv($A);
  1.444 s (6 allocations: 124.05 MiB)

julia> using MKL

julia> BLAS.get_config()
LinearAlgebra.BLAS.LBTConfig
Libraries:
└ [ILP64] libmkl_rt.1.dylib

julia> @btime inv($A);
  846.798 ms (6 allocations: 139.68 MiB)
5 Likes