Address and extent functions

Address and extent functions


Up: Derived datatypes Next: Lower-bound and upper-bound markers Previous: Datatype constructors

The displacements in a general datatype are relative to some initial buffer address. Absolute addresses can be substituted for these displacements: we treat them as displacements relative to ``address zero,'' the start of the address space. This initial address zero is indicated by the constant MPI_BOTTOM. Thus, a datatype can specify the absolute address of the entries in the communication buffer, in which case the buf argument is passed the value MPI_BOTTOM.

The address of a location in memory can be found by invoking the function
MPI_ADDRESS.

MPI_ADDRESS(location, address)
[ IN location] location in caller memory (choice)
[ OUT address] address of location (integer)

int MPI_Address(void* location, MPI_Aint *address)

MPI_ADDRESS(LOCATION, ADDRESS, IERROR)
<type> LOCATION(*)
INTEGER ADDRESS, IERROR

Returns the (byte) address of location.


  
 
Using  MPI_ADDRESS for an array. 

REAL A(100,100) 
   INTEGER I1, I2, DIFF 
   CALL MPI_ADDRESS(A(1,1), I1, IERROR) 
   CALL MPI_ADDRESS(A(10,10), I2, IERROR) 
   DIFF = I2 - I1 
! The value of DIFF is 909*sizeofreal; the values of I1 and I2 are 
! implementation dependent. 

[] Advice to users.

C users may be tempted to avoid the usage of MPI_ADDRESS and rely on the availability of the address operator &amp;. Note, however, that &amp; cast-expression is a pointer, not an address. ANSI C does not require that the value of a pointer (or the pointer cast to int) be the absolute address of the object pointed at --- although this is commonly the case. Furthermore, referencing may not have a unique definition on machines with a segmented address space. The use of MPI_ADDRESS to ``reference'' C variables guarantees portability to such machines as well. ( End of advice to users.)
The following auxiliary functions provide useful information on derived datatypes.

MPI_TYPE_EXTENT(datatype, extent)
[ IN datatype] datatype (handle)
[ OUT extent] datatype extent (integer)

int MPI_Type_extent(MPI_Datatype datatype, MPI_Aint *extent)

MPI_TYPE_EXTENT(DATATYPE, EXTENT, IERROR)
INTEGER DATATYPE, EXTENT, IERROR

Returns the extent of a datatype, where extent is as defined on page Lower-bound and upper-bound markers .

MPI_TYPE_SIZE(datatype, size)
[ IN datatype] datatype (handle)
[ OUT size] datatype size (integer)

int MPI_Type_size(MPI_Datatype datatype, int *size)

MPI_TYPE_SIZE(DATATYPE, SIZE, IERROR)
INTEGER DATATYPE, SIZE, IERROR

MPI_TYPE_SIZE returns the total size, in bytes, of the entries in the type signature associated with datatype; i.e., the total size of the data in a message that would be created with this datatype. Entries that occur multiple times in the datatype are counted with their multiplicity.



Up: Derived datatypes Next: Lower-bound and upper-bound markers Previous: Datatype constructors


Return to MPI Standard Index
Return to MPI home page