Help with eigenvalue decomposition for symmetric matrices

Dear all,

For some reason Julia’s eigenvalue factorization for symmetric matrices is considerable slow in my machine (MacBook Air, 1.8 GHz Intel Core i5, 4 GB 1600 MHz DDR3). In this same machine, Scipy’s eigenvalue factorization is usually 2x faster. Even using PyCall.jl is faster than the Julia’s version. I don’t recall using any kind of special configuration when installing scipy. The Python version used in the experiment was Anaconda’s Python2.7. There is probably something to do with the OpenBLAS version Julia (Version 0.6.2) is using. I would really appreciate some help on how to proceed.

In the following, there is an example code and timing results.

using BenchmarkTools
using PyCall

mat = randn(1000,1000)
mat = mat+mat’;

@pyimport scipy.linalg as sp

@benchmark sp.eig(mat)

BenchmarkTools.Trial:
memory estimate: 7.65 MiB
allocs estimate: 194
--------------
minimum time: 2.053 s (0.07% GC)
median time: 2.199 s (0.00% GC)
mean time: 2.152 s (0.02% GC)
maximum time: 2.205 s (0.00% GC)
--------------
samples: 3
evals/sample: 1

@benchmark sp.eigh(mat)

BenchmarkTools.Trial:
memory estimate: 7.64 MiB
allocs estimate: 194
--------------
minimum time: 458.228 ms (0.00% GC)
median time: 472.750 ms (0.00% GC)
mean time: 476.947 ms (1.66% GC)
maximum time: 538.251 ms (13.59% GC)
--------------
samples: 11
evals/sample: 1

@benchmark eig(mat)

BenchmarkTools.Trial:
memory estimate: 23.25 MiB
allocs estimate: 24
--------------
minimum time: 793.129 ms (0.40% GC)
median time: 800.991 ms (0.40% GC)
mean time: 835.071 ms (1.97% GC)
maximum time: 923.439 ms (8.29% GC)
--------------
samples: 6
evals/sample: 1

mat = Symmetric(mat);

@benchmark eig(mat)

BenchmarkTools.Trial:
memory estimate: 23.25 MiB
allocs estimate: 22
--------------
minimum time: 774.001 ms (0.07% GC)
median time: 786.044 ms (0.41% GC)
mean time: 819.341 ms (1.88% GC)
maximum time: 898.768 ms (8.87% GC)
--------------
samples: 7
1 Like

Maybe it’s the difference between linking to OpenBLAS and linking to MKL? I think JuliaPro has a version linked against MKL that you can try (gratis): https://juliacomputing.com/products/juliapro.html

6 Likes

The MKL version seems way faster for my problems. Thanks for the advice.