Hello everyone,
I’m fairly new to Julia. I am working on implementing SBFEM in Julia. SBFEM requires solving a lot of eigenvalue problems. I noticed that my code in Matlab is running much (much) faster than in Julia. I tried to apply the tips in the performance section.
Analyzing the profiler, I found that most time is spend on the eigenvalue problem (and also on LU decomposition for solving systems of equations). This is expected, however Julia runs much slower than Matlab.
To better understand this discrepancy between Julia and Matlab I timed the eigenproblem solver for several different matrix sizes.
Julia Code
using TimerOutputs
using LinearAlgebra
function timer_eigen(n::T,matrix_size::UnitRange{T}) where {T<:Integer}
# BLAS.set_num_threads(1)
timer = TimerOutput()
for m in matrix_size
Z = rand(Complex{Float64}, m, m)
for i in 1:n
𝚲, 𝚿 = @timeit timer "Size $m" eigen(-Z)
end
end
return timer
end
timer_eigen(1000,2:102)
Matlab Code
function timer = timer_eigen(n, matrix_size)
m = numel(matrix_size);
timer = zeros(m, 3);
for j = 1:m
s = matrix_size(j);
Z = rand(s) + 1i * rand(s);
timer(j,1) = s;
for i = 1:n
tic;
[V, L] = eig(-Z);
timer(j,2) = timer(j,2) + toc;
end
timer(j,3) = timer(j,2) / n;
end
end
What you can see is that (at least for me) Julia takes about twice as long to solve eigenproblems than Matlab.
I have read that OpenBLAS is usually slower than MKL, however, this much of a slowdown is rather disappointing and I believe detrimental to Julia.
Can anyone reproduce this discrepancy? Could this more likely be a problem with my machine rather than OpenBLAS?
EDIT: For completeness sake…
Julia Version 1.1.1
Commit 55e36cc308 (2019-05-16 04:10 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Matlab 2018b (with 6 threads).