Skip to content

Fixes to be able to compile MPICH testsuite #13192

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 1 commit into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/man-openmpi/man3/MPI_T_pvar_get_info.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ returned in the *bind* parameter may be one of the following:

* ``MPI_T_BIND_MPI_INFO``: MPI info object

For more information see MPI-3 section 14.3.2.
* ``MPI_T_BIND_MPI_SESSION``: MPI session

For more information see MPI-4 section 14.3.2.


NOTES
Expand Down
3 changes: 2 additions & 1 deletion ompi/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,8 @@ enum {
MPI_T_BIND_MPI_REQUEST,
MPI_T_BIND_MPI_WIN,
MPI_T_BIND_MPI_MESSAGE,
MPI_T_BIND_MPI_INFO
MPI_T_BIND_MPI_INFO,
MPI_T_BIND_MPI_SESSION
};

/*
Expand Down
4 changes: 3 additions & 1 deletion ompi/mpi/bindings/bindings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024 Triad National Security, LLC. All rights
# Copyright (c) 2024-2025 Triad National Security, LLC. All rights
# reserved.
#
# $COPYRIGHT$
Expand Down Expand Up @@ -31,6 +31,8 @@ def main():

# Fortran set up code
parser_fortran = subparsers.add_parser('fortran', help='subcommand for generating Fortran code')
parser_fortran.add_argument('--generate-ts-suffix', action="store_true",
help='generate ts suffixes for appropriate routines')
# Handler for generating actual code
subparsers_fortran = parser_fortran.add_subparsers()
parser_code = subparsers_fortran.add_parser('code', help='generate binding code')
Expand Down
39 changes: 25 additions & 14 deletions ompi/mpi/bindings/ompi_bindings/fortran.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024 Triad National Security, LLC. All rights
# Copyright (c) 2024-2025 Triad National Security, LLC. All rights
# reserved.
#
# $COPYRIGHT$
Expand All @@ -25,12 +25,13 @@
class FortranBinding:
"""Class for generating the binding for a single function."""

def __init__(self, prototype, out, template=None, bigcount=False):
def __init__(self, prototype, out, template=None, bigcount=False, needs_ts=False):
# Generate bigcount interface version
self.bigcount = bigcount
self.fn_name = template.prototype.name
self.out = out
self.template = template
self.needs_ts = needs_ts
self.parameters = []
for param in self.template.prototype.params:
self.parameters.append(param.construct(fn_name=self.fn_name,
Expand Down Expand Up @@ -117,7 +118,7 @@ def _print_fortran_header(self, is_interface=False):

def _print_fortran_subroutine(self):
"""Output the Fortran subroutine line."""
sub_name = util.fortran_f08_name(self.fn_name, bigcount=self.bigcount)
sub_name = util.fortran_f08_name(self.fn_name, bigcount=self.bigcount, needs_ts=self.needs_ts)
params = [param.name for param in self.parameters]
params.append(consts.FORTRAN_ERROR_NAME)
lines = util.break_param_lines_fortran(f'subroutine {sub_name}(', params, ')')
Expand All @@ -126,7 +127,7 @@ def _print_fortran_subroutine(self):

def _print_fortran_subroutine_end(self):
"""Output the Fortran end subroutine line."""
sub_name = util.fortran_f08_name(self.fn_name, bigcount=self.bigcount)
sub_name = util.fortran_f08_name(self.fn_name, bigcount=self.bigcount, needs_ts=self.needs_ts)
self.dump(f'end subroutine {sub_name}')

def dump_lines(self, line_text):
Expand Down Expand Up @@ -197,19 +198,23 @@ def print_f_source_header(out):
out.dump('#include "ompi/mpi/fortran/configure-fortran-output.h"')


def print_profiling_rename_macros(templates, out):
def print_profiling_rename_macros(templates, out, args):
"""Print macros for renaming functions for the profiling interface.

Previously hardcoded in mpi-f08-rename.h.
"""
out.dump('#if OMPI_BUILD_MPI_PROFILING')
for template in templates:
name = util.fortran_f08_name(template.prototype.name)
has_buffers = util.prototype_has_buffers(template.prototype)
needs_ts = has_buffers and args.generate_ts_suffix
name = util.fortran_f08_name(template.prototype.name, needs_ts=needs_ts)
out.dump(f'#define {name} P{name}')
# Check for bigcount version
if util.prototype_has_bigcount(template.prototype):
bigcount_name = util.fortran_f08_name(template.prototype.name, bigcount=True)
bigcount_name = util.fortran_f08_name(template.prototype.name, bigcount=True, needs_ts=needs_ts)
out.dump(f'#define {bigcount_name} P{bigcount_name}')
name = util.fortran_f08_generic_interface_name(template.prototype.name)
out.dump(f'#define {name} P{name}')
out.dump('#endif /* OMPI_BUILD_MPI_PROFILING */')


