Skip to content

Add missing functions to Fortran use_mpi interface - #14219

Merged
hppritcha merged 1 commit into
open-mpi:mainfrom
N00byKing:missing_funcs
Aug 10, 2026
Merged

Add missing functions to Fortran use_mpi interface#14219
hppritcha merged 1 commit into
open-mpi:mainfrom
N00byKing:missing_funcs

Conversation

@N00byKing

Copy link
Copy Markdown
Contributor

There's currently two closely related bugs.

The PMPI define for MPI_Status_set_elements is defined in pmpi-ignore-tkr-interfaces.h but the actual interface is in mpi-ignore-tkr-interfaces-generated.h.
Then, in mpi-ignore-tkr.F90 both are included in that order. This leads to the preprocessor overwriting MPI_Status_set_elements with the PMPI version, and the normal one is omitted entirely.
This is fixed by the first commit which just removes the superfluous define.

Then, for the functions in mpi-ignore-tkr-interfaces-generated.h, no PMPI interface versions are being generated at the moment, since the define in that header is unused.
In the second commit, I include that header again in mpi-ignore-tkr.F90 with the define to ensure the PMPI interfaces are in the final output.

I'm a bit unsure about the second commit, would be grateful for a deeper look.

@hppritcha

Copy link
Copy Markdown
Member

You should only need the first commit to fix this problem. The correct interfaces for both PMPI and MPI should be defined in the generated mpi-ignore-tkr-interfaces-generated.h.

@N00byKing

Copy link
Copy Markdown
Contributor Author

mpi-ignore-tkr-interfaces-generated.h only creates a list of defines, guarded by OMPI_BUILD_MPI_PROFILING, for MPI->PMPI, not any new interfaces.
But as far as I can tell OMPI_BUILD_MPI_PROFILING is unused for use-mpi-ignore-tkr, and so without that commit none of these functions are getting a PMPI interface (The commit might still be the wrong fix though).

As for the build failure, it looks like there's something else broken with the _FTS suffixed functions. I'm taking a look now.

@github-actions

Copy link
Copy Markdown

Hello! The Git Commit Checker CI bot found a few problems with this PR:

222ee8b: use-mpi: Generate and compile _FTS C glue

  • check_signed_off: does not contain a valid Signed-off-by line

be3d6f6: use-mpi: Make sure PMPI rename exists for interfac...

  • check_signed_off: does not contain a valid Signed-off-by line

096e959: use-mpi: Regen interfaces if python generator modi...

  • check_signed_off: does not contain a valid Signed-off-by line

Please fix these problems and, if necessary, force-push new commits back up to the PR branch. Thanks!

@N00byKing

N00byKing commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

So it looks like I stumbled into a rabbit hole...

With the second commit of this PR I added interfaces for the PMPI versions of all generated use-mpi-ignore-tkr functions,
including MPI_Comm_attach_buffer_FTS and MPI_Session_attach_buffer_FTS.
However, the python print_profiling_rename_macros function is broken for f90.
It currently adds a define like this:

#define MPI_Comm_attach_buffer_FTS PMPI_Comm_attach_buffer_FTS

But the interface does not have the _FTS suffix, which leads to:

