MPI_Probe is a pre-receive query about a message. You can use it to snoop on an incoming message to decide how it should be received. Typically you'll need it when a message is expected from a certain source with a certain tag, but the treatment of this message will depend on the contents, which might vary. For example, an MPI_Probe can help you choose whether to allocate a larger buffer to prepare for a big message, or whether to execute MPI_Cancel in order to save memory.

MPI_Probe therefore serves a somewhat different purpose from MPI_Test. As we have seen, MPI_Test works in conjunction with nonblocking calls. It tells you whether a specific call has completed after a nonblocking send or receive has been issued. In contrast, MPI_Probe provides an earlier determination about the status of a message having a given source and tag. It allows you to take some sort of action before posting a receive for the message.

Blocking and nonblocking versions of the query are available. The calling sequence for MPI_Iprobe looks like this:


    MPI_Iprobe(int source, int tag, MPI_Comm comm,
               int *flag, MPI_Status *status);

MPI_Probe differs in that it has no true/false flag; it simply blocks until a matching message arrives.

For even greater flexibility, the "wildcards" MPI_ANY_SOURCE and MPI_ANY_TAG may be used by MPI_Probe and MPI_Iprobe in situations where the source or tag of a message does not need to be known in advance.

 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement