HP-MPI User's Guide (11th Edition)
Introduction
MPI concepts
Chapter 114
Synchronization
Collective routines return as soon as their participation in a
communication is complete. However, the return of the calling process
does not guarantee that the receiving processes have completed or even
started the operation.
To synchronize the execution of processes, call MPI_Barrier.
MPI_Barrier blocks the calling process until all processes in the
communicator have called it. This is a useful approach for separating two
stages of a computation so messages from each stage do not overlap.
To implement a barrier, use
MPI_Barrier(MPI_Comm comm);
where
comm Identifies a group of processes and a communication
context.
For example, “cart.C” on page 245 uses MPI_Barrier to synchronize data
before printing.
MPI datatypes and packing
You can use predefined datatypes (for example, MPI_INT in C) to transfer
data between two processes using point-to-point communication. This
transfer is based on the assumption that the data transferred is stored in
contiguous memory (for example, sending an array in a C or Fortran
application).
When you want to transfer data that is not homogeneous, such as a
structure, or that is not contiguous in memory, such as an array section,
you can use derived datatypes or packing and unpacking functions:
Derived datatypes
Specifies a sequence of basic datatypes and integer
displacements describing the data layout in memory.
You can use user-defined datatypes or predefined
datatypes in MPI communication functions.
Packing and Unpacking functions