Julia versus MATLAB

I am trying Julia 1.7.2 on an M1 MacBook Air for bench marking Eigen against MATLAB 2022a

a=randn(100,100)
tic, for x=1:100; eig(a); end; toc
Elapsed time is 0.295766 seconds.

whereas Julia v1.7.2

a=randn(Float64, (100,100))
 @time begin
       for x in 1:100
       eigen(a);
       end
       end
  1.691869 seconds (2.10 k allocations: 41.257 MiB, 1.18% gc time)

Both are in x86 mode, I believe. Is there any reason why Julia should be so slow?
Kumar

How many threads is BLAS using? These are both just calling out to BLAS, so with some parameter tuning, they should be identical.

BLAS is using 8 threads. I changed it to 16 with no change. In fact, I changed it to 1 thread and the executed time was the same.

In my computer MKL's eigen is 4x as fast as the default, so maybe this is related (I think MATLAB uses MKL by default).

using BLAS:

julia> @time begin
              for x in 1:100
              eigen(a);
              end
              end
  1.968685 seconds (2.10 k allocations: 41.257 MiB, 5.29% gc time)

with MKL:

julia> @time begin
              for x in 1:100
              eigen(a);
              end
              end
  0.519582 seconds (2.10 k allocations: 60.788 MiB, 0.39% gc time)

(second execution in both cases, to discount compilation)

1 Like

I don’t expect the MacBook Air to benefit from MKL. The processor is ARM-based. But x86 has an emulation mode.
/K

See this comment from an earlier discussion:

9 Likes