Datatypes encode the same information in all languages. E.g., a datatype accessor like MPI_TYPE_GET_EXTENT will return the same information in all languages. If a datatype defined in one language is used for a communication call in another language, then the message sent will be identical to the message that would be sent from the first language: the same communication buffer is accessed, and the same representation conversion is performed, if needed. All predefined datatypes can be used in datatype constructors in any language. If a datatype is committed, it can be used for communication in any language.
The function MPI_GET_ADDRESS returns the same value in
all languages. Note that we do not require that the
constant MPI_BOTTOM have the same value in all languages (see
4.12.9, page ).
! FORTRAN CODE REAL R(5) INTEGER TYPE, IERR INTEGER (KIND=MPI_ADDRESS_KIND) ADDR ! create an absolute datatype for array R CALL MPI_GET_ADDRESS( R, ADDR, IERR) CALL MPI_TYPE_CREATE_STRUCT(1, 5, ADDR, MPI_REAL, TYPE, IERR) CALL C_ROUTINE(TYPE)
/* C code */ void C_ROUTINE(MPI_Fint *ftype) { int count = 5; int lens[2] = {1,1}; MPI_Aint displs[2]; MPI_Datatype types[2], newtype; /* create an absolute datatype for buffer that consists */ /* of count, followed by R(5) */ MPI_Get_address(&count, &displs[0]); displs[1] = 0; types[0] = MPI_INT; types[1] = MPI_Type_f2c(*ftype); MPI_Type_create_struct(2, lens, displs, types, &newtype); MPI_Type_commit(&newtype); MPI_Send(MPI_BOTTOM, 1, newtype, 1, 0, MPI_COMM_WORLD); /* the message sent contains an int count of 5, followed */ /* by the 5 REAL entries of the Fortran array R. */ }
It may be desirable to use a value other than zero for MPI_BOTTOM even in C/C++, so as to distinguish it from a NULL pointer. If MPI_BOTTOM = c then one can still avoid the test buf = MPI_BOTTOM, by using the displacement from MPI_BOTTOM, i.e., the regular address - c, as the MPI-/ address returned by MPI_GET_ADDRESS and stored in absolute datatypes.(End of advice to implementors.)
MPI-Standard for MARMOT