-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
As reported here, I came across the following issue when using MKL on Mac (my specific configuration is macOs Mojave 10.14.6, MacBook Pro (15-inch, 2016), 2,9 GHz Intel Core i7 with julia 1.6.1 and MKL.jl 0.4.1):
using LinearAlgebra
using Random
Random.seed!(111134)
B = randn(Float64, (144, 144))
eigvals(B) # computing the eigenvalues, everything is fine
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)
endThe result for y is computed correctly, however, after these final statements, MKL seems to be in some broken state, where following BLAS or LAPACK based calls either produce inconsistent results, or just hang. For example, eigvals(B) hangs for me, but in other cases, it just spitted out incorrect results, which differ between several sequential eigvals(B) calls. I came to this example by reducing a very complex codebase that started giving very inconsistent results.
This is without using multithreaded julia, so no environment variables or startup flags, i.e. Base.nthreads() == 1. BLAS / MKL uses the default setting, on my system using 4 threads.
The problem does not occur if
- using Linux or Windows
- using OpenBLAS
- using single-threaded BLAS, i.e. calling
BLAS.set_num_threads(1)