IBM Books

MPI Subroutine Reference

MPI_TYPE_GET_CONTENTS, MPI_Type_get_contents

Purpose

Obtains the arguments used in the creation of the datatype.

C synopsis

#include <mpi.h>
int MPI_Type_get_contents(MPI_Datatype datatype,int *max_integers, 
			  int *max_addresses, int *max_datatypes,
			  int array_of_integers[],
			  int array_of_addresses[],
			  int array_of_datatypes[]);

C++ synopsis

#include mpi.h
void MPI::Datatype::Get_contents(int max_integers, int max_addresses,
                                 int max_datatypes, int array_of_integers[],
                                 MPI::Aint array_of_addresses[],
                                 MPI::Datatype array_of_datatypes[]) 
				 const;

FORTRAN synopsis

include 'mpif.h' or use mpi
MPI_TYPE_GET_CONTENTS(INTEGER DATATYPE, INTEGER MAX_INTEGERS,INTEGER MAX_ADDRESSES, 
		      INTEGER MAX_DATATYPES,INTEGER ARRAY_of_INTEGERS, INTEGER ARRAY_OF_ADDRESSES,
		      INTEGER ARRAY_of_DATATYPES, INTEGER IERROR)

Parameters

datatype
is the datatype to access (handle) (IN)

max_integers
is the number of elements in array_of_integers (non-negative integer) (IN)

max_addresses
is the number of elements in the array_of_addresses (non-negative integer) (IN)

max_datatypes
is the number of elements in array_of_datatypes (non-negative integer) (IN)

array_of_integers
contains integer arguments used in the constructing datatype (array of integers) (OUT)

array_of_addresses
contains address arguments used in the constructing datatype (array of integers) (OUT)

array_of_datatypes
contains datatype arguments used in the constructing datatype (array of handles) (OUT)

If the combiner is MPI_COMBINER_NAMED, it is erroneous to call MPI_TYPE_GET_CONTENTS.

Table 4 lists the combiners and constructor arguments. The lowercase names of the arguments are shown.

Table 4. Combiners and constructor arguments

