|
Having successfully decoupled your communications from your main computational thread, you will nonetheless need to be able to both obtain information about the status of the communication transaction, and arrange to take certain actions regarding the conditions you find. The three calls described here are among the most commonly useful for dealing with these kinds of situations.
-
MPI_Wait

-
Useful for both sender and receiver of non-blocking communications. Blocking communications involve an automatic wait, so you'll never see a non-trivial call to it when such operations are used. In both the send and receive cases for non-blocking operations, the calling process suspends its operation until the operation referenced by the wait has completed, at which time execution resumes in the calling process.
-
Receiving process blocks until message is received, under programmer controlOn the receive side, the process has already posted a non-blocking receive, which will be completed regardless of what the calling process does. The programmer is therefore able to determine whether or not any useful computation can be accomplished before the information in the not-yet-received message is required ... if there is useful work available, the application has clearly gained efficiency by doing that work while the message is still in transit. At some point, of course, the message will be needed, and a wait will be issued.
-
Sending process blocks until send operation completes, at which time the message buffer is available for re-use On the sending side, the process is also freed from the transaction, except for the fact that it is constrained from doing any more writing to that particular buffer until its current use is completed ... if the sender attempts to put some other message into that buffer before the preceding transmission completes, the results are indeterminate and based solely on what part of the process was in train when the overwriting occurred. Doing a wait on the message guarantees that re-use will not be destructive.
-
MPI_Test
-
Used for both sender and receiver of non-blocking communication.Where wait suspends execution until an operation completes, test returns immediately with information about its current status.
-
Receiver checks to see if a specific sender has sent a message that is waiting to be delivered ... messages from all other senders are ignored.The test call will return true only in the case that the sender specified in the object has sent a message which is currently in the queue for delivery; traffic from all other sources is ignored.
-
Sender can find out if the message-buffer can be re-used ... have to wait until operation is complete before doing so. On the sender side, test is the non-blocking analog to wait, giving the application knowledge of the current state without requiring it to block until completion, thus allowing the application to do other work, if any exists.
- MPI_Probe
Receiver is notified when (i.e., this is a blocking call) messages from potentially any sender arrive and are ready to be processed.The previous calls all targeted specific messages and senders; the probe call can be tailored to return "deliverable" information regarding messages from any sender, as well as from specific ones.
|