Skip to content

a standalone MPI_F08 is painful without an ABI #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jeffhammond opened this issue Nov 29, 2022 · 8 comments
Closed

a standalone MPI_F08 is painful without an ABI #654

jeffhammond opened this issue Nov 29, 2022 · 8 comments
Assignees
Labels
had reading Completed the formal proposal reading mpi-6 For inclusion in the MPI 5.1 or 6.0 standard passed final vote Passed the final formal vote passed first vote Passed the first formal vote wg-abi ABI Working Group

Comments

@jeffhammond
Copy link
Member

jeffhammond commented Nov 29, 2022

Problem

I create a standalone implementation of the MPI F08 module to learn some things about writing language interfaces to MPI.

I worked around a lot of problems like hard-coding MPI_Status to the implementation ABI, which is easy enough to do, although would not be necessary with an ABI.

I can mostly deal with compile-time constants, using my own values and doing on-the-fly conversions back to the underlying implementation's C values.

The place where I cannot deal with this is in user-defined reductions. When I have my own reduction, it takes a datatype argument based on the Fortran type definition in my module. When I pass MPI_INTEGER in Fortran, it uses my compile-time constant (-1003), which is converted to the C value (MPICH's in this case is 1275069467 in decimal), because that is what I have to pass to the C call to MPI_Allreduce. The latter is what my user-defined reduction sees, which is not useful since my Fortran has no idea what the MPICH op % MPI_VAL means.

Because MPICH uses integers, I could hack this and do the back-conversion secretly in my F->C layer, only for user-defined reductions with built-in datatypes, although this won't work if MPICH checks the handle for validity. It also doesn't work with Open-MPI.

I can avoid this problem by doing such as reimplementing all the collectives from scratch in Fortran when user-defined reductions are involved, but that's unreasonable. Another workaround would be to generate a user-defined datatype on-the-fly when the user passes a built-in type with a user-defined reduction, which is probably what I'm going to do, but this should not be necessary.

Update: I can't do the on-the-fly type swap trick because then user code won't get the type they passed at the command-line, so if they have logic to check that (which is common), it's going break.

Proposal

This is one of many reasons we should have an ABI. The MPI F08 module was designed to be implementable as a standalone component, but we have failed to make that possible, which means that our ecosystem requires one to compile an entire MPI implementation from scratch just to get a Fortran module, which is an awful user experience because many platforms support multiple Fortran compilers, and building any MPI implementation from source is not quick (open-mpi/ompi#2056).

Changes to the Text

Impact on Implementations

Impact on Users

References and Pull Requests

@wesbland wesbland added the mpi-6 For inclusion in the MPI 5.1 or 6.0 standard label Nov 30, 2022
@wesbland wesbland added the wg-abi ABI Working Group label Nov 30, 2022
@github-project-automation github-project-automation bot moved this to To Do in MPI Next Mar 21, 2023
@wesbland wesbland added the scheduled first vote First vote is scheduled for the next meeting label Oct 31, 2024
@wesbland wesbland moved this from To Do to Had Reading in MPI Next Oct 31, 2024
@wesbland wesbland added had reading Completed the formal proposal reading scheduled reading Reading is scheduled for the next meeting scheduled no-no vote No-No vote is scheduled for the next meeting no-no and removed scheduled reading Reading is scheduled for the next meeting labels Oct 31, 2024
@wesbland wesbland added this to the December 2024 milestone Nov 7, 2024
@wesbland wesbland removed the no-no label Nov 7, 2024
@Wee-Free-Scot
Copy link

This part of the ABI goes beyond a pure ABI spec and adds new functions for converting handles.

@jeffhammond We had a question about those handle conversion procedures.

The C part of the ABI defines handles as incomplete struct pointers, for example, (struct MPI_ABI_Comm*), which makes them pointer-sized.

The conversion procedures require serialisation into int, which is not usually pointer-sized.

** Shouldn't these procedures use MPI_Aint instead?

This type is well-defined in Fortran and in C, so it should serve all the purposes of the conversion and it doesn't require 64bit->32bit conversion in either direction.

@jeffhammond
Copy link
Member Author

It does not work because of the definition of handles in Fortran, which are INTEGER, either raw or inside of a type.

@Wee-Free-Scot
Copy link

So, at some point, either inside these new functions or somewhere else, MPI will need to assign a 32-bit integer (possibly by hashing the 64-bit pointer) and recover the 64-bit pointer (possibly by looking up the 32-bit integer in a hash table)?

This is already needed (for implementations that have 64-bit handle types in C), so it is not a new requirement. Is that the line of argument?

@jeffhammond
Copy link
Member Author

Yes. This is a trivial modification of the API that requires no change to implementations, with the upside that the C ABI won't depend on the Fortran compiler configuration.

@wesbland
Copy link
Member

This passed a no-no vote.

Yes No Abstain
26 0 3

@wesbland wesbland removed scheduled no-no vote No-No vote is scheduled for the next meeting scheduled first vote First vote is scheduled for the next meeting labels Dec 13, 2024
@wesbland
Copy link
Member

This passed a 1st vote.

Yes No Abstain
23 0 6

@wesbland wesbland added the passed first vote Passed the first formal vote label Dec 13, 2024
@wesbland wesbland moved this from Had Reading to Passed 1st Vote in MPI Next Dec 13, 2024
@wesbland wesbland added the scheduled reading Reading is scheduled for the next meeting label Dec 16, 2024
@wesbland wesbland removed this from the December 2024 milestone Dec 16, 2024
@wesbland wesbland added scheduled no-no vote No-No vote is scheduled for the next meeting scheduled second vote Second vote is scheduled for the next meeting labels Dec 16, 2024
@wesbland
Copy link
Member

wesbland commented Jan 9, 2025

This passed a no-no vote.

Yes No Abstain
29 0 1

@wesbland wesbland removed scheduled no-no vote No-No vote is scheduled for the next meeting scheduled second vote Second vote is scheduled for the next meeting scheduled reading Reading is scheduled for the next meeting labels Jan 9, 2025
@wesbland
Copy link
Member

wesbland commented Jan 9, 2025

This passed a 2nd vote.

Yes No Abstain
28 0 2

@wesbland wesbland added the passed final vote Passed the final formal vote label Jan 9, 2025
@wesbland wesbland moved this from Passed 1st Vote to Passed 2nd Vote in MPI Next Jan 9, 2025
@wgropp wgropp closed this as completed Jan 13, 2025
@github-project-automation github-project-automation bot moved this from Passed 2nd Vote to Merged in MPI Next Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
had reading Completed the formal proposal reading mpi-6 For inclusion in the MPI 5.1 or 6.0 standard passed final vote Passed the final formal vote passed first vote Passed the first formal vote wg-abi ABI Working Group
Projects
Status: Merged
Development

No branches or pull requests

3 participants