Skip to content
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

Generate bigcount interfaces for Fortran and C #12226

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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.

ompi/mpi/fortran/use-mpi-f08/Makefile.am Outdated Show resolved Hide resolved

# JMS Somehow this variable substitution isn't quite working, and I
# don't have time to figure it out. So just wholesale copy the file
# list. :-(
#pmpi_api_files = $(mpi_api_files:%=profile/p%)
#pmpi_api_files = $(mpi_api_files:%=p%)
Copy link
Member

Choose a reason for hiding this comment

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

If you can figure out why this substitution isn't working, go ahead and uncomment it. Otherwise, it would probably be ok to delete this whole commented-out block.

ompi/include/mpi.h.in Outdated Show resolved Hide resolved
ompi/mpi/c/Makefile.am Show resolved Hide resolved
ompi/mpi/c/Makefile.am Show resolved Hide resolved
ompi/mpi/c/generate_bindings.py Outdated Show resolved Hide resolved
ompi/mpi/c/generate_bindings.py Outdated Show resolved Hide resolved
ompi/mpi/c/generate_bindings.py Outdated Show resolved Hide resolved
args = parser.parse_args()

# Always add the header
print('/* THIS FILE WAS AUTOGENERATED BY ompi/mpi/c/abi.py. DO NOT EDIT BY HAND. */')
Copy link
Member

Choose a reason for hiding this comment

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

Additionally, it might be better to have a traditional --outfile=FILENAME kind of CLI arg that indicates the name of the file that you want to write to. This leaves stdout available for info/verbose/debug kinds of output.

* Functions requiring a bigcount implementation should have type COUNT in
place of MPI_Count or int for each count parameter. Bigcount functions will
be generated automatically for any function that includes a COUNT type.
"""
Copy link
Member

Choose a reason for hiding this comment

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

Please add a larger comment here at the top explaining the purpose of this script, and at least a high-level overview of what it does / how it works. This is a very large script; having an intro to it at the top would be most helpful to the reader (e.g., me).

@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

@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@open-mpi open-mpi deleted a comment from github-actions bot Nov 28, 2024
@jsquyres
Copy link
Member

we don't intend to address the lower level datatype issues in this PR.

Oh... how is this PR correct, then? If we have datatype size mismatches, the code isn't going to be correct.

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 made a bunch of nit-picky comments, some of which will be trivial to fix.

I think probably the only real substantial thing is the question about the compiler warnings / not attempting to address the changes needed by the underlying OMPI datatype functions. We'll need to figure that out -- we can't just ignore that.

ompi/mpi/fortran/use-mpi-f08/base/bigcount.h Show resolved Hide resolved
ompi/mpi/fortran/use-mpi-f08/base/bigcount.h Show resolved Hide resolved
docs/developers/bindings.rst Outdated Show resolved Hide resolved
@@ -57,436 +484,439 @@ ompi_HEADERS = $(headers)
endif

#
# List of all C files that have profile versions
# List of all C files that have profile versions (generated_*.c files were
# generated from prototype_sources above).
#
interface_profile_sources = \
Copy link
Member

Choose a reason for hiding this comment

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

Not critical, but is it possible to generate interface_profile_sources from prototype_sources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a way to do that with automake?

Copy link
Member

Choose a reason for hiding this comment

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

@jsquyres i think this is the last open conversation. do we need to do something in this PR or can this wait till a followup?

docs/developers/bindings.rst Outdated Show resolved Hide resolved
ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h.in Outdated Show resolved Hide resolved
ompi/mpi/bindings/ompi_bindings/c_type.py Show resolved Hide resolved
ompi/mpi/bindings/ompi_bindings/parser.py Show resolved Hide resolved
ompi/mpi/bindings/ompi_bindings/c_type.py Show resolved Hide resolved

@Type.add_type('TYPE_COPY_ATTR_FUNCTION', abi_type=['standard'])
class TypeTypeCopyAttrFunctionStandard(Type):
# TODO: This may require a special function to wrap the callback
Copy link
Member

Choose a reason for hiding this comment

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

All these attribute functions are still marked TODO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also for the standard ABI

Copy link
Member

@bosilca bosilca left a comment

Choose a reason for hiding this comment

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

Deleting the old API files and creating new ones that are 95% identical instead of renaming and altering the renamed file drops access to past history of the MPI API support. What is the reason for taking this approach and is this reason compensating the losing history drawback ?

@@ -33,21 +33,22 @@
*/

#if OMPI_SIZEOF_FORTRAN_INTEGER == SIZEOF_INT
#define OMPI_ARRAY_NAME_DECL(a) int *c_##a = NULL
Copy link
Member

Choose a reason for hiding this comment

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

The new macros are not doing anything.
How is a macro such as OMPI_ARRAY_FINT_2_INT_CLEANUP supposed to work now ? If I read this code correctly it will test if one of the arguments of the API, which is not allowed to be NULL by the standard, is NULL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is code that was pulled in from PR #10302, and indirectly from a branch by @ggouaillardet.


MOSTLYCLEANFILES = *.mod

CLEANFILES += *.i90

lib_LTLIBRARIES = lib@OMPI_LIBMPI_NAME@_usempif08.la
noinst_LTLIBRARIES = lib@OMPI_LIBMPI_NAME@_usempif08_profile.la
Copy link
Member

Choose a reason for hiding this comment

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

I would like to see an answer to your previous question as well. It will be educative for all OMPI developers to understand how will the profiling layer generated and build.

@hppritcha
Copy link
Member

Deleting the old API files and creating new ones that are 95% identical instead of renaming and altering the renamed file drops access to past history of the MPI API support. What is the reason for taking this approach and is this reason compensating the losing history drawback ?

actually one just needs to do

git log --follow name_of.c.in file

to get the history of a renamed file.

@hppritcha hppritcha force-pushed the bigcount branch 2 times, most recently from bfd0681 to cff5b03 Compare December 18, 2024 16:32
@hppritcha
Copy link
Member

uh oh. nvidia needs to be more disks!

hppritcha added a commit to hppritcha/ompi that referenced this pull request Jan 2, 2025
to take a count argument of type size_t.

related to open-mpi#12226

related to open-mpi#9194

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
hppritcha added a commit to hppritcha/ompi that referenced this pull request Jan 2, 2025
to take a count argument of type size_t.

related to open-mpi#12226

related to open-mpi#9194

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
hppritcha added a commit to hppritcha/ompi that referenced this pull request Jan 3, 2025
to take a count argument of type size_t.

related to open-mpi#12226

related to open-mpi#9194

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
hppritcha added a commit to hppritcha/ompi that referenced this pull request Jan 9, 2025
related to open-mpi#12226 and open-mpi#9194

remove incorrect and misleading comment about ompi_3buff_op_reduce.
See open-mpi#967

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
hppritcha added a commit to hppritcha/ompi that referenced this pull request Jan 10, 2025
related to open-mpi#12226 and open-mpi#9194

remove incorrect and misleading comment about ompi_3buff_op_reduce.
See open-mpi#967

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
jtronge and others added 3 commits February 3, 2025 08:42
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 <mphinney@lanl.gov>
Co-authored-by: Howard Pritchard <hppritcha@gmail.com>
Signed-off-by: Jake Tronge <jtronge@lanl.gov>
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 <gilles@rist.or.jp>
Co-authored-by: Howard Pritchard <howardp@lanl.gov>
Signed-off-by: Jake Tronge <jtronge@lanl.gov>
Signed-off-by: Jake Tronge <jtronge@lanl.gov>
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.

6 participants