Some ideas about using the advanced API for MPI, such as prob, non-blocking call etc.

Prob and get count

The MPI_Prob is similar to the operation of getting the meta data, these meta data are stored into the MPI status. This blog provides a good explanation about the prob and the associated get count operation after the prob. There are also some good examples here. The main idea is that we can allocated space dynamically based on the results of the prob instead of using the fixed amount of memory. This provides a lot of flexibility for mpi recv call.

This sentences provides a really good explanation about the MPI Probe operation: In fact, you can think of MPI_Probe as an MPI_Recv that does everything but receive the message. Similar to MPI_Recv, MPI_Probe will block for a message with a matching tag and sender. When the message is available, it will fill the status structure with information (only the metadata information here).

Non-blocking and all kinds of Wait

The high quality software that uses the MPI library may need the MPI nonblocking send and recv, this can overlap multiple communications or overlap the communciation and communication.

This is the simple version of the send and recv

Let’s see how to update it into the isend and irecv version.

The basic version is to use isend/irecv and wait, the wait MPI is used to wait for the completion of specific request handle. After the irecv operation, we could do other things and put the wait operation at last. If the data transfer operation is completed, the wait returns.

More advanced version is the wait some/any for exampe here explains the waitsome. This is used for the case where there are multiple requests, instead of waiting for the completion of all the request in the list. It seems that the waitsome provides a fine granularity control of how to process the recieved request. Once the request can be processed, such as the completion of the sending opertaion, we can move to the subsequent operations.

MPI_Wait and MPI_Test

MPI_Test seems like the non-blocking version fo the MPI_Wait, instead of waiting here, we can use a while loop and call the MPI_Test in that while loop, if the message is recieved successfully, we process the message, otherwise, we can do some other computaion tasks. This exmaple shows some ideas.

References

good references containing detailed MPI exmaples

http://mpi.deino.net/mpi_functions/