Expand All @@ -233,9 +238,9 @@ def print_c_source_header(out):
out.dump('#include "bigcount.h"')


def print_binding(prototype, lang, out, bigcount=False, template=None):
def print_binding(prototype, lang, out, bigcount=False, template=None, needs_ts=False):
"""Print the binding with or without bigcount."""
binding = FortranBinding(prototype, out=out, bigcount=bigcount, template=template)
binding = FortranBinding(prototype, out=out, bigcount=bigcount, template=template, needs_ts=needs_ts)
if lang == 'fortran':
binding.print_f_source()
else:
Expand All @@ -257,32 +262,38 @@ def generate_code(args, out):
if args.lang == 'fortran':
print_f_source_header(out)
out.dump()
print_profiling_rename_macros(templates, out)
print_profiling_rename_macros(templates, out, args)
out.dump()
else:
print_c_source_header(out)

for template in templates:
out.dump()
print_binding(template.prototype, args.lang, out, template=template)
has_buffers = util.prototype_has_buffers(template.prototype)
needs_ts = has_buffers and args.generate_ts_suffix
print_binding(template.prototype, args.lang, out, template=template, needs_ts=needs_ts)
if util.prototype_has_bigcount(template.prototype):
out.dump()
print_binding(template.prototype, args.lang, bigcount=True, out=out, template=template)
print_binding(template.prototype, args.lang, bigcount=True, out=out, template=template, needs_ts=needs_ts)


def generate_interface(args, out):
"""Generate the Fortran interface files."""
out.dump(f'! {consts.GENERATED_MESSAGE}')

templates = load_function_templates(args.prototype_files)
print_profiling_rename_macros(templates, out, args)

for template in templates:
ext_name = util.ext_api_func_name(template.prototype.name)
out.dump(f'interface {ext_name}')
binding = FortranBinding(template.prototype, template=template, out=out)
has_buffers = util.prototype_has_buffers(template.prototype)
needs_ts = has_buffers and args.generate_ts_suffix
binding = FortranBinding(template.prototype, template=template, needs_ts=needs_ts, out=out)
binding.print_interface()
if util.prototype_has_bigcount(template.prototype):
out.dump()
binding_c = FortranBinding(template.prototype, out=out, template=template,
bigcount=True)
needs_ts=needs_ts, bigcount=True)
binding_c.print_interface()
out.dump(f'end interface {ext_name}')
26 changes: 22 additions & 4 deletions ompi/mpi/bindings/ompi_bindings/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024 Triad National Security, LLC. All rights
# Copyright (c) 2024-2025 Triad National Security, LLC. All rights
# reserved.
#
# $COPYRIGHT$
Expand Down Expand Up @@ -67,11 +67,15 @@ def ext_api_func_name_profile(fn_name, bigcount=False):
return f'P{ext_api_func_name(fn_name, bigcount)}'


def fortran_f08_name(fn_name, bigcount=False):
"""Produce the final f08 name from base_name."""
def fortran_f08_name(fn_name, bigcount=False, needs_ts=False):
"""Produce the final f08 name from base_name. See section 19.2 of MPI 4.1 standard."""
suffix = '_c' if bigcount else ''
return f'MPI_{fn_name.capitalize()}_f08{suffix}'
ts = 'ts' if needs_ts else ''
return f'MPI_{fn_name.capitalize()}{suffix}_f08{ts}'

def fortran_f08_generic_interface_name(fn_name):
"""Produce the generic interface name from the base_name."""
return f'MPI_{fn_name.capitalize()}'

