Skip to content

Commit 08ac1be

Browse files
authored
Merge pull request #13192 from hppritcha/mpich_fixes
Fixes to be able to compile MPICH testsuite
2 parents 176278f + 326ccbc commit 08ac1be

File tree

11 files changed

+76
-30
lines changed

11 files changed

+76
-30
lines changed

docs/man-openmpi/man3/MPI_T_pvar_get_info.3.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ returned in the *bind* parameter may be one of the following:
166166

167167
* ``MPI_T_BIND_MPI_INFO``: MPI info object
168168

169-
For more information see MPI-3 section 14.3.2.
169+
* ``MPI_T_BIND_MPI_SESSION``: MPI session
170+
171+
For more information see MPI-4 section 14.3.2.
170172

171173

172174
NOTES

ompi/include/mpi.h.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,8 @@ enum {
899899
MPI_T_BIND_MPI_REQUEST,
900900
MPI_T_BIND_MPI_WIN,
901901
MPI_T_BIND_MPI_MESSAGE,
902-
MPI_T_BIND_MPI_INFO
902+
MPI_T_BIND_MPI_INFO,
903+
MPI_T_BIND_MPI_SESSION
903904
};
904905

905906
/*

ompi/mpi/bindings/bindings.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 Triad National Security, LLC. All rights
1+
# Copyright (c) 2024-2025 Triad National Security, LLC. All rights
22
# reserved.
33
#
44
# $COPYRIGHT$
@@ -31,6 +31,8 @@ def main():
3131

3232
# Fortran set up code
3333
parser_fortran = subparsers.add_parser('fortran', help='subcommand for generating Fortran code')
34+
parser_fortran.add_argument('--generate-ts-suffix', action="store_true",
35+
help='generate ts suffixes for appropriate routines')
3436
# Handler for generating actual code
3537
subparsers_fortran = parser_fortran.add_subparsers()
3638
parser_code = subparsers_fortran.add_parser('code', help='generate binding code')

ompi/mpi/bindings/ompi_bindings/fortran.py

+25-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 Triad National Security, LLC. All rights
1+
# Copyright (c) 2024-2025 Triad National Security, LLC. All rights
22
# reserved.
33
#
44
# $COPYRIGHT$
@@ -25,12 +25,13 @@
2525
class FortranBinding:
2626
"""Class for generating the binding for a single function."""
2727

28-
def __init__(self, prototype, out, template=None, bigcount=False):
28+
def __init__(self, prototype, out, template=None, bigcount=False, needs_ts=False):
2929
# Generate bigcount interface version
3030
self.bigcount = bigcount
3131
self.fn_name = template.prototype.name
3232
self.out = out
3333
self.template = template
34+
self.needs_ts = needs_ts
3435
self.parameters = []
3536
for param in self.template.prototype.params:
3637
self.parameters.append(param.construct(fn_name=self.fn_name,
@@ -117,7 +118,7 @@ def _print_fortran_header(self, is_interface=False):
117118

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

127128
def _print_fortran_subroutine_end(self):
128129
"""Output the Fortran end subroutine line."""
129-
sub_name = util.fortran_f08_name(self.fn_name, bigcount=self.bigcount)
130+
sub_name = util.fortran_f08_name(self.fn_name, bigcount=self.bigcount, needs_ts=self.needs_ts)
130131
self.dump(f'end subroutine {sub_name}')
131132

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

199200

200-
def print_profiling_rename_macros(templates, out):
201+
def print_profiling_rename_macros(templates, out, args):
201202
"""Print macros for renaming functions for the profiling interface.
202203
203204
Previously hardcoded in mpi-f08-rename.h.
204205
"""
205206
out.dump('#if OMPI_BUILD_MPI_PROFILING')
206207
for template in templates:
207-
name = util.fortran_f08_name(template.prototype.name)
208+
has_buffers = util.prototype_has_buffers(template.prototype)
209+
needs_ts = has_buffers and args.generate_ts_suffix
210+
name = util.fortran_f08_name(template.prototype.name, needs_ts=needs_ts)
208211
out.dump(f'#define {name} P{name}')
209212
# Check for bigcount version
210213
if util.prototype_has_bigcount(template.prototype):
211-
bigcount_name = util.fortran_f08_name(template.prototype.name, bigcount=True)
214+
bigcount_name = util.fortran_f08_name(template.prototype.name, bigcount=True, needs_ts=needs_ts)
212215
out.dump(f'#define {bigcount_name} P{bigcount_name}')
216+
name = util.fortran_f08_generic_interface_name(template.prototype.name)
217+
out.dump(f'#define {name} P{name}')
213218
out.dump('#endif /* OMPI_BUILD_MPI_PROFILING */')
214219

215220

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

235240

236-
def print_binding(prototype, lang, out, bigcount=False, template=None):
241+
def print_binding(prototype, lang, out, bigcount=False, template=None, needs_ts=False):
237242
"""Print the binding with or without bigcount."""
238-
binding = FortranBinding(prototype, out=out, bigcount=bigcount, template=template)
243+
binding = FortranBinding(prototype, out=out, bigcount=bigcount, template=template, needs_ts=needs_ts)
239244
if lang == 'fortran':
240245
binding.print_f_source()
241246
else:
@@ -257,32 +262,38 @@ def generate_code(args, out):
257262
if args.lang == 'fortran':
258263
print_f_source_header(out)
259264
out.dump()
260-
print_profiling_rename_macros(templates, out)
265+
print_profiling_rename_macros(templates, out, args)
261266
out.dump()
262267
else:
263268
print_c_source_header(out)
264269

265270
for template in templates:
266271
out.dump()
267-
print_binding(template.prototype, args.lang, out, template=template)
272+
has_buffers = util.prototype_has_buffers(template.prototype)
273+
needs_ts = has_buffers and args.generate_ts_suffix
274+
print_binding(template.prototype, args.lang, out, template=template, needs_ts=needs_ts)
268275
if util.prototype_has_bigcount(template.prototype):
269276
out.dump()
270-
print_binding(template.prototype, args.lang, bigcount=True, out=out, template=template)
277+
print_binding(template.prototype, args.lang, bigcount=True, out=out, template=template, needs_ts=needs_ts)
271278

272279

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

277284
templates = load_function_templates(args.prototype_files)
285+
print_profiling_rename_macros(templates, out, args)
286+
278287
for template in templates:
279288
ext_name = util.ext_api_func_name(template.prototype.name)
280289
out.dump(f'interface {ext_name}')
281-
binding = FortranBinding(template.prototype, template=template, out=out)
290+
has_buffers = util.prototype_has_buffers(template.prototype)
291+
needs_ts = has_buffers and args.generate_ts_suffix
292+
binding = FortranBinding(template.prototype, template=template, needs_ts=needs_ts, out=out)
282293
binding.print_interface()
283294
if util.prototype_has_bigcount(template.prototype):
284295
out.dump()
285296
binding_c = FortranBinding(template.prototype, out=out, template=template,
286-
bigcount=True)
297+
needs_ts=needs_ts, bigcount=True)
287298
binding_c.print_interface()
288299
out.dump(f'end interface {ext_name}')

ompi/mpi/bindings/ompi_bindings/util.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 Triad National Security, LLC. All rights
1+
# Copyright (c) 2024-2025 Triad National Security, LLC. All rights
22
# reserved.
33
#
44
# $COPYRIGHT$
@@ -67,11 +67,15 @@ def ext_api_func_name_profile(fn_name, bigcount=False):
6767
return f'P{ext_api_func_name(fn_name, bigcount)}'
6868

6969

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

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

7680
def break_param_lines_fortran(start, params, end):
7781
"""Break paramters for a fortran call onto multiple lines.
@@ -147,3 +151,17 @@ def abi_internal_name(extname):
147151
def prototype_has_bigcount(prototype):
148152
"""Should this prototype have a bigcount version?"""
149153
return any(param.type_name in BIGCOUNT_TYPE_NAMES for param in prototype.params)
154+
155+
BUFFER_TYPE_NAMES = [
156+
'BUFFER',
157+
'BUFFER_ASYNC',
158+
'BUFFER_OUT',
159+
'BUFFER_ASYNC_OUT',
160+
]
161+
162+
def prototype_has_buffers(prototype):
163+
"""Does the prototype have buffer arguments?"""
164+
if any(param.type_name in BUFFER_TYPE_NAMES for param in prototype.params):
165+
return True
166+
else:
167+
return False

ompi/mpi/fortran/use-mpi-f08/Makefile.am

+5
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,17 @@ if OMPI_GENERATE_BINDINGS
435435
include Makefile.prototype_files
436436
template_files =${prototype_files:%=$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/%}
437437

438+
if OMPI_FORTRAN_HAVE_TS
439+
gen_ts = --generate-ts-suffix
440+
endif
441+
438442
api_f08_generated.F90: $(template_files)
439443
$(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \
440444
--builddir $(abs_top_builddir) \
441445
--srcdir $(abs_top_srcdir) \
442446
--output $(abs_builddir)/$@ \
443447
fortran \
448+
$(gen_ts) \
444449
code \
445450
--lang fortran \
446451
--prototype-files $(template_files)

ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am

+7
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,23 @@ if OMPI_GENERATE_BINDINGS
8282
include ../Makefile.prototype_files
8383
template_files =${prototype_files:%=$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/%}
8484

85+
if OMPI_FORTRAN_HAVE_TS
86+
gen_ts = --generate-ts-suffix
87+
endif
88+
89+
8590
mpi-f08-interfaces-generated.h: $(template_files)
8691
$(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \
8792
--builddir $(abs_top_builddir) \
8893
--srcdir $(abs_top_srcdir) \
8994
--output $(abs_builddir)/$@ \
9095
fortran \
96+
$(gen_ts) \
9197
interface \
9298
--prototype-files $(template_files)
9399

94100
endif
101+
95102
# Delete generated file on maintainer-clean
96103
MAINTAINERCLEANFILES = mpi-f08-interfaces-generated.h
97104

ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-rename.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@
407407
#define MPI_Ineighbor_allgatherv PMPI_Ineighbor_allgatherv
408408
#define MPI_Ineighbor_alltoall_f08 PMPI_Ineighbor_alltoall_f08
409409
#define MPI_Ineighbor_alltoall PMPI_Ineighbor_alltoall
410-
#define MPI_Ineighbor_alltoallv_f08 PMPI_Ineighbor_alltoallv_init_f08
410+
#define MPI_Ineighbor_alltoallv_f08 PMPI_Ineighbor_alltoallv_f08
411411
#define MPI_Ineighbor_alltoallv PMPI_Ineighbor_alltoallv
412412
#define MPI_Ineighbor_alltoallw_f08 PMPI_Ineighbor_alltoallw_f08
413413
#define MPI_Ineighbor_alltoallw PMPI_Ineighbor_alltoallw

ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
! Copyright (c) 2015-2020 Research Organization for Information Science
1111
! and Technology (RIST). All rights reserved.
1212
! Copyright (c) 2017-2018 FUJITSU LIMITED. All rights reserved.
13-
! Copyright (c) 2019 Triad National Security, LLC. All rights
13+
! Copyright (c) 2019-2025 Triad National Security, LLC. All rights
1414
! reserved.
1515
! $COPYRIGHT$
1616
!
@@ -28,6 +28,7 @@
2828
module pmpi_f08_interfaces
2929

3030
#include "mpi-f08-interfaces.h"
31+
#include "mpi-f08-interfaces-generated.h"
3132

3233
! MPI_Wtick is not a wrapper function
3334
!

ompi/mpi/fortran/use-mpi-f08/pack_external_ts.c.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2015-2019 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15-
* Copyright (c) 2024 Triad National Security, LLC. All rights
15+
* Copyright (c) 2024-2025 Triad National Security, LLC. All rights
1616
* reserved.
1717
* $COPYRIGHT$
1818
*
@@ -23,7 +23,7 @@
2323

2424
PROTOTYPE VOID pack_external(CHAR_ARRAY datarep, BUFFER x1, COUNT incount,
2525
DATATYPE datatype, BUFFER x2,
26-
COUNT outsize, AINT_COUNT_INOUT position)
26+
AINT_COUNT outsize, AINT_COUNT_INOUT position)
2727
{
2828
int c_ierr;
2929
MPI_Datatype c_datatype, c_type = PMPI_Type_f2c(*datatype);

ompi/mpi/fortran/use-mpi-f08/unpack_external_ts.c.in

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2015-2019 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15-
* Copyright (c) 2024 Triad National Security, LLC. All rights
15+
* Copyright (c) 2024-2025 Triad National Security, LLC. All rights
1616
* reserved.
1717
* $COPYRIGHT$
1818
*
@@ -21,15 +21,14 @@
2121
* $HEADER$
2222
*/
2323

24-
PROTOTYPE VOID unpack_external(CHAR_ARRAY datarep, BUFFER x1, COUNT insize,
24+
PROTOTYPE VOID unpack_external(CHAR_ARRAY datarep, BUFFER x1, AINT_COUNT insize,
2525
AINT_COUNT_INOUT position, BUFFER x2,
2626
COUNT_OUT outcount, DATATYPE datatype)
2727
{
2828
int c_ierr;
2929
MPI_Datatype c_datatype, c_type = PMPI_Type_f2c(*datatype);
3030
char *inbuf = OMPI_CFI_BASE_ADDR(x1);
3131
void *outbuf = OMPI_CFI_BASE_ADDR(x2);
32-
int c_outcount = OMPI_FINT_2_INT(*outcount);
3332

3433
c_type = PMPI_Type_f2c(*datatype);
3534

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

43-
OMPI_CFI_2_C(x2, c_outcount, c_type, c_datatype, c_ierr);
42+
OMPI_CFI_2_C(x2, *outcount, c_type, c_datatype, c_ierr);
4443
if (MPI_SUCCESS != c_ierr) {
4544
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
4645
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,
5150
*insize,
5251
position,
5352
OMPI_F2C_BOTTOM(outbuf),
54-
c_outcount,
53+
*outcount,
5554
c_datatype);
5655
if (c_datatype != c_type) {
5756
ompi_datatype_destroy(&c_datatype);

0 commit comments

Comments
 (0)