HP-MPI User's Guide (11th Edition)
Introduction
MPI concepts
Chapter 1 15
Provide MPI_Pack and MPI_Unpack functions so that a
sending process can pack noncontiguous data into a
contiguous buffer and a receiving process can unpack
data received in a contiguous buffer and store it in
noncontiguous locations.
Using derived datatypes is more efficient than using MPI_Pack and
MPI_Unpack. However, derived datatypes cannot handle the case where
the data layout varies and is unknown by the receiver, for example,
messages that embed their own layout description.
Section 3.12, “Derived Datatypes” in the MPI 1.0 standard describes the
construction and use of derived datatypes. The following is a summary of
the types of constructor functions available in MPI:
• Contiguous (MPI_Type_contiguous)—Allows replication of a
datatype into contiguous locations.
• Vector (MPI_Type_vector)—Allows replication of a datatype into
locations that consist of equally spaced blocks.
• Indexed (MPI_Type_indexed)—Allows replication of a datatype into
a sequence of blocks where each block can contain a different number
of copies and have a different displacement.
• Structure (MPI_Type_struct)—Allows replication of a datatype into
a sequence of blocks such that each block consists of replications of
different datatypes, copies, and displacements.
After you create a derived datatype, you must commit it by calling
MPI_Type_commit.
HP-MPI optimizes collection and communication of derived datatypes.
Section 3.13, “Pack and unpack” in the MPI 1.0 standard describes the
details of the pack and unpack functions for MPI. Used together, these
routines allow you to transfer heterogeneous data in a single message,
thus amortizing the fixed overhead of sending and receiving a message
over the transmittal of many elements.
Refer to Chapter 3, “User-Defined Datatypes and Packing” in MPI: The
Complete Reference for a discussion of this topic and examples of
construction of derived datatypes from the basic datatypes using the
MPI constructor functions.