Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the behavior of MPI communication of a rank with itself well-defined?

Tags:

mpi

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).

like image 970
Michael Schlottke-Lakemper Avatar asked Jul 08 '12 18:07

Michael Schlottke-Lakemper


Video Answer


1 Answers

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.)

like image 97
Greg Inozemtsev Avatar answered Nov 27 '22 17:11

Greg Inozemtsev