What does MPI_Recv have in common with calls like MPI_Wait, MPI_Test, and MPI_Probe (and their variants), as described in previous sections? They all return a status variable. Status is not simply a flag value, but an object with several useful fields. The status variable provides information on the message source and tag, as well as any error incurred on the communication call. In Fortran, the information is returned in the form of an integer array: status(MPI_SOURCE), status(MPI_TAG), and status(MPI_ERROR). In C, these are returned as fields in a struct of type MPI_Status: status.MPI_SOURCE, status.MPI_TAG, and status.MPI_ERROR.

The status variable is designed to fill in missing information that was unknown at the time the call was made. Clearly, the error status is something that can't be known in advance. Also, if a receive or probe is posted with the wildcards MPI_ANY_TAG and/or MPI_ANY_SOURCE, the source or tag must be discovered from status. (Note: a send can never use wildcards, so the error field is the only sensible value that is returned in the status variable for a Wait or Test operation on a nonblocking send.)

Status also serves as an input parameter to the MPI_Get_count function, which returns the number of elements in a receive buffer. This is particularly helpful when a receive has been completed for MPI_ANY_TAG or MPI_ANY_SOURCE; or when an incoming message has been identified by MPI_Probe, but its content is unknown prior to parsing.

C
int MPI_Get_count (MPI_Status *status, MPI_Datatype datatype, int *count)
Fortran
MPI_Get_count (status, datatype, count, ierror)
    INTEGER status(MPI_STATUS_SIZE), datatype, count, ierror 

Status becomes defined only after a matching communication event has taken place; otherwise, it remains undefined. Blocking calls such as MPI_Recv, MPI_Wait, and MPI_Probe do not return until a matching communication event is found, so obviously, the status is defined upon return. For nonblocking calls like MPI_Test and MPI_Iprobe, the status is defined only if flag=true (or the equivalent) upon return.

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