diff --git a/docs/man-openmpi/man3/MPI_T_pvar_get_info.3.rst b/docs/man-openmpi/man3/MPI_T_pvar_get_info.3.rst index 3192bfa8312..1165d0c1630 100644 --- a/docs/man-openmpi/man3/MPI_T_pvar_get_info.3.rst +++ b/docs/man-openmpi/man3/MPI_T_pvar_get_info.3.rst @@ -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 diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index dfb31852048..ced7340baa2 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -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 }; /* diff --git a/ompi/mpi/bindings/bindings.py b/ompi/mpi/bindings/bindings.py index b2bf67f8bdf..951d651a74d 100644 --- a/ompi/mpi/bindings/bindings.py +++ b/ompi/mpi/bindings/bindings.py @@ -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$ @@ -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') diff --git a/ompi/mpi/bindings/ompi_bindings/fortran.py b/ompi/mpi/bindings/ompi_bindings/fortran.py index d35824965e0..cfe423904c2 100644 --- a/ompi/mpi/bindings/ompi_bindings/fortran.py +++ b/ompi/mpi/bindings/ompi_bindings/fortran.py @@ -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$ @@ -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, @@ -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, ')') @@ -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): @@ -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 */') @@ -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: @@ -257,17 +262,19 @@ 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): @@ -275,14 +282,18 @@ def generate_interface(args, out): 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}') diff --git a/ompi/mpi/bindings/ompi_bindings/util.py b/ompi/mpi/bindings/ompi_bindings/util.py index b8b9f1e7a46..68d03eaa563 100644 --- a/ompi/mpi/bindings/ompi_bindings/util.py +++ b/ompi/mpi/bindings/ompi_bindings/util.py @@ -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$ @@ -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. @@ -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 diff --git a/ompi/mpi/fortran/use-mpi-f08/Makefile.am b/ompi/mpi/fortran/use-mpi-f08/Makefile.am index 593feca0480..98e1826a1f4 100644 --- a/ompi/mpi/fortran/use-mpi-f08/Makefile.am +++ b/ompi/mpi/fortran/use-mpi-f08/Makefile.am @@ -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) diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am b/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am index 9a72cf2ee88..d851dd2301a 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am +++ b/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am @@ -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 diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-rename.h b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-rename.h index 1ed460e7259..ea8370f4b54 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-rename.h +++ b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-rename.h @@ -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 diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90 b/ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90 index 1089248c42b..72a45e57d61 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90 @@ -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$ ! @@ -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 ! diff --git a/ompi/mpi/fortran/use-mpi-f08/pack_external_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/pack_external_ts.c.in index fd8e77b47ac..ed9ad8608c3 100644 --- a/ompi/mpi/fortran/use-mpi-f08/pack_external_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/pack_external_ts.c.in @@ -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$ * @@ -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); diff --git a/ompi/mpi/fortran/use-mpi-f08/unpack_external_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/unpack_external_ts.c.in index adbf2e9e04c..4852a43bada 100644 --- a/ompi/mpi/fortran/use-mpi-f08/unpack_external_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/unpack_external_ts.c.in @@ -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$ * @@ -21,7 +21,7 @@ * $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) { @@ -29,7 +29,6 @@ PROTOTYPE VOID unpack_external(CHAR_ARRAY datarep, BUFFER x1, COUNT insize, 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); @@ -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); @@ -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);