interface MPI_Session_attach_buffer
subroutine PMPI_Session_attach_buffer_FTS(session, &

Which is incorrect, and leads to multiple equivalent interface names, one for (P)MPI each but with the same interface name.

Correct example from f08:

#define MPI_Accumulate_f08ts PMPI_Accumulate_f08ts
#define MPI_Accumulate_c_f08ts PMPI_Accumulate_c_f08ts
#define MPI_Accumulate PMPI_Accumulate

Meaning a define for the TS, big, and interface name each.

The reason for that is because its gated away in fortran.py explicitly:

if gen_f90 == False:
    name = util.fortran_f08_generic_interface_name(template.prototype.name)
    out.dump(f'#define {name} P{name}')

I'm pretty sure this is to get the non _f08 suffixed name for f08, but it ignores the _FTS suffix for f90.

I've added a commit (a76e35e) which fixes this by collecting all required names (TS, big and interface if interface != TS),
then emits the define for each.

But when testing this, I got another error.
It turns out the two _FTS functions are not being compiled, and prior to this PR they seem to already be broken and cause linker errors.
They need a generated c source similar to how f08 does it (calling bindings.py with code instead of interface), which is currently not being created.
So on main using these two functions will give you a linker error.

I've essentially recreated the f08 setup in f90 in commit 2b711dc in order to get this to work.

Finally, b6a6731 just makes sure that the generated interface is recreated if the script is modified, which tripped me up a few times.

@N00byKing
N00byKing force-pushed the missing_funcs branch 2 times, most recently from 4c8bdfa to c081483 Compare July 29, 2026 13:42
@hppritcha

Copy link
Copy Markdown
Member

@devreal could you do a co-pilot scan on this PR?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes missing / incorrect Fortran use mpi (ignore-TKR) interfaces by correcting an unintended MPI_...PMPI_... macro substitution for MPI_Status_set_elements, and by ensuring PMPI variants are generated for the set of interfaces coming from mpi-ignore-tkr-interfaces-generated.h. It also extends the bindings generator and build system to generate/compile the needed TS-related Fortran/C glue code for the ignore-TKR mpi module.

Changes:

  • Remove the stray MPI_Status_set_elements profiling rename macro that caused the non-PMPI interface to be omitted.
  • Include mpi-ignore-tkr-interfaces-generated.h a second time with OMPI_BUILD_MPI_PROFILING=1 so PMPI interfaces are emitted for the generated interface set.
  • Add new build targets/subdir to generate and build F90/C wrapper code for TS routines (plus generator updates, config wiring, and ignore patterns).

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ompi/mpi/fortran/use-mpi-ignore-tkr/pmpi-ignore-tkr-interfaces.h Removes the problematic MPI_Status_set_elementsPMPI_Status_set_elements macro mapping.
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr.F90 Includes the generated interfaces twice (second time under profiling macro) to produce both MPI and PMPI interfaces.
ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am Adds generation/compilation of api_f90_generated.F90 and links in new helper libs; tightens generator dependencies.
ompi/mpi/fortran/use-mpi-ignore-tkr/base/Makefile.am New subdir to compile generated C wrapper code with non-zeroed CPPFLAGS/AM_CPPFLAGS.
ompi/mpi/bindings/ompi_bindings/util.py Renames/expands generic-interface naming helper used by the generator.
ompi/mpi/bindings/ompi_bindings/fortran.py Updates wrapper naming for f90 vs f08, profiling macro emission, include paths, and f90 generation filtering.
ompi/mpi/bindings/ompi_bindings/fortran_type.py Adjusts handle argument passing for f90-generated bindings (integers vs %MPI_VAL).
ompi/Makefile.am Adds the new ignore-tkr base/ subdir to the build ordering.
config/ompi_config_files.m4 Ensures base/Makefile is configured/generated.
.gitignore Ignores newly generated ignore-tkr base C files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am
@hppritcha

Copy link
Copy Markdown
Member

This PR looks good to me modulo the copilot finding above and something I noticed in examining the generated api_f90_generated.F90. Namely the 'x' arguments i think should really be replaced by the proper argument name in the standard to allow for keyword argument asociation. Fixing this would involve updating line 363 in fortran.py, but the comments above that line give me pause. See 86c5eab . i'm not sure that comment is right for use mpi.

@jsquyres jsquyres left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review Summary

Verdict: COMMENT

Findings (3 validated from 12 raw)

  • Agreed (cross-source): 0
  • v3-reviewer: 3
  • Description accuracy: 0

Filter Pipeline

  • Dropped (no quote): 0
  • Dropped (hallucination): 0 (path: 0, quote: 0, deleted: 0)
  • Suppressed (dedup): 1
  • Dropped (below cutoff): 8

v3-reviewer

[Bugs and logic errors | MEDIUM] ompi/mpi/bindings/ompi_bindings/fortran.py:302see inline comment

[Architecture and design patterns | MEDIUM] ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am:86see inline comment

[Bugs and logic errors | MEDIUM] ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am:96see inline comment

Comment thread ompi/mpi/bindings/ompi_bindings/fortran.py Outdated
Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am Outdated
Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am
@github-actions

Copy link
Copy Markdown

Hello! The Git Commit Checker CI bot found a few problems with this PR:

6d2460f: use-mpi: Use standard dummy param names for genera...

  • check_signed_off: does not contain a valid Signed-off-by line

Please fix these problems and, if necessary, force-push new commits back up to the PR branch. Thanks!

@N00byKing

Copy link
Copy Markdown
Contributor Author

I've modified the pympi parsing to apply to f90 as well, so now the x parameters in the interfaces are gone.
Well, more accurately would be gone if pympi had the definitions for {comm,session}_attach_buffer.
For that to actually happen #14216 would have to land, but it worked fine when manually updating the submodule.
Since this PR also works without the update to pympi, it doesn't block on #14216 though, and it will just work once the submodule is updated.
Regarding the comment, I'm pretty sure its just that it wasn't implemented yet, since keyword params worked in testing and the other callsite in L396 just says that f90 was "out of scope".

The other review comments should be addressed as well (f08 leaking into the generated header, Makefile deps + nodist removed).

@jsquyres jsquyres left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review Summary

Verdict: COMMENT

Findings (3 validated from 14 raw)

  • Agreed (cross-source): 0
  • v3-reviewer: 3
  • Description accuracy: 0

Filter Pipeline

  • Dropped (no quote): 0
  • Dropped (hallucination): 0 (path: 0, quote: 0, deleted: 0)
  • Suppressed (dedup): 2
  • Dropped (below cutoff): 9

Warnings

  • Agents failed: codex-reviewer
  • Degraded — codex-reviewer: stalled (no new output within the idle window) — treated as timed out

v3-reviewer

[Cross-file consistency | MEDIUM] ompi/mpi/fortran/use-mpi-ignore-tkr/pmpi-ignore-tkr-interfaces.h:266see inline comment

[Edge cases and error handling | MEDIUM] ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr.F90:56see inline comment

[Test coverage | MEDIUM] ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am:180see inline comment

Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/pmpi-ignore-tkr-interfaces.h
Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr.F90 Outdated
Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am
@N00byKing

N00byKing commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Addressed review comments regarding the makefile.

As for the testing infra, I'm splitting that up into a separate PR.
First, this one is getting bloated (It was supposed to be a quick -1 line PR...).
More importantly, check_f08_names.py fails if it doesn't find the interface in pympistd.
If I add the check without #14216, it will fail, and thus this PR becomes dependant on #14216.
Finally, when I did modify the check, I actually did find some inconsistencies in the handwritten portion of use-mpi.
So all of that + bugfixes will go in the separate PR.

EDIT: See #14229

hppritcha
hppritcha previously approved these changes Aug 1, 2026
@hppritcha
hppritcha requested a review from jsquyres August 1, 2026 15:17

@jsquyres jsquyres left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review Summary

Verdict: COMMENT

Findings (1 validated from 17 raw)

  • Agreed (cross-source): 0
  • v3-reviewer: 1
  • Description accuracy: 0

Filter Pipeline

  • Dropped (no quote): 0
  • Dropped (hallucination): 0 (path: 0, quote: 0, deleted: 0)
  • Suppressed (dedup): 0
  • Dropped (below cutoff): 16

v3-reviewer

[cross-file-consistency | MEDIUM] ompi/mpi/fortran/use-mpi-ignore-tkr/base/Makefile.am:44see inline comment

Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/base/Makefile.am

@jsquyres jsquyres left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

First off: apologies for the slow turnaround on this one, and thank you for your patience — I know this PR has been through several rounds already, and I appreciate you sticking with it. I'm sorry to come back with yet more build-system feedback; the ignore-TKR + TS plumbing is a genuinely subtle corner of the tree.

The good news: the core fix (removing the stray MPI_Status_set_elements PMPI define) looks correct to me — it was the only overlap between the PMPI define list and the generated prototypes — and the double-include profiling scheme holds together.

I've left three inline comments below: one linking concern and two Automake dependency/distribution concerns.

Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am
Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am Outdated
Comment thread ompi/mpi/fortran/use-mpi-ignore-tkr/base/Makefile.am Outdated
@N00byKing
N00byKing force-pushed the missing_funcs branch 2 times, most recently from 9d43b2e to fc8f108 Compare August 10, 2026 08:18
@hppritcha

Copy link
Copy Markdown
Member

@N00byKing would you mind squashing down to one commit? I'll rereview and merge after that.

@N00byKing
N00byKing force-pushed the missing_funcs branch 2 times, most recently from 699d1c1 to fc8f108 Compare August 10, 2026 15:28
MPI_Status_set_elements was not callable, and many PMPI versions were
missing entirely.

The MPI_{Comm/Session}_attach_buffer_FTS functions were also not
generated.

Signed-off-by: Yussur Mustafa Oraji <yussur.oraji@tu-darmstadt.de>
@N00byKing

Copy link
Copy Markdown
Contributor Author

Done

@hppritcha
hppritcha merged commit a9c7e07 into open-mpi:main Aug 10, 2026
27 checks passed
@hppritcha

Copy link
Copy Markdown
Member

/backport v6.0.x

@jsquyres

Copy link
Copy Markdown
Member

Thank you @N00byKing!

@N00byKing
N00byKing deleted the missing_funcs branch August 13, 2026 13:01
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.

4 participants