6.1.8. True Extent of Datatypes

PreviousUpNext
Up: Derived Datatypes Next: Commit and Free Previous: Extent and Bounds of Datatypes

Suppose we implement gather (see also Section Gather) as a spanning tree implemented on top of point-to-point routines. Since the receive buffer is only valid on the root process, one will need to allocate some temporary space for receiving data on intermediate nodes. However, the datatype extent cannot be used as an estimate of the amount of space that needs to be allocated, if the user has modified the extent, for example by using MPI_TYPE_CREATE_RESIZED. The procedure MPI_TYPE_GET_TRUE_EXTENT returns the true extent of the datatype.

MPI_TYPE_GET_TRUE_EXTENT(datatype, true_lb, true_extent)
IN datatypedatatype to get information on (handle)
OUT true_lbtrue lower bound of datatype (integer)
OUT true_extenttrue extent of datatype (integer)
C binding
int MPI_Type_get_true_extent(MPI_Datatype datatype, MPI_Aint *true_lb, MPI_Aint *true_extent)
int MPI_Type_get_true_extent_c(MPI_Datatype datatype, MPI_Count *true_lb, MPI_Count *true_extent)
Fortran 2008 binding
MPI_Type_get_true_extent(datatype, true_lb, true_extent, ierror)

TYPE(MPI_Datatype), INTENT(IN) :: datatype
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: true_lb, true_extent
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Type_get_true_extent(datatype, true_lb, true_extent, ierror) !(_c)

TYPE(MPI_Datatype), INTENT(IN) :: datatype
INTEGER(KIND=MPI_COUNT_KIND), INTENT(OUT) :: true_lb, true_extent
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_TYPE_GET_TRUE_EXTENT(DATATYPE, TRUE_LB, TRUE_EXTENT, IERROR)

INTEGER DATATYPE, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) TRUE_LB, TRUE_EXTENT

true_lb returns the offset of the lowest unit of storage that is addressed by the datatype, i.e., the lower bound of the corresponding typemap, ignoring explicit lower bound markers. true_extent returns the true size of the datatype, i.e., the extent of the corresponding typemap, ignoring explicit lower bound and upper bound markers, and performing no rounding for alignment. If the typemap associated with datatype is

Image file

Then

Image file

Image file

and

true_extent (mwordTypemap) = true_ub(mwordTypemap) - true_lb(mwordTypemap).

(Readers should compare this with the definitions in Section Lower-Bound and Upper-Bound Markers and Section Extent and Bounds of Datatypes, which describe the procedure MPI_TYPE_GET_EXTENT.)

The true_extent is the minimum number of bytes of memory necessary to hold a datatype, uncompressed.

If either OUT parameter cannot express the value to be returned (e.g., if the parameter is too small to hold the output value), it is set to MPI_UNDEFINED.


PreviousUpNext
Up: Derived Datatypes Next: Commit and Free Previous: Extent and Bounds of Datatypes


Return to MPI-4.1 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023