JuliaSmoothOptimizers / MUMPS.jl

A Julia Interface to MUMPS
Other
43 stars 15 forks source link

Missing finalize in solve function leading to MPI error #124

Closed guiburon closed 9 months ago

guiburon commented 9 months ago

Hello,

Running this code,

using MPI
using MUMPS
using LinearAlgebra
using SparseArrays

n = 1_000
A = sprand(n, n, 0.1) + I
b = rand(eltype(A), n)

MPI.Init()

x = solve(A, b)

MPI.Finalize()

leads to this MPI error after completion:

mpiexec detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[26313,1],3]
  Exit code:    1

Tested on Linux with Julia 1.9 & 1.10, with local OpenMPI, OpenMPI_jll and MPICH_jll.

The similar example in the documentation does not lead to this error because the matrix A is reused after the solve, leading to proper garbage collection I guess?

using MUMPS, MPI, SparseArrays
using LinearAlgebra   # missing in the doc for norm()
MPI.Init()
A = sprand(10, 10, 0.2) + I
rhs = rand(10)
x = solve(A, rhs)
norm(x - A \ rhs) / norm(x)
MPI.Finalize()

I link a pull request fixing this issue. No performance delta seen for n = 10_000 on 4 proc.

Thanks for this great package!