Struct
MPI_TYPE_STRUCT is the most general type constructor.
It further generalizes
the previous one in that it allows each block to consist of replications of
different datatypes.
MPI_TYPE_STRUCT(count, array_of_blocklengths,
array_of_displacements, array_of_types, newtype)
- IN
- count number of blocks (integer) - also number of
entries in arrays array_of_types,
array_of_displacements and array_of_blocklengths
- IN
- array_of_blocklength number of elements in each block
(array of integer)
- IN
- array_of_displacements byte displacement of each block
(array of integer)
- IN
- array_of_types type of elements in each block (array
of handles to datatype objects)
- OUT
- newtype new datatype (handle)
int MPI_Type_struct(int count, int *array_of_blocklengths, MPI_Aint *array_of_displacements, MPI_Datatype *array_of_types, MPI_Datatype *newtype)
MPI_TYPE_STRUCT(COUNT, ARRAY_OF_BLOCKLENGTHS, ARRAY_OF_DISPLACEMENTS, ARRAY_OF_TYPES, NEWTYPE, IERROR)
INTEGER COUNT, ARRAY_OF_BLOCKLENGTHS(*), ARRAY_OF_DISPLACEMENTS(*), ARRAY_OF_TYPES(*), NEWTYPE, IERROR
Example 3..24 Let
type1 have type map,
with extent 16.
Let
B = (2, 1, 3),
D = (0, 16, 26),
and
T = (MPI_FLOAT, type1, MPI_CHAR). Then a call to
MPI_TYPE_STRUCT(3, B, D, T, newtype) returns
a datatype with type map,
That is, two copies of
MPI_FLOAT starting at 0, followed by
one copy of
type1 starting at 16, followed by three copies of
MPI_CHAR, starting at 26.
(We assume that a float occupies four bytes.)
In general,
let T be the array_of_types argument, where T[i]
is a handle to,
with extent
.
Let
B be the array_of_blocklength argument and D be
the array_of_displacements argument. Let c be the
count argument.
Then the newly created datatype has a type map with
entries:
A call to MPI_TYPE_HINDEXED( count, B, D, oldtype, newtype) is
equivalent to a call to
MPI_TYPE_STRUCT( count, B, D, T, newtype), where each entry
of T is equal to oldtype.
MPI-Standard for MARMOT