Sending


Up: The Contiguous Routines Next: Buffered Sends Previous: The Contiguous Routines

The basic contiguous send routine has the form

MPID_SendContig( comm, buf, len, src_lrank, tag, context_id, dest_grank, 
                 msgrep, &error_code ) 
comm
Communicator for the operation (struct MPIR_COMMUNICATOR *, not MPI_Comm).
buf
Address of the buffer.
len
Length in bytes of the buffer.
src_lrank
Rank in communicator of the sender (source local rank).
tag
Message tag.
context_id
Numeric context id.
dest_grank
Rank of the destination, as known to the device. Usually this is the rank in MPI_COMM_WORLD but may differ if dynamic process management is supported.
msgrep
The message representation form. This is an MPID_Msgrep_t (enum int) data item that will be delivered to the receiving process. Implementations are free to ignore this value.
error_code
The result of the action (an MPI error code). This may be set only if the value would not be MPI_SUCCESS. In other words, an implementation is free to not set this unless there is an error. The error code was made an argument so that an implementation as a macro would be easier.

Similar versions exist for the other MPI send modes (i.e., MPID_SsendContig and MPID_RsendContig).

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.



Up: The Contiguous Routines Next: Buffered Sends Previous: The Contiguous Routines


Buffered Sends


Up: Sending Next: Receiving Previous: Sending

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.



Up: Sending Next: Receiving Previous: Sending


Receiving


Up: Sending Next: Summary of Blocking Routines Previous: Buffered Sends

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.



Up: Sending Next: Summary of Blocking Routines Previous: Buffered Sends