MUMPS.jl icon indicating copy to clipboard operation
MUMPS.jl copied to clipboard

Since julia-1.10 / OpenBLAS32-0.3.22 the number of threads must be explicitly specified

Open fp4code opened this issue 7 months ago • 6 comments

Since julia-1.10 a simple program like this one is very slow because only one CPU is used

# On a 32-core computer, uncomment next line to have 3200% CPU workload if julia version is > 1.9
# ENV["OPENBLAS_NUM_THREADS"]="32"

using Random, MUMPS, MPI, SparseArrays, LinearAlgebra
N = 10000
Nc = 1
Random.seed!(3)
A = sprand(N, N, 0.1) + I
rhs = rand(N, Nc)
x = Matrix{Float64}(undef, N, Nc)
MPI.Init()
mumps = Mumps{Float64}(mumps_unsymmetric, default_icntl, default_cntl64)
associate_matrix!(mumps, A)
t = @elapsed factorize!(mumps)
associate_rhs!(mumps, rhs)
solve!(mumps)
MUMPS.get_sol!(x, mumps)
finalize(mumps)
MPI.Finalize()
println("maximum error = ", maximum(abs.(A*x - rhs)), ", factorise time (s) = ", t)

No such problem with pinning OpenBLAS32_jll to 0.3.21: Pkg.add(name="OpenBLAS32_jll", version="0.3.21")

One solution is to set the environment variable for the desired number of threads: export OPENBLAS_NUM_THREADS=32

This can be done inside Julia: ENV["OPENBLAS_NUM_THREADS"]="32"

fp4code avatar Nov 15 '23 15:11 fp4code