Skip to content

Commit 448742d

Browse files
committed
fix MPI crash in NonMPI env
1 parent 188c8d8 commit 448742d

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

vbcsr/pybind_common.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ inline MPI_Comm get_mpi_comm(py::object comm_obj) {
1212

1313
if (comm_obj.is_none()) {
1414
if (initialized) return MPI_COMM_WORLD;
15-
16-
// If not initialized, we initialize it to support serial execution (size=1)
17-
// or execution where mpi4py is not used but MPI is needed by C++.
18-
int provided;
19-
MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, &provided);
20-
return MPI_COMM_WORLD;
15+
16+
// MPI not initialized and no communicator requested → serial mode.
17+
// Do NOT call MPI_Init_thread here — if the system MPI is absent or
18+
// misconfigured (e.g. conda env without openmpi), it would crash.
19+
return MPI_COMM_NULL;
2120
}
2221

2322
// If a communicator is provided, we MUST be initialized

0 commit comments

Comments
 (0)