Point to Point Communication Routines: MPI Message Passing Routine Arguments

MPI point-to-point communication routines generally have an argument list that takes one of the following formats:

Blocking sendsMPI_Send(buffer,count,type,dest,tag,comm)
Non-blocking sendsMPI_Isend(buffer,count,type,dest,tag,comm,request)
Blocking receiveMPI_Recv(buffer,count,type,source,tag,comm,status)
Non-blocking receiveMPI_Irecv(buffer,count,type,source,tag,comm,request)

Buffer

Program (application) address space that references the data that is to be sent or received. In most cases, this is simply the variable name that is be sent/received. For C programs, this argument is passed by reference and usually must be prepended with an ampersand: &var1

Data Count

Indicates the number of data elements of a particular type to be sent.

Data Type

For reasons of portability, MPI predefines its elementary data types. The table below lists those required by the standard.

C Data TypesFortran Data Types
MPI_CHARcharMPI_CHARACTERcharacter(1)
MPI_WCHARwchar_t - wide character
MPI_SHORTsigned short int
MPI_INTsigned intMPI_INTEGER
MPI_INTEGER1
MPI_INTEGER2
MPI_INTEGER4
integer
integer*1
integer*2
integer*4
MPI_LONGsigned long int
MPI_LONG_LONG_INT
MPI_LONG_LONG
signed long long int
MPI_SIGNED_CHARsigned char
MPI_UNSIGNED_CHARunsigned char
MPI_UNSIGNED_SHORTunsigned short int
MPI_UNSIGNEDunsigned int
MPI_UNSIGNED_LONGunsigned long int
MPI_UNSIGNED_LONG_LONGunsigned long long int
MPI_FLOATfloatMPI_REAL
MPI_REAL2
MPI_REAL4
MPI_REAL8
real
real*2
real*4
real*8
MPI_DOUBLEdoubleMPI_DOUBLE_PRECISIONdouble precision
MPI_LONG_DOUBLElong double
MPI_C_COMPLEX
MPI_C_FLOAT_COMPLEX
float _ComplexMPI_COMPLEXcomplex
MPI_C_DOUBLE_COMPLEXdouble _ComplexMPI_DOUBLE_COMPLEXdouble complex
MPI_C_LONG_DOUBLE_COMPLEXlong double _Complex
MPI_C_BOOL_BoolMPI_LOGICALlogical
MPI_INT8_T
MPI_INT16_T
MPI_INT32_T
MPI_INT64_T
int8_t
int16_t
int32_t
int64_t
MPI_UINT8_T
MPI_UINT16_T
MPI_UINT32_T
MPI_UINT64_T
uint8_t
uint16_t
uint32_t
uint64_t
MPI_BYTE8 binary digits MPI_BYTE8 binary digits
MPI_PACKEDdata packed or unpacked with MPI_Pack()/ MPI_UnpackMPI_PACKEDdata packed or unpacked with MPI_Pack()/ MPI_Unpack

Notes:

Destination

An argument to send routines that indicates the process where a message should be delivered. Specified as the rank of the receiving process.

Source

An argument to receive routines that indicates the originating process of the message. Specified as the rank of the sending process. This may be set to the wild card MPI_ANY_SOURCE to receive a message from any task.

Tag

Arbitrary non-negative integer assigned by the programmer to uniquely identify a message. Send and receive operations should match message tags. For a receive operation, the wild card MPI_ANY_TAG can be used to receive any message regardless of its tag. The MPI standard guarantees that integers 0-32767 can be used as tags, but most implementations allow a much larger range than this.

Communicator

Indicates the communication context, or set of processes for which the source or destination fields are valid. Unless the programmer is explicitly creating new communicators, the predefined communicator MPI_COMM_WORLD is usually used.

Status

For a receive operation, indicates the source of the message and the tag of the message. In C, this argument is a pointer to a predefined structure MPI_Status (ex. stat.MPI_SOURCE stat.MPI_TAG). In Fortran, it is an integer array of size MPI_STATUS_SIZE (ex. stat(MPI_SOURCE) stat(MPI_TAG)). Additionally, the actual number of bytes received is obtainable from Status via the MPI_Get_count routine. The constants MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE can be substituted if a message’s source, tag or size will be be queried later.

Request

Used by non-blocking send and receive operations. Since non-blocking operations may return before the requested system buffer space is obtained, the system issues a unique “request number”. The programmer uses this system assigned “handle” later (in a WAIT type routine) to determine completion of the non-blocking operation. In C, this argument is a pointer to a predefined structure MPI_Request. In Fortran, it is an integer.