Skip to content

Instantly share code, notes, and snippets.

@hzhou
Last active March 27, 2024 22:26
Show Gist options
  • Save hzhou/27f0682e0f15e3129524c7067c1d1a31 to your computer and use it in GitHub Desktop.
Save hzhou/27f0682e0f15e3129524c7067c1d1a31 to your computer and use it in GitHub Desktop.
MPI ABI discussion

Current ABI draft -

  • All fortran interop C API are included in MPI C ABI, e.g. MPI_INTEGER, MPI_Comm_f2c, MPI_F_STATUS_IGNORE
  • Jeff intended an MPI ABI implementation that does not depend on Fortran
  • Thus the ABI standard need fix all relevant Fortran ABIs
  • The key requirement: Fortran INTEGER is equivalent to C int, but also need fix all Fortran datatypes with C equivalents.
  • MPI C ABI need implement MPI_Comm_f2c etc. with a dictionary mechanism
  • MPI C ABI does not do any Fortran compiler checks, only via assumptions

My rejection:

  • MPI should not specifiy INTEGER is C int if Fortran doesn't say so
  • MPI Fortran binding should implement proper MPI Fortran inter-op, via compiler feature checks and value conversions if necessary.
  • A C-only MPI Fortran inter-op is useless. For example, to inter-op with Fortran INTEGER, just use MPI_Int.

My proposal:

  • Do not change any MPI API
  • MPI C ABI does not contain any Fortran parts
    • mpi_abi.h only contains non-fortran APIs
    • mpi.h includes mpi_abi.h + mpi_fort.h
    • libmpi_abi.so does not contain any Fortran related symbols
    • libmpifort.so contains or Fortran related symbols include Fortran interface and inter-op C APIs
  • Fortran related API is provided in header via an opt-in option and in linker via libmpifort.so

Examples

case 1: t.c is a C-only MPI code

$ mpicc -mpi-abi -o t t.c
# t will link with `libmpi_abi.so`

case 2: t.c is a C code that uses MPI_INTEGER (or MPI_Comm_f2c)

$ mpicc -mpi-abi -o t t.c
ERROR: name undefined

$ mpicc -mpi-abi -fort -o t t.c
# SUCCESS. t will link with `libmpifort.so libmpi_abi.so`

case 3: t.f is a FORTRAN code

$ mpifort -mpi-abi -o t t.f
# SUCCESS. t will link with `libmpifort.so libmpi_abi.so`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment