CTC Discussion on MPI Basics: Six Basic Calls
1.2.4 Sending a message
In MPI, there are many flavors of sends and receives.
This is one reason why there are over 125 routines provided in MPI.
In our basic set of six calls, we will look
at just one type of send and one type of receive.
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.)
- 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)
<type> buf(*)
integer count, datatype, dest, tag, comm, ierror
The parameters:
- buf is the 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 is the number of elements to be sent (not bytes)
- datatype is the type of data
- dest is the rank of the process which is the destination for the message
- tag is an arbitrary number which can be used to distinguish among messages
- comm is the communicator
- ierror is a return error code
These will be discussed in more detail later in the module.