Skip to content

Commit ffe674a

Browse files
Sébastien LoiselSébastien Loisel
authored andcommitted
Fix precompilation under mpiexec
Wrap MPI.Init() in try-catch so precompilation workload skips gracefully when run under mpiexec (where subprocess is not part of the MPI job).
1 parent ee6f56f commit ffe674a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/LinearAlgebraMPI.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,15 @@ using PrecompileTools
696696
I_sparse = sparse(1.0 * LinearAlgebra.I, n, n)
697697

698698
@compile_workload begin
699-
# Initialize MPI (works in single-process mode during precompilation)
700-
MPI.Init()
699+
# Try to initialize MPI - may fail during precompilation under mpiexec
700+
mpi_ok = try
701+
MPI.Init()
702+
true
703+
catch
704+
false
705+
end
701706

707+
if mpi_ok
702708
# === VectorMPI operations (Float64) ===
703709
v = VectorMPI(v_f64)
704710
w = VectorMPI(2.0 .* v_f64)
@@ -781,6 +787,7 @@ using PrecompileTools
781787

782788
# Clear caches
783789
clear_plan_cache!()
790+
end # if mpi_ok
784791
end
785792
end
786793

0 commit comments

Comments
 (0)