mpich
mpich copied to clipboard
Support Application Compile-time Selection of F90 Integer Size
I recently heard from an ALCF user that there might be some use cases where someone would want to be able to select the size of a Fortran 90 integer type at application compile time (as opposed to MPICH compile time, which is easier).
Apparently this is a feature that Intel MPI supports by passing -i8 to mpif90. However, I think the solution used there won't work in today's MPICH anymore because of the way the binding generation has changed. So a program like this:
program main
use mpi
integer error
integer :: sml_comm = 0
!
! Initialize MPI.
!
call MPI_Init ( error )
call mpi_comm_dup(mpi_comm_world,sml_comm,error)
call mpi_barrier( sml_comm, error )
!
! Shut down MPI.
!
call MPI_Finalize ( error )
stop
end
Would work when compiled like this:
$ mpifort -fc=ifx -i8 hello.F90
$ mpirun -n 1 ./a.out
However, instead of that, there's a segfault in the call to mpi_barrier.
I talked to @hzhou about this today and we think this would require some pretty big changes to the Fortran binding generation scripts to generate multiple versions of each MPI function along with some conversion functions to pick the right one.
This is probably a low priority issue unless someone champions it, but I wanted to capture the request here so we can have a discussion about whether or not this is worth implementing. Especially since this might just work with Fortran 2008 (or not, I'm not sure).
Apparently this is a feature that Intel MPI supports by passing -i8 to mpif90.
Note that MPICH can be built with either default INTEGER size 4 or INTEGER size 8 by setting appropriate compiler flags. However, this require the built mpich binary be consistent with the user binary, i.e. with the same integer sizes. A easy solution is to build both versions, then use a compiler wrapper to pick the correct one at compile time -- I suspect this is the solution taken by Intel Suite. Since we don't have control over the compiler, the same solution won't work for us.
I talked to @hzhou about this today and we think this would require some pretty big changes to the Fortran binding generation scripts to generate multiple versions of each MPI function along with some conversion functions to pick the right one.
I believe the generic interface feature from Fortran compiler might work. We'll need supply at least two versions of the binding routines for every MPI function and handle appropriate conversions inside the routines. Both use mpi and use mpi_f08 can work. It is fairly complex work, we'll need take care of both the build time type sizes and large count interfaces for several hundred API functions.
This is probably a low priority issue unless someone champions it
From the user point of view, it is just matter of picking the correct mpich binary. It appears relatively trivial to explicitly link with the correct one at build time. For example, system can provide an alternative module load option or user can build a custom mpich and link against it. Thus, I don't see the benefit of inflate the complexity of MPICH in a big way just to provide a small convenience for the user or system admin.
While this is user-friendly and I understand it's generous of Intel MPI to do it, it teaches Fortran programmers to do bad things.
Real Fortran experts like Bill Long will tell you that -i8 and similar are abominations and never shouldn't have been supported. If somebody wants an INTEGER*8 (or more correctly, an INTEGER(KIND=INT64)), they should use that.
Using the MPI F08 module with MPI-4 large count support is the right way for Fortran programmers to use MPI when they want larger integer to be supported.
I forwarded this discussion to Bill Long and he sent back this comment which might be of interest:
The mpi_f08 module should be written such that the Fortran interfaces for any routine with an integer argument are generic with specific versions for 32-bit integer and 64-bit integer. Inside the specific wrappers the code can be included to “cast down to C int” for arguments that are 64-bit, except for the COUNT arguments where the 64-bit count version of the C library routine should be called. Actually, this could be done for the mpi module as well as mpi_f08. The capabilities for handling this sort of thing in a module have been around long before f08.
I think when Bill said:
Actually, this could be done for the mpi module as well as mpi_f08.
I think he was saying the same could be done for the F90 "use mpi" module.
I don't disagree 😄 But it's quite a chore. If enough people are interested in this, it can be more motivated.
Sorry - should have said that I'm not advocating changes, just making you aware of a possible avenue if you decide to work on this area. Bill, on the other hand, would advocate making the changes, but then he's the Fortran guy ... 😄
I am working on a new implementation of MPI F08 that is completely separate from the MPI library. It should allow this sort of thing pretty easily. I don't know when it will be >50% complete but I might get to the features that most people actually use by the end of the year.
https://github.com/jeffhammond/standalone_mpi_f08_module
I don't know about the MPI (F90) module but I can think about doing that, too.