Constructor argument C location FORTRAN location ni
na
nd
MPI_COMBINER_DUP
oldtype d[0] D(1) 0
0
1
MPI_COMBINER_CONTIGUOUS
count
oldtype
i[0]
d[0]
I(1)
D(1)
1
0
1
MPI_COMBINER_VECTOR
count
blocklength
stride
oldtype
i[0]
i[1]
i[2]
d[0]
I(1)
I(2)
I(3)
D(1)
3
0
1
MPI_COMBINER_HVECTOR
MPI_COMBINER_HVECTOR_INTEGER
count
blocklength
stride
oldtype
i[0]
i[1]
a[0]
d[0]
I(1)
I(2)
A(1)
D(1)
2
1
1
MPI_COMBINER_INDEXED
count
array_of_blocklengths
array_of_displacements
oldtype
i[0]
i[1] to i[i[0]]
i[i[0]+1] to i[2*i[0]]
d[0]
I(1)
I(2) to I(I(1)+1)
I(I(1)+2) to I(2*I(1)+1)
D(1)
2*count+1
0
1
MPI_COMBINER_HINDEXED
MPI_COMBINER_HINDEXED_INTEGER
count
array_of_blocklengths
array_of_displacements
oldtype
i[0]
i[1] to i[i[0]]
a[0] to a[i[0]-1]
d[0]
I(1)
I(2) to I(I(1)+1)
A(1) to A(I(1))
D(1)
count+1
count
1
MPI_COMBINER_INDEXED_BLOCK
count
blocklength
array_of_displacements
oldtype
i[0]
i[1]
i[2] to i[i[0]+1]
d[0]
I(1)
I(2)
I(3) to I(I(1)+2)
D(1)
count+2
0
1
MPI_COMBINER_STRUCT
MPI_COMBINER_STRUCT_INTEGER
count
array_of_blocklengths
array_of_displacements
array_of_types
i[0]
i[1] to i[i[0]]
a[0] to a[i[0]-1]
d[0] to d[i[0]-1]
I(1)
I(2) to I(I(1)+1)
A(1) to A(I(1))
D(1)
count+1
count
count
MPI_COMBINER_SUBARRAY
ndims
array_of_sizes
array_of_subsizes
array_of_starts
order
oldtype
i[0]
i[1] to i[i[0]]
i[i[0]+1] to i[2*i[0]]
i[2*i[0]+1] to i[3*i[0]]
i[3*i[0]+1]
d[0]
I(1)
I(2) to I(I(1)+1)
I(I(1)+2) to I(2*I(1)+1)
I(2*I(1)+2) to I(3*I(1)+1)
I(3*I(1)+2)
D(1)
3*ndims+2
0
1
MPI_COMBINER_DARRAY
size
rank
ndims
array_of_gsizes
array_of_distribs
array_of_dargs
array_of_psizes
order
oldtype
i[0]
i[1]
i[2]
i[3] to i[i[2]+2]
i[i[2]+3] to i[2*i[2]+2]
i[2*i[2]+3] to i[3*i[2]+2]
i[3*i[2]+3] to i[4*i[2]+2]
i[4*i[2]+3]
d[0]
I(1)
I(2)
I(3)
I(4) to I(I(3)+3)
I(I(3)+4) to I(2*I(3)+3)
I(2*I(3)+4) to I(3*I(3)+3)
I(3*I(3)+4) to I(4*I(3)+3)
I(4*I(3)+4)
D(1)
4*ndims+4
0
1
MPI_COMBINER_F90_REAL
MPI_COMBINER_F90_COMPLEX
p
r
i[0]
i[1]
I(1)
I(2)
2
0
0
MPI_COMBINER_F90_INTEGER
r i[0] I(1) 1
0
0
MPI_COMBINER_RESIZED
lb
extent
oldtype
a[0]
a[1]
d[0]
A(1)
A(2)
D(1)
0
2
1

Description

MPI_TYPE_GET_CONTENTS identifies the combiner and returns the arguments that were used with this combiner to create the datatype of interest. A call to MPI_TYPE_GET_CONTENTS is normally preceded by a call to MPI_TYPE_GET_ENVELOPE to discover whether the type of interest is one that can be decoded and if so, how large the output arrays must be. An MPI_COMBINER_NAMED datatype is a predefined type that may not be decoded. The datatype handles returned in array_of_datatypes can include both named and derived types. The derived types may or may not already be committed. Each entry in array_of_datatypes is a separate datatype handle that must eventually be freed if it represents a derived type.

Notes

An MPI type constructor, such as MPI_TYPE_CONTIGUOUS, creates a datatype object within MPI and gives a handle for that object to the caller. This handle represents one reference to the object. IN PE MPI, the MPI datatypes obtained with calls to MPI_TYPE_GET_CONTENTS are new handles for the existing datatype objects. The number of handles (references) given to the user is tracked by a reference counter in the object. MPI cannot discard a datatype object unless MPI_TYPE_FREE has been called on every handle the user has obtained.

The use of reference-counted objects is encouraged, but not mandated, by the MPI standard. Another MPI implementation may create new objects instead. The user should be aware of a side effect of the reference count approach. Suppose mytype was created by a call to MPI_TYPE_VECTOR and used so that a later call to MPI_TYPE_GET_CONTENTS returns its handle in hertype. Because both handles identify the same datatype object, attribute changes made with either handle are changes in the single object. That object will exist at least until MPI_TYPE_FREE has been called on both mytype and hertype. Freeing either handle alone will leave the object intact and the other handle will remain valid.

Errors

Invalid datatype

Predefined datatype

Maximum array size is not big enough

MPI already finalized

MPI not initialized

Related information

MPI_TYPE_COMMIT
MPI_TYPE_FREE
MPI_TYPE_GET_ENVELOPE


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]