def break_param_lines_fortran(start, params, end):
"""Break paramters for a fortran call onto multiple lines.
Expand Down Expand Up @@ -147,3 +151,17 @@ def abi_internal_name(extname):
def prototype_has_bigcount(prototype):
"""Should this prototype have a bigcount version?"""
return any(param.type_name in BIGCOUNT_TYPE_NAMES for param in prototype.params)

BUFFER_TYPE_NAMES = [
'BUFFER',
'BUFFER_ASYNC',
'BUFFER_OUT',
'BUFFER_ASYNC_OUT',
]

def prototype_has_buffers(prototype):
"""Does the prototype have buffer arguments?"""
if any(param.type_name in BUFFER_TYPE_NAMES for param in prototype.params):
return True
else:
return False
5 changes: 5 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,17 @@ if OMPI_GENERATE_BINDINGS
include Makefile.prototype_files
template_files =${prototype_files:%=$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/%}

if OMPI_FORTRAN_HAVE_TS
gen_ts = --generate-ts-suffix
endif

api_f08_generated.F90: $(template_files)
$(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \
--builddir $(abs_top_builddir) \
--srcdir $(abs_top_srcdir) \
--output $(abs_builddir)/$@ \
fortran \
$(gen_ts) \
code \
--lang fortran \
--prototype-files $(template_files)
Expand Down
7 changes: 7 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,23 @@ if OMPI_GENERATE_BINDINGS
include ../Makefile.prototype_files
template_files =${prototype_files:%=$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/%}

if OMPI_FORTRAN_HAVE_TS
gen_ts = --generate-ts-suffix
endif


mpi-f08-interfaces-generated.h: $(template_files)
$(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \
--builddir $(abs_top_builddir) \
--srcdir $(abs_top_srcdir) \
--output $(abs_builddir)/$@ \
fortran \
$(gen_ts) \
interface \
--prototype-files $(template_files)

endif

# Delete generated file on maintainer-clean
MAINTAINERCLEANFILES = mpi-f08-interfaces-generated.h

Expand Down
2 changes: 1 addition & 1 deletion ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-rename.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
#define MPI_Ineighbor_allgatherv PMPI_Ineighbor_allgatherv
#define MPI_Ineighbor_alltoall_f08 PMPI_Ineighbor_alltoall_f08
#define MPI_Ineighbor_alltoall PMPI_Ineighbor_alltoall
#define MPI_Ineighbor_alltoallv_f08 PMPI_Ineighbor_alltoallv_init_f08
#define MPI_Ineighbor_alltoallv_f08 PMPI_Ineighbor_alltoallv_f08
#define MPI_Ineighbor_alltoallv PMPI_Ineighbor_alltoallv
#define MPI_Ineighbor_alltoallw_f08 PMPI_Ineighbor_alltoallw_f08
#define MPI_Ineighbor_alltoallw PMPI_Ineighbor_alltoallw
Expand Down
3 changes: 2 additions & 1 deletion ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
! Copyright (c) 2015-2020 Research Organization for Information Science
! and Technology (RIST). All rights reserved.
! Copyright (c) 2017-2018 FUJITSU LIMITED. All rights reserved.
! Copyright (c) 2019 Triad National Security, LLC. All rights
! Copyright (c) 2019-2025 Triad National Security, LLC. All rights
! reserved.
! $COPYRIGHT$
!
Expand All @@ -28,6 +28,7 @@
module pmpi_f08_interfaces

#include "mpi-f08-interfaces.h"
#include "mpi-f08-interfaces-generated.h"

! MPI_Wtick is not a wrapper function
!
Expand Down
4 changes: 2 additions & 2 deletions ompi/mpi/fortran/use-mpi-f08/pack_external_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015-2019 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2024 Triad National Security, LLC. All rights
* Copyright (c) 2024-2025 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
Expand All @@ -23,7 +23,7 @@

PROTOTYPE VOID pack_external(CHAR_ARRAY datarep, BUFFER x1, COUNT incount,
DATATYPE datatype, BUFFER x2,
COUNT outsize, AINT_COUNT_INOUT position)
AINT_COUNT outsize, AINT_COUNT_INOUT position)
{
int c_ierr;
MPI_Datatype c_datatype, c_type = PMPI_Type_f2c(*datatype);
Expand Down
9 changes: 4 additions & 5 deletions ompi/mpi/fortran/use-mpi-f08/unpack_external_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015-2019 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2024 Triad National Security, LLC. All rights
* Copyright (c) 2024-2025 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
Expand All @@ -21,15 +21,14 @@
* $HEADER$
*/

PROTOTYPE VOID unpack_external(CHAR_ARRAY datarep, BUFFER x1, COUNT insize,
PROTOTYPE VOID unpack_external(CHAR_ARRAY datarep, BUFFER x1, AINT_COUNT insize,
AINT_COUNT_INOUT position, BUFFER x2,
COUNT_OUT outcount, DATATYPE datatype)
{
int c_ierr;
MPI_Datatype c_datatype, c_type = PMPI_Type_f2c(*datatype);
char *inbuf = OMPI_CFI_BASE_ADDR(x1);
void *outbuf = OMPI_CFI_BASE_ADDR(x2);
int c_outcount = OMPI_FINT_2_INT(*outcount);

c_type = PMPI_Type_f2c(*datatype);

Expand All @@ -40,7 +39,7 @@ PROTOTYPE VOID unpack_external(CHAR_ARRAY datarep, BUFFER x1, COUNT insize,
return;
}

OMPI_CFI_2_C(x2, c_outcount, c_type, c_datatype, c_ierr);
OMPI_CFI_2_C(x2, *outcount, c_type, c_datatype, c_ierr);
if (MPI_SUCCESS != c_ierr) {
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
OMPI_ERRHANDLER_INVOKE(MPI_COMM_SELF, c_ierr, FUNC_NAME);
Expand All @@ -51,7 +50,7 @@ PROTOTYPE VOID unpack_external(CHAR_ARRAY datarep, BUFFER x1, COUNT insize,
*insize,
position,
OMPI_F2C_BOTTOM(outbuf),
c_outcount,
*outcount,
c_datatype);
if (c_datatype != c_type) {
ompi_datatype_destroy(&c_datatype);
Expand Down