Repository navigation
Add support for custom MPI communicator #188
Description
Activity
Hello @fsimonis ! Based on your comment here precice/precice#2544 (comment):
More as a side note: preCICE is compatible with the Multiple Instruction Multiple Data (MIMD) Model of MPI, where multiple executables are launched in the same world communicator.
The solver needs to support using a communicator other than world, and the adapter needs to forward the correct communicator to preCICE. None of the official adapters support this, as every participant needs to participate in such a collective split, but it should be easy to implement in in-house codes.
So, this is possible.I wanted to try this with the Python code I work with.
While the interface suggests that one can pass a communicator of typempi4py.MPI.Intracomm, it does not work in practice:
As soon as I pass a communicator, I get a segmentation fault with the following backtrace:0 0x0000000000012990 __funlockfile() :0 1 0x00000000000b1133 MPI_Comm_rank() ???:0 2 0x000000000030f4a9 precice::utils::Parallel::CommState::rank() :0 3 0x0000000000281055 precice::impl::ParticipantImpl::ParticipantImpl() :0 4 0x0000000000281670 precice::Participant::Participant() ???:0 5 0x000000000001f8ec __pyx_pw_9cyprecice_11Participant_3__cinit__() /tmp/pip-req-build-a0dn74rh/cyprecice/cyprecice.cpp:7020 6 0x000000000001f8ec __pyx_pw_9cyprecice_11Participant_3__cinit__() /tmp/pip-req-build-a0dn74rh/cyprecice/cyprecice.cpp:6957 7 0x0000000000020541 __pyx_tp_new_9cyprecice_Participant() /tmp/pip-req-build-a0dn74rh/cyprecice/cyprecice.cpp:16785 8 0x000000000017b65e type_call() /dev/shm/easybuild/build/Python/3.13.5/GCCcore-14.3.0/Python-3.13.5/Objects/typeobject.c:1985I have tried
MPI.COMM_SELFandMPI.COMM_WORLD; the latter is not technically anIntracommobject but I figured this should behave exactly as passingNone.
I found this issue when I started writing up a reproducible example to ask about it... Does this mean that custom MPI communicators are still not supported for the Python bindings and my error is a result of this?@valentinaschueller Thanks for bringing this up.
Can you try the fix and report in the PR if this works? #256
Reacted by Valentina Schüller
The python bindings currently don't support the constructor which provides a custom MPI_Communicator to preCICE.
https://precice.org/doxygen/develop/classprecice_1_1Participant.html#a292d1a7e046ac3c083c3eec09bdb1a48
This locks preCICE into using MPI_COMM_WORLD and blocks reconstruction of the Participant.
Resulting issue: precice/precice#828