Skip to content

Commit 354fa83

Browse files
committed
SQUASHME: OMNIBUS COMMIT 3
add replacements to code bodies for various string lengths We now scan the generated internal 'c' body of each function for replaceable variants of MPI_MAX_DATAREP_STRING MPI_MAX_ERROR_STRING MPI_MAX_INFO_KEY MPI_MAX_INFO_VAL MPI_MAX_LIBRARY_VERSION_STRING MPI_MAX_OBJECT_NAME MPI_MAX_PORT_NAME MPI_MAX_PROCESSOR_NAME MPI_MAX_STRINGTAG_LEN MPI_MAX_PSET_NAME_LEN This way the code body sees the same constant values as the app sees using either the OMPI or ABI variants of the mpi.h add support for distrib array and order for subarray type datatype constructors add support for mode bits - in only add support for amode out add support for whence used by some MPI I/O functions add support for some win attributes handle special case of MPI_DISPLACEMENT_CURRENT add support for combiner, typeclass, win lock assert types c_header: comment out deprecated functions The ABI doesn't support any of the functions deprecated in MPI 3.1 or earlier. See section 20.2.1 of the MPI 5.0 standard. fix problem with special attrs for windows fix for win_shared_query fixes to rget/rget_accumulate fix problem with code gen for win create keyval fix rank problem in rput/raccumulate add MPI_GROUP_EMPTY to predefined group handles handle user error classes and codes temporary WAR for non-blocking alltoallw variants. We'll need to append the temporary arrays holding translated datatype handles to the nbc request for cleanup after the non-blocking op is completed or the persistent request has been freed. add support for comm topos support INOUT attribute for all handles thanks to dalcinl for help here fix problem with attribute callback handling need to convert the ompi internal keyval to abi one before invoking user supplied callbacks for win, type, comm catch use of special buffer consts like MPI_BUFFER_AUTOMATIC remove some debug statements swat nit patch get_address add new type to handle out void stars from buffer detach operations. fixes for datatypes for neighbor collectives add inouts for op, errhandler, info cleanup datatype tmps for ialltoallw and friends leverage nbc infrastructure a logical16 fix Thanks to dalcinl for finding. abi_get_version/get_info add to ompi abi lib and correction major/minor versoin returned from the ABI build. toint fixes thanks to dalcinl ! fix issue with ASYNC data arrays cleanup various fixes from dalcinl Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 0d648ce commit 354fa83

File tree

183 files changed

+1300
-484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+1300
-484
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ ompi/mpi/c/*_generated*.c
538538
ompi/mpi/c/standard_*.c
539539
ompi/mpi/c/abi.h
540540
ompi/mpi/c/abi_get_info.c
541+
ompi/mpi/c/abi_converters.h
541542
ompi/mpi/c/standard_abi
542543
ompi/mpi/tool/*_generated*.c
543544

ompi/include/mpi.h.in

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,9 +1453,8 @@ OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub;
14531453
/*
14541454
* MPI API
14551455
*/
1456-
OMPI_DECLSPEC int MPI_Abi_supported(int *flag);
1457-
OMPI_DECLSPEC int MPI_Abi_version(int *abi_major, int *abi_minor);
1458-
OMPI_DECLSPEC int MPI_Abi_details(int *buflen, char *details, MPI_Info *info);
1456+
OMPI_DECLSPEC int MPI_Abi_get_version(int *abi_major, int *abi_minor);
1457+
OMPI_DECLSPEC int MPI_Abi_get_info(MPI_Info *info);
14591458
OMPI_DECLSPEC int MPI_Abi_get_fortran_info(MPI_Info *info);
14601459
OMPI_DECLSPEC int MPI_Abi_set_fortran_info(MPI_Info info);
14611460
OMPI_DECLSPEC int MPI_Abi_get_fortran_booleans(int logical_size, void *logical_true, void *logical_false, int *is_set);
@@ -2656,9 +2655,8 @@ OMPI_DECLSPEC double MPI_Wtime(void);
26562655
/*
26572656
* Profiling MPI API
26582657
*/
2659-
OMPI_DECLSPEC int PMPI_Abi_supported(int *flag);
2660-
OMPI_DECLSPEC int PMPI_Abi_version(int *abi_major, int *abi_minor);
2661-
OMPI_DECLSPEC int PMPI_Abi_details(int *buflen, char *details, MPI_Info *info);
2658+
OMPI_DECLSPEC int PMPI_Abi_get_version(int *abi_major, int *abi_minor);
2659+
OMPI_DECLSPEC int PMPI_Abi_get_info(MPI_Info *info);
26622660
OMPI_DECLSPEC int PMPI_Abi_get_fortran_info(MPI_Info *info);
26632661
OMPI_DECLSPEC int PMPI_Abi_set_fortran_info(MPI_Info info);
26642662
OMPI_DECLSPEC int PMPI_Abi_get_fortran_booleans(int logical_size, void *logical_true, void *logical_false, int *is_set);

