Possible race condition problem when using eigen with @threads in windows? #30460
Closed
Description
opened on Dec 20, 2018
using LinearAlgebra
function test(H)
E = zeros(N, Threads.nthreads())
Threads.@threads for ik = 1:484
E[:, Threads.threadid()] += eigen(H).values
end
Esum=zeros(N)
for i=1:Threads.nthreads()
Esum += E[:,i]
end
return Esum
end
N = 4
H = rand(N, N)+im*rand(N, N)
H = H+H'
reference = test(H)
for i in 1:20
if maximum(abs.(test(H)-reference))>1.0e-7
println("race?")
end
end
Expected no output. However, with N=2
we get a small chance(~10%) to get the "race?" message. With N=4 almost every execution of test()
returns different values.
Note that the problem only occurs on Windows. On linux no output would show up. Here's the test environment:
julia> versioninfo()
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4
Activity