JuliaLinearAlgebra / Arpack.jl

Julia Wrappers for the arpack-ng Fortran library
https://arpack.julialinearalgebra.org/stable
MIT License
69 stars 29 forks source link

Segmentation fault when using Arpack and Threads.@threads #86

Closed CodeLenz closed 4 years ago

CodeLenz commented 4 years ago

Hi.

The following example

 function test_call_parpack(NP,NM)

    # Parallel calls to Arpack
    Threads.@threads for k=1:NP

        # Generate random matrix
        A = sprand(NM,NM,0.2)

        # Call Arpack
        eigs(A)

    end

end

results in

julia> test_call_parpack(1000,1000)
Segmentation fault (core dumped)

If I run the sequence 
# Generate random matrix
    A = sprand(NM,NM,0.2)

    # Call Arpack
    eigs(A)

by hand many times, everything works fine. I suspect there must be some constraint on using external libraries in parallel, but all the variables are local to the loop and Julia just have to call multiple instances of it. Is it expected?

Julia 1.3 here Thanks for your assistance.

andreasnoack commented 4 years ago

See https://stackoverflow.com/a/6972455. Arpack might not be threadsafe. Consider using a native Julia implementation such as e.g. https://github.com/haampie/ArnoldiMethod.jl

CodeLenz commented 4 years ago

Thanks!