The basic contiguous send routine has the form
MPID_SendContig( comm, buf, len, src_lrank, tag, context_id, dest_grank,
msgrep, &error_code )
One point that deserves discussion is the use of a global rank for the destination instead of a rank relative to the communicator. The advantage of using a global rank is that many ADI implementations can then ignore the communicator argument (except for error processing). In addition, for communicators congruent to MPI_COMM_WORLD, no translation from relative to global ranks is needed.
MPI programs can suffer in performance if a naive implemenations of MPI_Bsend is used. The standard shows an implementation that uses nonblocking sends and extra copies for each message. Many systems can deliver short messages without any special effort; the routine MPID_BsendContig does so if possible. However, rather than block as MPID_SendContig does if the message cannot be delivered, MPID_BsendContig returns MPIR_ERR_MAY_BLOCK as the error code. In this case, the MPI implementation (not the ADI) can use the model solution in the standard.
The routine to receive a message is much like the send routines, with the
addition of an
MPI_Status argument:
MPID_RecvContig( comm, buf, maxlen, src_lrank, tag, context_id,
&status, &error_code )
The address of the status may be null, in which case all status
information is discarded. This is not supported by the MPI standard, but is
not prohibited either, and this allows study of what efficiencies can be
gained.
Note that the receive is given the src_lrank, the local rank of the
source in the communicator. If the implementation of MPID_RecvContig
requires the absolute rank, it can get this from the communicator with the
code (this is MPICH-specific)
comm->lrank_to_grank[src_lrank]Note that MPID_RecvContig has both a status and an error_code argument. An MPI status has the field MPI_ERROR;Added in version 1.1 of the MPI standard. this could be used instead. Doing so, however, would eliminate the possibility of using a null status. Moreover, in the case of no error, there is no additional cost.