ompi/mpi/bindings/c_header.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@
5757
"MPI_Delete_function",
5858
]
5959

60+
DEPRECATED_FUNCTIONS = [
61+
"MPI_Keyval_create",
62+
"MPI_Keyval_free",
63+
"MPI_Attr_put",
64+
"MPI_Attr_get",
65+
"MPI_Attr_delete",
66+
"MPI_Address",
67+
"MPI_Errhandler_create",
68+
"MPI_Errhandler_get",
69+
"MPI_Errhandler_set",
70+
"MPI_Type_extent",
71+
"MPI_Type_hindexed",
72+
"MPI_Type_hvector",
73+
"MPI_Type_lb",
74+
"MPI_Type_struct",
75+
"MPI_Type_ub",
76+
]
77+
6078
ENUM_CATEGORIES = [
6179
"ERROR_CLASSES",
6280
"MODE_CONSTANTS",
@@ -255,6 +273,12 @@ def output_constant(const, use_enum: bool, mangle_name: bool):
255273
output.append(" */\n")
256274
output.append("extern int ompi_abi_mpi_proc_null_val;\n")
257275
output.append("extern int ompi_abi_mpi_any_source_val;\n")
276+
output.append("extern int ompi_abi_mpi_win_flavor_create;\n")
277+
output.append("extern int ompi_abi_mpi_win_flavor_allocate;\n")
278+
output.append("extern int ompi_abi_mpi_win_flavor_shared;\n")
279+
output.append("extern int ompi_abi_mpi_win_flavor_dynamic;\n")
280+
output.append("extern int ompi_abi_mpi_win_model_unified;\n")
281+
output.append("extern int ompi_abi_mpi_win_model_separate;\n")
258282
output.append("\n")
259283
output.append("int ABI_C_MPI_COMM_NULL_DELETE_FN( MPI_Comm_ABI_INTERNAL comm, int comm_keyval, void* attribute_val_out, void* extra_state );\n")
260284
output.append("int ABI_C_MPI_COMM_NULL_COPY_FN( MPI_Comm_ABI_INTERNAL comm, int comm_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, int* flag );\n")
@@ -296,9 +320,17 @@ def output_constant(const, use_enum: bool, mangle_name: bool):
296320
# like "MPI_Group_difference"
297321
datatype_pattern = r"([\( ]?)(" + datatype + r")([; \*\)]{1})"
298322
line = re.sub(datatype_pattern, f"\\g<1>\\g<2>{ABI_INTERNAL}\\g<3>", line)
323+
# TODO: need to enhance pympistandard to be able to prune out deprecated functions
324+
# This stands in as a workaround
325+
comment_out = any(i in line for i in DEPRECATED_FUNCTIONS)
326+
327+
# function is not in the ABI standard (things in MPI 5.1 chapter 19 sections 19.3.4 and 19.3.5
299328
# TODO: need to enhance pympistandard to have field in json to indicate a
300329
# function is not in the ABI standard (things in MPI 5.1 chapter 19 sections 19.3.4 and 19.3.5
301330
if "MPI_Fint" in line or "MPI_F08_status" in line:
331+
comment_out = True
332+
333+
if comment_out == True:
302334
# Comment out a line if it has references to MPI_Fint or MPI_F08_status, since
303335
# functions with these argument types are not in the ABI
304336
line = line[:-1]

ompi/mpi/bindings/ompi_bindings/c.py

Lines changed: 104 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from ompi_bindings.c_type import Type
3535
from ompi_bindings.parser import SourceTemplate
3636

37-
c_intrinsic_types = ['char', 'int', 'long int']
37+
c_intrinsic_types = ['char', 'int', 'long int', 'void']
3838
#OMPI_ABI_HANDLE_BASE_OFFSET = '16385'
3939

4040
class ABIHeaderBuilder:
@@ -226,7 +226,7 @@ def generate_error_convert_fn(self):
226226
lines.append(f'case {self.mangle_name(error)}:')
227227
lines.append(f'return {error};')
228228
lines.append('default:')
229-
lines.append('return error_class;')
229+
lines.append('return (error_class - %s);' % ('OMPI_ABI_HANDLE_BASE_OFFSET'))
230230
lines.append('}')
231231
self.dump_lines(lines)
232232
self.dump('}')
@@ -240,7 +240,7 @@ def generate_error_convert_fn_intern_to_abi(self):
240240
lines.append(f'case {error}:')
241241
lines.append(f'return {self.mangle_name(error)};')
242242
lines.append('default:')
243-
lines.append('return error_class;')
243+
lines.append('return (error_class + %s);' % ('OMPI_ABI_HANDLE_BASE_OFFSET'))
244244
lines.append('}')
245245
self.dump_lines(lines)
246246
self.dump('}')
@@ -338,10 +338,17 @@ def generic_convert(self, fn_name, param_name, type_, value_names, offset=None):
338338
self.dump('}')
339339

340340
def generic_convert_reverse(self, fn_name, param_name, type_, value_names, offset=None):
341-
if type_ not in c_intrinsic_types:
342-
intern_type = self.mangle_name(type_)
341+
is_ptr_arg = False
342+
tmp_type = type_
343+
if (tmp_type[-1] == '*'):
344+
is_ptr_arg = True
345+
tmp_type = tmp_type[:-1].strip()
346+
if tmp_type not in c_intrinsic_types:
347+
intern_type = self.mangle_name(tmp_type)
343348
else:
344-
intern_type = type_
349+
intern_type = tmp_type
350+
if (is_ptr_arg == True):
351+
intern_type = intern_type + ' *'
345352
self.dump(f'{consts.INLINE_ATTRS} {intern_type} {fn_name}({type_} {param_name})')
346353
self.dump('{')
347354
lines = []
@@ -525,6 +532,65 @@ def generate_comm_split_type_convert_fn(self):
525532
def generate_weight_convert_fn(self):
526533
self.generic_convert(ConvertFuncs.WEIGHTS, 'weights', 'int *', consts.RESERVED_WEIGHTS)
527534

535+
def generate_subarray_order_convert_fn(self):
536+
self.generic_convert(ConvertFuncs.SUBARRAY_ORDER, 'order', 'int', consts.SUBARRAY_ORDER_TYPES)
537+
538+
def generate_subarray_distrib_types_convert_fn(self):
539+
self.generic_convert(ConvertFuncs.SUBARRAY_DISTRIB_TYPES, 'dist', 'int', consts.SUBARRAY_DISTRIB_TYPES)
540+
541+
def generate_whence_convert_fn(self):
542+
self.generic_convert(ConvertFuncs.WHENCE, 'whence', 'int', consts.WHENCE_VALUES)
543+
544+
def generate_combiner_convert_fn_intern_to_abi(self):
545+
self.generic_convert_reverse(ConvertOMPIToStandard.COMBINER, 'combiner', 'int', consts.COMBINER_VALUES)
546+
547+
def generate_typeclass_convert_fn(self):
548+
self.generic_convert(ConvertFuncs.TYPECLASS, 'typeclass', 'int', consts.TYPECLASS_VALUES)
549+
550+
def generate_typeclass_convert_fn(self):
551+
self.generic_convert(ConvertFuncs.TYPECLASS, 'typeclass', 'int', consts.TYPECLASS_VALUES)
552+
553+
def generate_win_lock_convert_fn(self):
554+
self.generic_convert(ConvertFuncs.WIN_LOCK, 'lock_assert', 'int', consts.WIN_LOCK_VALUES)
555+
556+
def generate_topo_convert_fn_intern_to_abi(self):
557+
self.generic_convert_reverse(ConvertOMPIToStandard.TOPO, 'status', 'int', consts.TOPO_VALUES)
558+
559+
def generate_buffer_convert_fn(self):
560+
self.generic_convert(ConvertFuncs.BUFFER, 'buffer', 'void *', consts.BUFFER_VALUES)
561+
562+
def generate_buffer_convert_fn_intern_to_abi(self):
563+
self.generic_convert_reverse(ConvertOMPIToStandard.BUFFER, 'buffer', 'void *', consts.BUFFER_VALUES)
564+
565+
def generate_mode_bits_convert_fn(self):
566+
self.dump(f'{consts.INLINE_ATTRS} int {ConvertFuncs.MODE_BITS}(int mode_bits)')
567+
self.dump('{')
568+
lines = []
569+
lines.append('int ret_value = 0;')
570+
for value_name in consts.MODE_BITS:
571+
intern_name = self.mangle_name(value_name)
572+
lines.append('if (%s & mode_bits ) {' % (intern_name))
573+
lines.append('ret_value |= %s;' % (value_name))
574+
lines.append('}')
575+
lines.append('return ret_value;')
576+
self.dump_lines(lines)
577+
self.dump('}')
578+
579+
def generate_mode_bits_convert_fn_intern_to_abi(self):
580+
self.dump(f'{consts.INLINE_ATTRS} int {ConvertOMPIToStandard.MODE_BITS}(int mode_bits)')
581+
self.dump('{')
582+
lines = []
583+
lines.append('int ret_value = 0;')
584+
for value_name in consts.MODE_BITS:
585+
intern_name = self.mangle_name(value_name)
586+
lines.append('if (%s & mode_bits ) {' % (value_name))
587+
lines.append('ret_value |= %s;' % (intern_name))
588+
lines.append('}')
589+
lines.append('return ret_value;')
590+
self.dump_lines(lines)
591+
self.dump('}')
592+
593+
528594
def generate_pointer_convert_fn(self, type_, fn_name, constants):
529595
abi_type = self.mangle_name(type_)
530596
self.dump(f'{consts.INLINE_ATTRS} void {fn_name}({abi_type} *ptr)')
@@ -665,6 +731,10 @@ def dump_code(self):
665731
self.generate_t_source_order_convert_fn_intern_to_abi()
666732
self.generate_pvar_class_convert_fn()
667733
self.generate_pvar_class_convert_fn_intern_to_abi()
734+
self.generate_mode_bits_convert_fn()
735+
self.generate_mode_bits_convert_fn_intern_to_abi()
736+
self.generate_buffer_convert_fn()
737+
self.generate_buffer_convert_fn_intern_to_abi()
668738

669739
#
670740
# the following only need abi to intern converters
@@ -677,13 +747,19 @@ def dump_code(self):
677747
self.generate_win_delete_attr_convert_fn()
678748
self.generate_comm_split_type_convert_fn()
679749
self.generate_weight_convert_fn()
750+
self.generate_subarray_order_convert_fn()
751+
self.generate_subarray_distrib_types_convert_fn()
752+
self.generate_root_convert_fn()
753+
self.generate_t_cb_safety_convert_fn()
754+
self.generate_win_lock_convert_fn()
755+
self.generate_whence_convert_fn()
680756

681757
#
682758
# the following only need intern to abi converters
683759
#
684760
self.generate_comm_cmp_convert_fn_intern_to_abi()
685-
self.generate_root_convert_fn()
686-
self.generate_t_cb_safety_convert_fn()
761+
self.generate_combiner_convert_fn_intern_to_abi()
762+
self.generate_topo_convert_fn_intern_to_abi()
687763

688764
self.dump("""
689765
#if defined(c_plusplus) || defined(__cplusplus)
@@ -718,6 +794,16 @@ def print_cdefs_for_abi(out, abi_type='ompi'):
718794
out.dump('#undef OMPI_ABI_SRC')
719795
out.dump('#define OMPI_ABI_SRC 1')
720796

797+
def generate_replacements(mangle_names=False):
798+
replacements = {}
799+
for key in consts.MAX_STRING_LEN_CONSTANTS:
800+
if mangle_names == True:
801+
val = util.abi_internal_name(key)
802+
else:
803+
val = key
804+
replacements[key] = val
805+
return replacements
806+
721807
def ompi_abi(base_name, template, out, suppress_bc=False, suppress_nbc=False):
722808
"""Generate the OMPI ABI functions."""
723809
template.print_header(out)
@@ -726,7 +812,8 @@ def ompi_abi(base_name, template, out, suppress_bc=False, suppress_nbc=False):
726812
print_cdefs_for_bigcount(out)
727813
print_cdefs_for_abi(out)
728814
out.dump(template.prototype.signature(base_name, abi_type='ompi'))
729-
template.print_body(func_name=base_name, out=out)
815+
template.print_body(func_name=base_name, out=out,
816+
replacements=generate_replacements(mangle_names=False))
730817
# Check if we need to generate the bigcount interface
731818
if util.prototype_has_bigcount(template.prototype) and suppress_bc == False:
732819
# there are some special cases where we need to explicitly define the bigcount functions in the template file
@@ -738,8 +825,8 @@ def ompi_abi(base_name, template, out, suppress_bc=False, suppress_nbc=False):
738825
print_cdefs_for_bigcount(out, enable_count=True)
739826
print_cdefs_for_abi(out)
740827
out.dump(template.prototype.signature(base_name_c, abi_type='ompi', enable_count=True))
741-
template.print_body(func_name=base_name_c, out=out)
742-
828+
template.print_body(func_name=base_name_c, out=out,
829+
replacements=generate_replacements(mangle_names=False))
743830

744831
ABI_INTERNAL_HEADER = 'ompi/mpi/c/abi.h'
745832
ABI_INTERNAL_CONVERTOR = 'ompi/mpi/c/abi_converters.h'
@@ -771,15 +858,15 @@ def standard_abi(base_name, template, out, suppress_bc=False, suppress_nbc=False
771858
internal_sig = template.prototype.signature(internal_name, abi_type='ompi',
772859
enable_count=False)
773860
out.dump(consts.INLINE_ATTRS, internal_sig)
774-
template.print_body(func_name=base_name, out=out)
861+
template.print_body(func_name=base_name, out=out, replacements=generate_replacements(mangle_names=True))
775862
if util.prototype_has_bigcount(template.prototype) and suppress_bc == False:
776863
internal_name = f'ompi_abi_{template.prototype.name}_c'
777864
print_cdefs_for_bigcount(out, enable_count=True)
778865
print_cdefs_for_abi(out, abi_type='standard')
779866
internal_sig = template.prototype.signature(internal_name, abi_type='ompi',
780867
enable_count=True)
781868
out.dump(consts.INLINE_ATTRS, internal_sig)
782-
template.print_body(func_name=base_name, out=out)
869+
template.print_body(func_name=base_name, out=out, replacements=generate_replacements(mangle_names=True))
783870

784871
def generate_function(prototype, fn_name, internal_fn, out, enable_count=False):
785872
"""Generate a function for the standard ABI."""
@@ -794,6 +881,10 @@ def generate_function(prototype, fn_name, internal_fn, out, enable_count=False):
794881
return_type = prototype.return_type.construct(abi_type='standard')
795882
lines.append(f'{return_type.tmp_type_text()} ret_value;')
796883
for param in params:
884+
if param.need_async_cleanup == True:
885+
lines.append('int idx = 0;')
886+
break
887+
for param in params:
797888
# print("param = " + str(param) + " " + str(param.argument))
798889
if param.init_code:
799890
lines.extend(param.init_code)

0 commit comments

Comments
 (0)