When using MPI_Isend
, can the MPI_Request
parameter be a null pointer (when the sender doesn't care about the message after it is sent)?
Short answer is no - the request handle parameter cannot be NULL
.
MPI_Isend()
initiates an asynchronous send operation. All asynchronous operations are given a request handle that has to be acted on later in one of the following ways:
MPI_Wait()
and friendsMPI_Test()
and friends until the test turns out positiveMPI_Request_free()
Both waiting and testing functions free the request once it has completed. You can also free it immediately after it is returned by MPI_Isend()
. This will not cancel the operation but rather mark the request for deletion as soon as it is finished. You won't be able to get the status of the send operation though.
If you don't care about the outcome of the asynchronous operation (e.g. completion status, message receive status, error code, etc.), the right thing to do is as follows:
MPI_Request req;
...
MPI_Isend(..., &req);
MPI_Request_free(&req);
...
Caveat: this works for asynchronous sends since one can devise another method to verify that the send operation has completed, e.g. the destination process might respond after receiving the message. But one should never free an asynchronous receive request and should wait or test for completion instead as there will be no way to know when the operation has been completed.