Point to Point Communication I

2. Blocking Behavior

Syntax review for blocking sends and receives (note, all blocking sends take the same argument list, regardless of communication mode):

Before moving on to the communication modes, let's review syntax for blocking sends and receives.

MPI_SEND is a blocking send. This means the call does not return control to your program until the data have been copied from the location you specify in the parameter list. Because of this, you can change the data after the call and not affect the original message. (There are non-blocking sends where this is not the case.) Note that all blocking sends take the same argument list as MPI_SEND, regardless of communication mode.

C: int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)

Fortran: MPI_SEND(buf, count, datatype, dest, tag, comm, ierror)

The parameters:
buf beginning of the buffer containing the data to be sent. For Fortran, this is often the name of an array in your program. For C, it is an address.
count number of elements to be sent (not bytes)
datatype type of data
dest rank of the process which is the destination for the message
tag arbitrary number which can be used to distinguish among messages
comm communicator
ierror return error code

Like MPI_SEND, MPI_RECV is blocking. This means the call does not return control to your program until all the received data have been stored in the variable(s) you specify in the parameter list. Because of this, you can use the data after the call and be certain it is all there. (There are non-blocking receives where this is not the case.)

C: int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)

Fortran: MPI_RECV(buf, count, datatype, source, tag, comm, status, ierror)

The parameters:
buf beginning of the buffer where the incoming data are to be stored. For Fortran, this is often the name of an array in your program. For C, it is an address.
count number of elements (not bytes) in your receive buffer
datatype type of data
source rank of the process from which data will be accepted (This can be a wildcard, by specifying the parameter MPI_ANY_SOURCE.)
tag arbitrary number which can be used to distinguish among messages (This can be a wildcard, by specifying the parameter MPI_ANY_TAG.)
comm communicator
status array or structure of information that is returned. For example, if you specify a wildcard for source or tag, status will tell you the actual rank or tag for the message received
ierror return error code