Joe Todd
Joe Todd

Reputation: 897

MPI_Double_Precision vs MPI_Real8

Is there a practical difference between MPI's MPI_REAL8 and MPI_DOUBLE_PRECISION? In other words, is there any modern machine architecture for which these two types aren't guaranteed to occupy the same amount of memory? Can they be used interchangeably?

Upvotes: 2

Views: 1025

Answers (1)

francescalus
francescalus

Reputation: 32451

MPI_REAL8 and MPI_DOUBLE_PRECISION are not interchangeable.

For one reason, MPI_REAL8 is an optional named constant and so may not exist in your implementation at all.

Beyond that, MPI_REAL8, if it exists, maps to a REAL*8 "Fortran" object, and MPI_DOUBLE_PRECISION maps to a DOUBLE PRECISION object. These needn't be the same thing: with gfortran consider the compile-time option -fdefault-real-8 and the following program:

 implicit none

 real*8 x
 double precision y

 print*, STORAGE_SIZE(x), STORAGE_SIZE(y)
end

More generally, you can use techniques in answer to this related question to avoid worrying about which MPI named constant to use for your Fortran objects.

Upvotes: 2

Related Questions