'MPI_Probe() for determining message size
A common usage of MPI_Probe is in determining the size of an incoming message so that enough memory is allocated for the receive buffer. But this can also be done with a separate pair of MPI_Send-MPI_Recv calls, i.e. the sender process sends the message size to the receiver in a different message. Can it be assumed that MPI_Probe is in general the faster option? Why? We can perform some tests and compare the walltimes, but the results may be implementation-dependent.
Solution 1:[1]
- For short messages the latency is more important than the size of the message, so probing for a small message is probably faster.
- Probing makes it easier to deal with
MPI_ANY_SOURCEas a sender: otherwise you'd have to first determine where the size msg comes from, and then do a specific receive from that source.
Instead of MPI_Probe, people often do MPI_Iprobe which tells you if there is a message at all. Yes, you can emulate that with multiple Irecvs, but why would you make your code so complicated?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Victor Eijkhout |
