MKL threading bug?

Before posting this as a github issue, I wanted to confirm that this is not some problem with my computer.

The following happens for me, but only on mac (macOs Mojave 10.14.6, MacBook Pro (15-inch, 2016), 2,9 GHz Intel Core i7) with julia 1.6.1, only with MKL (installed using MKL.jl v0.4.1) and with the default setting of multithreaded MKL (i.e. it disappears with LinearAlgebra.BLAS.set_num_threads(1)).

Consider the following code


using LinearAlgebra
using Random
Random.seed!(111134)

B = randn(Float64, (144, 144))
eigvals(B)

D = 4
T = Float64

Q = randn(T, (D,D))
x = one(Q)
y = similar(x)

Threads.@threads for k = 0:0
	mul!(y, Q', x)
end

The result in y is correctly computed. However, now running

eigvals(B)

again, this call either hangs or produces completely inconsistent and incorrect results. Removing the @threads call surrounding mul!, this problem disappears.

Is there anyone that can reproduce this on a similar configuration (definitely no linux, no OpenBLAS, these all work fine)

Is there some known conflict between Julia threading (note that Threads.nthreads() == 1, so it should be off) and MKL threading on Mac?

Funny, I can replicate in a recent julia 1.7 nightly + MKL, but not on julia 1.6.1. Both under macOS 11.4

I think you should open an issue.

Thanks. Are you sure MKL was installed on 1.6.1. MKL.jl 0.4.0 pretended to install, but did not actually do anything on Julia 1.6.1 (as you could check with BLAS.vendor()). This was only fixed with MKL.jl 0.4.1 yesterday.

Oh, you’re completely right! Rebuilding latest MKL master in julia 1.6.1 also makes your example hang for me

Thanks for confirming; I’ve opened an issue.

In case you want to follow along:
https://github.com/JuliaLang/julia/issues/41077

1 Like