mpi-forum / mpi-issues

Tickets for the MPI Forum
http://www.mpi-forum.org/
67 stars 8 forks source link

MPI_Type_size(MPI_INTEGER,..) with INTEGER size promotion #744

Open jeffhammond opened 1 year ago

jeffhammond commented 1 year ago

Problem

We do not prohibit the modification of Fortran INTEGER using compiler options.

I would like someone to explain to me how they think this should be implemented.

My contention is this is almost impossible to implement, and we should disallow it.

This program illustrates the problem. How do people think implementers can make it so that the output of this program depends on the compiler option used?

program main
  use mpi_f08
  implicit none
  integer :: size,ierr
  call MPI_Init(ierr)
  call MPI_Type_size(MPI_INTEGER,size,ierr)
  print*,size
  call MPI_Finalize(ierr)
end program main

To be clear, I know how to implement this, but it's tricky and requires Fortran 2003, which isn't something we assume with mpif.h or the MPI module.

Proposal

We should disallow modification of the size Fortran INTEGER in the MPI standard.

Changes to the Text

Impact on Implementations

Intel MPI has at least partial support for ILP64 in the MPI module (but not the MPI_F08 module). This would disallow that.

Impact on Users

Users like this feature but do not understand its implications. It has never been safe to use.

References and Pull Requests

jeffhammond commented 1 year ago

@jsquyres @RolfRabenseifner @hritzdorf you have any thoughts?

jeffhammond commented 1 year ago

Also, one can have the same program in C and somehow it has to know what Fortran compiler options were used. How does it know that?

I accept that one can implement this by having a separate MPI C library for each Fortran INTEGER option and the user is responsible for using the right everything throughout their build but is this really the world we want to live in?

How does this work when building C shared libraries? How do those know what Fortran compiler options are going to be used?

hritzdorf commented 1 year ago

(1) a mpicc compile time option is used or a C macro is defined

(2) The reason for this is, that it is a common Fortran compile/link option to expand the width of integers (and other kind of variables); for example gnu Fortran option: -fdefault-integer-8 A reason to use this option may be, that the numbers to be stored in integer variables are too large for 4 byte wide integers and the users don't want to manually change the entire code. In general, logical and real variables are also expanded to 8 byte wide variables if integer variables are expanded. NEC MPI supports this feature since many (> 25) years. Users asked for it.

(3) By using different library names or different directories. Linking of applications is done by the MPI Fortran compile/link script, which knows how to link the executable correctly.

jeffhammond commented 1 year ago

Okay, I am coming around to the need to have a C ABI for every possible INTEGER size on a platform.