Skip to content

[feature request] packaging for multiple Fortran compilers #2056

Open
@jeffhammond

Description

@jeffhammond

Summary

Please support the ability to build Open-MPI Fortran bindings for multiple Fortran compilers in the same build. This will dramatically improve user experience.

I recognize this is not a small thing to implement, but at least two vendors do this already, and since some vendors use Open-MPI as the basis for their MPI product, it might be the sort of thing that makes sense for the project to support.

Alternative / Workaround

The current solution for multiple Fortran compilers is to build the MPI library once for every toolchain, e.g. one has installation directories open-mpi-intel15, open-mpi-intel16, open-mpi-gcc5, open-mpi-gcc6, etc. This naturally leads to mpi.mod and mpi_f08.mod for every Fortran compiler.

While simple, the current solution is a waste of sysadmin time, processor cycles, filesystem metadata, etc. given that one could instead build Open-MPI once with the preferred C compiler once and then support O(n) Fortran compiler wrappers and modules.

Future Workaround

In theory, there could be an implementation-agnostic implementation of the MPI Fortran 2008 bindings that could be compiled independent of the MPI C library, but such a project does not yet exist and in any case, very few users have adopted use mpi_f08.

Background

The Fortran bindings are largely if not completely independent of the internals of MPI, which are compiled with a C compiler, and C allows for a standard ABI. On the other hand, Fortran does not have a standard ABI and modules must be generated for every compiler vendor, and possibly also multiple (major) versions of the compiler from a single vendor.

Suggested implementation

  1. Allow the user to specify FCn for n=1,2,... as an alternative to FC. The build system would then generate MPI Fortran scripts named mpi$FC1, mpi$FC2, etc., assuming FCn do not have the full paths, otherwise they will be stripped.
  2. -enable-fortran-compilers=$FC1,$FC2. This is just different syntax for option 1.
  3. If it is too hard to do it simply, require a configuration file that describes the settings for each Fortran compiler explicitly.

Ideally, the user can do something like $PATH_TO_OMPI/configure FC1=ifort FC2=gfortran and get $OMPI_PREFIX/bin/mpiifort, $OMPI_PREFIX/bin/mpigfortran, $OMPI_PREFIX/include/ifort/mpi.mod, $OMPI_PREFIX/include/gfortran/mpi.mod, $OMPI_PREFIX/include/ifort/mpi_f08.mod, $OMPI_PREFIX/include/gfortran/mpi_f08.mod, and any companion files.

Prior Engineering / Proof-of-Principle

Intel MPI

Intel MPI packages the wrappers and modules for Intel Fortran and GNU Fortran.

$ mpiifort -show
ifort -I/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/include 
-I/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/include 
-L/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib/release_mt 
-L/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib -Xlinker 
--enable-new-dtags -Xlinker -rpath -Xlinker /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib/release_mt 
-Xlinker -rpath -Xlinker /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib 
-Xlinker -rpath -Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib/release_mt -Xlinker -rpath 
-Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib -lmpifort -lmpi -lmpigi -ldl -lpthread

$ mpifc -show
gfortran -I/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/include/gfortran/5.1.0 
-I/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/include 
-L/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib/release_mt 
-L/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib -Xlinker 
--enable-new-dtags -Xlinker -rpath -Xlinker /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib/release_mt 
-Xlinker -rpath -Xlinker /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib 
-Xlinker -rpath -Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib/release_mt -Xlinker -rpath 
-Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib -lmpifort -lmpi -lmpigi -ldl -lpthread

$ mpif90 -show
gfortran -I/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/include/gfortran/5.1.0 
-I/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/include 
-L/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib/release_mt 
-L/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib -Xlinker 
--enable-new-dtags -Xlinker -rpath -Xlinker /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib/release_mt 
-Xlinker -rpath -Xlinker /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib 
-Xlinker -rpath -Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib/release_mt -Xlinker -rpath 
-Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib -lmpifort -lmpi -lmpigi -ldl -lpthread

$ mpif77 -show
gfortran -I/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/include 
-L/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib/release_mt 
-L/opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib -Xlinker 
--enable-new-dtags -Xlinker -rpath -Xlinker /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib/release_mt 
-Xlinker -rpath -Xlinker /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/lib 
-Xlinker -rpath -Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib/release_mt -Xlinker -rpath 
-Xlinker /opt/intel/mpi-rt/2017.0.0/intel64/lib -lmpifort -lmpi -lmpigi -ldl -lpthread

$ ll /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/include
total 2.0M
drwxr-xr-x 11 jrhammon root 4.0K Mar 16 16:41 gfortran
drwxr-xr-x  3 jrhammon root 4.0K Mar 16 16:41 ilp64
-rw-r--r--  1 jrhammon root 5.3K Mar  2  2016 i_malloc.h
-rw-r--r--  1 jrhammon root 116K Mar  2  2016 mpi_base.mod
-rw-r--r--  1 jrhammon root  51K Mar  2  2016 mpi_constants.mod
-rw-r--r--  1 jrhammon root 103K Mar  2  2016 mpicxx.h
-rw-r--r--  1 jrhammon root  32K Mar  2  2016 mpi_f08_callbacks.mod
-rw-r--r--  1 jrhammon root  81K Mar  2  2016 mpi_f08_compile_constants.mod
-rw-r--r--  1 jrhammon root 8.6K Mar  2  2016 mpi_f08_link_constants.mod
-rw-r--r--  1 jrhammon root 645K Mar  2  2016 mpi_f08.mod
-rw-r--r--  1 jrhammon root  49K Mar  2  2016 mpi_f08_types.mod
-rw-r--r--  1 jrhammon root  23K Mar  2  2016 mpif.h
-rw-r--r--  1 jrhammon root 131K Mar  2  2016 mpi.h
-rw-r--r--  1 jrhammon root  11K Mar  2  2016 mpi.mod
-rw-r--r--  1 jrhammon root 4.1K Mar  2  2016 mpiof.h
-rw-r--r--  1 jrhammon root  26K Mar  2  2016 mpio.h
-rw-r--r--  1 jrhammon root 8.8K Mar  2  2016 mpi_sizeofs.mod
-rw-r--r--  1 jrhammon root 656K Mar  2  2016 pmpi_f08.mod

$ ll /opt/intel/compilers_and_libraries_2017.0.036/linux/mpi/intel64/include/gfortran/5.1.0
total 52K
-rw-r--r-- 1 jrhammon root  13K Mar  2  2016 mpi_base.mod
-rw-r--r-- 1 jrhammon root 7.9K Mar  2  2016 mpi_constants.mod
-rw-r--r-- 1 jrhammon root  23K Mar  2  2016 mpi.mod
-rw-r--r-- 1 jrhammon root 1.2K Mar  2  2016 mpi_sizeofs.mod

IBM Blue Gene/Q

IBM supported this on Blue Gene/Q. I do not know the implementation details but can demonstrate the results if anyone needs to see it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions