Buffer in MPI calls is the space in the computer's memory where
the MPI messages are to be sent from or stored to. In this context,
a buffer is simply memory the compiler has assigned to a variable (often an array)
in your program. Three parameters in the MPI call are needed to specify
the buffer:
Startbuf
The address where the data start. For example, the start of an array in your program.
Count
The number of elements (items) of data in the message. Note that this is elements,
not bytes. This makes for portable code, since there is no need
to worry about different representations of data types on different computers. The
software implementation of MPI determines the number of bytes automatically.
The count specified by the receive call should be equal to or greater than the count
specified by the send. If more data is sent than storage is available in the receive
buffer, an error will occur.
Datatype
The type of data to be transmitted--floating point, for example. The datatype should
be the same for the send and receive call. An
exception to this rule is the datatype MPI_PACKED, which is one method of handling
mixed-type messages (the preferred method is with a derived datatype). Type-checking
is relaxed in this case. The types of data already defined for you are called "basic
datatypes," and are listed below. Warning: the names are slightly different
between the C and the Fortran implementations.
MPI Basic Datatypes for C
| MPI Datatype |
C Datatype |
| MPI_CHAR |
signed char |
| MPI_SHORT |
signed short int |
| MPI_INT |
signed int |
| MPI_LONG |
signed long int |
| MPI_UNSIGNED_CHAR |
unsigned char |
| MPI_UNSIGNED_SHORT |
unsigned short int |
| MPI_UNSIGNED |
unsigned int |
| MPI_UNSIGNED_LONG |
unsigned long int |
| MPI_FLOAT |
float |
| MPI_DOUBLE |
double |
| MPI_LONG_DOUBLE |
long double |
| MPI_BYTE |
|
| MPI_PACKED |
|
MPI Basic Datatypes for Fortran
| MPI Datatype |
Fortran Datatype |
| MPI_INTEGER |
INTEGER |
| MPI_REAL |
REAL |
| MPI_DOUBLE_PRECISION |
DOUBLE PRECISION |
| MPI_COMPLEX |
COMPLEX |
| MPI_LOGICAL |
LOGICAL |
| MPI_CHARACTER |
CHARACTER(1) |
| MPI_BYTE |
|
| MPI_PACKED |
|
Derived Datatypes
Additional datatypes, called derived datatypes can also be defined. You can
define a datatype for noncontiguous data or for a sequence of mixed basic datatypes.
This can make programming easier and often make the code
run faster. Derived datatypes are beyond the scope of this introduction, but are
covered in the talk
Derived Datatypes.
Some derived datatypes are:
- Contiguous
- Vector
- Hvector
- Indexed
- Hindexed
- Struct