Print

Print


I would argue that in the strictest interpretation, that the correspondence of the _types_ does not necessarily hold.    E.g., a processor could offer more than one real with 32 bits of storage.      But C_FLOAT, C_DOUBLE, etc should always correspond to the MPI types.   (Have to use a bit of theorem proving and the fact that MPI is implemented in C under the hood.)

OTOH, unless one is doing reductions in MPI, the storage size is all that matters.   And on this issue, both standards are rather explicit about the number of bits involved in each type.

And then there is the pragmatic answer:  all current and foreseeable hardware implementations have the same representations for most of the types that you listed.    But when you get to the types that are not supported in HW, e.g., REAL128 on current generation architectures,  it is not impossible to imagine a Fortran compiler that implements IEEE 128 bit reals while the MPI library uses a double-double representations.    Reductions might be very “interesting" in that scenario, but I would expect no problems with any other MPI operations.  

- Tom






> On Feb 27, 2018, at 3:54 AM, Anton Shterenlikht <[log in to unmask]> wrote:
> 
> The MPI spec:
> 	http://mpi-forum.org/docs/mpi-3.1/mpi31-report.pdf
> says that:
> 
> MPI_INTEGER1  corresponds to INTEGER*1
> MPI_INTEGER2  corresponds to INTEGER*2
> MPI_INTEGER4  corresponds to INTEGER*4
> MPI_INTEGER8  corresponds to INTEGER*8
> MPI_INTEGER16 corresponds to INTEGER*16
> 
> (Secs. 3.2.2, A.1) which is not completely portable.
> 
> However, it also says, in 13.5.3 User-Defined Data Representations,
> that these optional types have the following lengths in bytes:
> 
> MPI_INTEGER1  1 
> MPI_INTEGER2  2
> MPI_INTEGER4  4
> MPI_INTEGER8  8
> MPI_INTEGER16 16
> 
> It further says explicitly in 17.1. FORTRAN SUPPORT,
> Support for Size-specific MPI Datatypes:
> 
> "...MPI_<TYPE>n in C and Fortran where <TYPE> is one of REAL, INTEGER
> and COMPLEX, and n is the length in bytes of the machine representation."
> 
> which suggests therefore that these MPI datatypes
> *always* correspond to F2008 named constants for integer kinds as:
> 
> MPI_INTEGER1  int8
> MPI_INTEGER2  int16
> MPI_INTEGER4  int32
> MPI_INTEGER8  int64
> 
> MPI_INTEGER16 ---- ?
> 
> This mapping does seem to work in my limited tests, but...
> 
> My question - can the program logic rely
> on int8 *always* matching MPI_INTEGER1, etc. or
> am I missing some other assumptions or corner cases?
> 
> And for real kinds - is it *always* true that e.g.
> real32 kind will match MPI_REAL4, etc.?
> 
> Thanks
> 
> Anton