Skip to content

Generate bigcount interfaces for Fortran and C #12226

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

Merged
merged 3 commits into from
Mar 28, 2025
Merged

Conversation

jtronge
Copy link
Contributor

@jtronge jtronge commented Jan 10, 2024

This adds scripts for generating the C and Fortran mpi_f08 API bindings from template files, while also generating bigcount interfaces for those that require them. On the Fortran side it also adds support for TS 29113 when possible, allowing for better Fortran array handling that matches the standard (some files were imported from PR #10302).

Python >=3.6 is required for running these scripts, which is only necessary when the binding files have not already been generated. Users of the distribution tarball should not need to generate these files and thus should not require Python.

We used https://github.com/cea-hpc/pcvs-benchmarks and the MPI4PY test suite to help ensure all big count interfaces (C and Fortran) are being generated.

PR #12033 is a previous version of this focused specifically on ABI support.

Note that there are additional changes needed to Open MPI for bigcount support. One is that the datatype system needs to be embiggened. This PR includes workarounds for this lack of support that will need to be changed once the datatype system is embiggened. These areas of code are marked with TODO:BIGCOUNT.

Copy link
Member

@jsquyres jsquyres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't finished reading / understanding / reviewing both generate_bindings.py scripts yet, but since I'm so late for this and the clock is ticking on @jtronge's availability, I'm going to submit what I have so far.

@jsquyres
Copy link
Member

jsquyres commented Feb 7, 2024

Should #12033 be closed (if this PR wholly replaces it)?

@jtronge
Copy link
Contributor Author

jtronge commented Feb 7, 2024

I think I'll try to remove the extra standard ABI code from the script, as well as the additional items you caught @jsquyres.

I don't think this code completely replaces PR #12033, especially since that one includes the refactor of libmpi into multiple libraries that we discussed.

@jtronge
Copy link
Contributor Author

jtronge commented Feb 14, 2024

/azp run

@hppritcha
Copy link
Member

bot:ompi:retest

hppritcha added a commit to hppritcha/ompi that referenced this pull request Mar 19, 2025
for count args.

This helps with the big count effort.

Related to open-mpi#12226

Related to open-mpi#13152

Signed-off-by: Howard Pritchard <[email protected]>
Copy link
Member

@jsquyres jsquyres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replied to a few comments and resolved all the open conversations that I think are now actually resolved. I think my last concern is the question about: are we planning to ship the bigcount APIs without actually supporting big counts?

@hppritcha
Copy link
Member

Okay. We should put this discussion of what to do with the datatype support in one of our upcoming tuesday meetings. Meanwhile, I think this PR is good to go - modulo commit squashing. Its clear from the initial commit message that this was one of several pieces of work that need to be done before we can claim complete (or reasonably complete) support for big count. Also getting this in to main now will help flush out any problems it may cause well before we branch for the next major release. If there's some fundamental issue with providing bigcount support in the datatype engine we can modify the binding generating infrastructure to not generate the bigcount variants.

Note we've already merged other PRs for bigcount support that had this same problem with the datatype engine - see for example comments in #12621 .

jsquyres
jsquyres previously approved these changes Mar 23, 2025
Copy link
Member

@jsquyres jsquyres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's squash and merge.

@hppritcha
Copy link
Member

@jsquyres for some reason github lost your approval. could you please reapprove?

@devreal
Copy link
Contributor

devreal commented Mar 26, 2025

I tried to build this branch on my mac and get this error:

  GENERATE mpi-f08-interfaces-generated.h
Traceback (most recent call last):
  File "/Users/joseph/src/openmpi/git/ompi/build/ompi/mpi/fortran/use-mpi-f08/mod/../../../../../../ompi/mpi/bindings/bindings.py", line 75, in <module>
    main()
    ~~~~^^
  File "/Users/joseph/src/openmpi/git/ompi/build/ompi/mpi/fortran/use-mpi-f08/mod/../../../../../../ompi/mpi/bindings/bindings.py", line 71, in main
    args.handler(args, OutputFile(f))
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joseph/src/openmpi/git/ompi/build/ompi/mpi/fortran/use-mpi-f08/mod/../../../../../../ompi/mpi/bindings/bindings.py", line 43, in <lambda>
    parser_interface.set_defaults(handler=lambda args, out: fortran.generate_interface(args, out))
                                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/joseph/src/openmpi/git/ompi/build/../ompi/mpi/bindings/ompi_bindings/fortran.py", line 277, in generate_interface
    templates = load_function_templates(args.prototype_files)
  File "/Users/joseph/src/openmpi/git/ompi/build/../ompi/mpi/bindings/ompi_bindings/fortran.py", line 248, in load_function_templates
    SourceTemplate.load(fname, type_constructor=FortranType.construct)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joseph/src/openmpi/git/ompi/build/../ompi/mpi/bindings/ompi_bindings/parser.py", line 97, in load
    with open(fname) as fp:
         ~~~~^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '../accumulate_ts.c.in'
make[2]: *** [mpi-f08-interfaces-generated.h] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

Not sure what is going on, might be a python version issue.

➜  build git:(bigcount) python3 --version
Python 3.13.2

@devreal
Copy link
Contributor

devreal commented Mar 26, 2025

The path ../accumulate_ts.c.in seems suspicious. I'm doing an out-of-tree build so the build directory is located somewhere else than the ompi/mpi/fortran/use-mpi-f08/bindings directory where I assume the generator runs.

Copy link
Member

@jsquyres jsquyres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devreal I was just doing a VPATH build myself to confirm, but your reply beat me to it. Yeah, I'm guessing there's something not quite right in our Makefile.am substitution to create lists of input files. I.e., instead of making the files be ../BLAH, they'll need to be listed relative to the srcdir.

There's now a small conflict in a Makefile.am that needs to be resolved, too.

@hppritcha
Copy link
Member

out of path build should work. i checked that a week or so ago and IWFM

@hppritcha
Copy link
Member

of course that may have been prior to these numerous makefile refactors

@hppritcha
Copy link
Member

fixing your issue @devreal having problems with the rebase though so i'll push fix for your problem first. thanks for giving this PR a try.

@hppritcha
Copy link
Member

@devreal try now

This adds scripts for generating the C API bindings from template files,
while also generating bigcount interfaces for those that require them.
The binding script also include initial support for the mpi_f08 Fortran
bindings, but doesn't yet make any changes to fortran/use-mpi-f08

Python >=3.6 is required for running these scripts, which is only
necessary when the binding files have not already been generated.
Users of the distribution tarball should not need to generate these
files and thus should not require Python.

Note that there are additional changes needed to Open MPI for bigcount support.
One is that the datatype system needs to be embiggened.  This
PR includes workarounds for this lack of support that will need to
be changed once the datatype system is embiggened.  These areas
of code are marked with TODO:BIGCOUNT.

Co-authored-by: mphinney1100 <[email protected]>
Co-authored-by: Howard Pritchard <[email protected]>
Signed-off-by: Jake Tronge <[email protected]>
Copy link
Contributor

@devreal devreal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm able to build it and the RMA API looks correct.

@bosilca
Copy link
Member

bosilca commented Mar 26, 2025

works with and without VPATH with both gcc and nv compilers. 👍

jtronge and others added 2 commits March 27, 2025 10:44
This updates fortran/use-mpi-f08 to generate most of the Fortran
bindings from a script and template files. It also adds support for
Fortran TS 29113 when possible, allowing for better Fortran array
handling that matches the standard.

The C files were imported from PR open-mpi#10302 and converted to templates to
be fed into the binding script.

Co-authored-by: Gilles Gouaillardet <[email protected]>
Co-authored-by: Howard Pritchard <[email protected]>
Signed-off-by: Jake Tronge <[email protected]>
@hppritcha
Copy link
Member

squashing a bit

@bosilca bosilca merged commit 92e1378 into open-mpi:main Mar 28, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants