What happens if you use one of the MPI communication methods to have a rank communicate with itself? Is there a well-defined behavior (e.g. guaranteed to succeed or fail), or does it depend on chance/other uncontrollable influences, whether the program will continue to run or not?
An example would be a fluid dynamics code, where each rank determines which grid cells need to be sent to the neighboring ranks to create the necessary halo for the computational stencil. If the simulation is started just on one rank, there would be non-blocking send/receive of rank 0 with itself (sending around 0-length information).
While you can avoid self-messaging as per suszterpatt's answer, self-messaging will work and is part of the MPI standard. There is even a pre-defined convenience communicator MPI_COMM_SELF
. As long as the send/receive calls do not cause deadlock (for example, non-blocking calls are used), sending to self is fine. Of course, the send and receive buffers should not overlap.
Note that with OpenMPI you need to enable the self
BTL.
Source: MPI 1.1 Section 3.2.4
Source = destination is allowed, that is, a process can send a message to itself. (However, it is unsafe to do so with the blocking send and receive operations described above, since this may lead to deadlock. See Sec. 3.5. Semantics of point-to-point communication.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With