Skip to content

Possible race condition problem when using eigen with @threads in windows? #30460

Closed
@atbug

Description

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    multithreadingBase.Threads and related functionalitysystem:windowsAffects only WindowsupstreamThe issue is with an upstream dependency, e.g. LLVM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions