Flexibility in Message Order
MPI_Waitany and Friends
MPI_Wait halts progress until a specific nonblocking request (send or receive) is satisfied; the related message buffer is then safe to use. However, what if you have not just one request, but an entire array of them? How do you decide which request to wait for first? Variants of MPI_Wait like MPI_Waitany help you resolve multiple calls in arbitrary order.
- MPI_Waitany waits for any one request from an array
- MPI_Waitall does the same thing for a whole array of requests
- MPI_Waitsome waits for one or more requests from an array
Outline for typical code:
MPI_Testany and Friends
MPI_Test immediately returns the status (no waiting!) of a specific nonblocking operation, again identified by a request handle. Not surprisingly, the Test call features variants similar to those of Wait, which work similarly: MPI_Testany, MPI_Testall, and MPI_Testsome. Here are the C prototypes for these functions:
For Testsome, no flag variable is needed. If no request is satisfied, it merely returns outcount=0, rather than setting the flag to false.