Skip to content

Commit 348511c

Browse files
committed
SQUASH_ME: OMNIBUS commit 7
to heed the --enable-abi-standard config option makefile fixes checkpoint some fixes and start of a wrapper method for comm/type/win attributes. Not clear if this is the way to handle attr copy/del call backs compiled againt the mpi.h ABI header file. attributes: add wrapper infrastructure This approach works for attributes but other approaches will be needed for error handlers and datatype conversion related functions. abi: move converter functions to a persistent file Signed-off-by: Howard Pritchard <[email protected]>
1 parent d166410 commit 348511c

29 files changed

+1286
-1562
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ docs/man
535535

536536
# Generated C Bindings
537537
ompi/mpi/c/*_generated*.c
538-
ompi/mpi/c/ompi_*.c
539538
ompi/mpi/c/standard_*.c
540539
ompi/mpi/c/abi.h
541540
ompi/mpi/c/standard_abi

ompi/attribute/attribute.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ do { \
322322
/* C style */ \
323323
else { \
324324
void *attr_val = translate_to_c(attribute); \
325+
/* TODO: NEED SUPPORT FOR ABI */ \
325326
err = (*((keyval_obj->delete_attr_fn).attr_##type##_delete_fn)) \
326327
((ompi_##type##_t *)object, \
327328
key, attr_val, \
@@ -381,6 +382,7 @@ do { \
381382
else { \
382383
void *in, *out; \
383384
in = translate_to_c(in_attr); \
385+
/* TODO: NEED SUPPORT FOR ABI */ \
384386
if ((err = (*((keyval_obj->copy_attr_fn).attr_##type##_copy_fn)) \
385387
((ompi_##type##_t *)old_object, key, keyval_obj->extra_state.c_ptr, \
386388
in, &out, &flag)) == MPI_SUCCESS) { \

ompi/attribute/attribute.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#define OMPI_KEYVAL_PREDEFINED 0x0001
5151
#define OMPI_KEYVAL_F77 0x0002
5252
#define OMPI_KEYVAL_F77_INT 0x0004
53+
#define OMPI_KEYVAL_ABI 0x0008
5354

5455

5556
BEGIN_C_DECLS
@@ -136,7 +137,7 @@ struct ompi_attribute_keyval_t {
136137
copy/delete attribute functions
137138
properly and error checking */
138139
int attr_flag; /**< flag field: contains "OMPI_KEYVAL_PREDEFINED",
139-
"OMPI_KEYVAL_F77" */
140+
"OMPI_KEYVAL_F77", "OMPI_KEYVAL_ABI", etc. */
140141
ompi_attribute_fn_ptr_union_t copy_attr_fn; /**< Copy function for the
141142
attribute */
142143
ompi_attribute_fn_ptr_union_t delete_attr_fn; /**< Delete function for the

ompi/mpi/bindings/ompi_bindings/c.py

Lines changed: 86 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,11 @@ def generate_status_convert_fn(self):
218218
abi_type = self.mangle_name(type_)
219219
self.dump(f'{consts.INLINE_ATTRS} void {ConvertFuncs.STATUS}({type_} *out, {abi_type} *inp)')
220220
self.dump('{')
221+
self.dump(' void *ptr = &out->_ucount;')
221222
self.dump(' out->MPI_SOURCE = inp->MPI_SOURCE;')
222223
self.dump(' out->MPI_TAG = inp->MPI_TAG;')
224+
self.dump(' out->_cancelled = inp->MPI_Internal[0];')
225+
self.dump(' memcpy(ptr, &inp->MPI_Internal[1],sizeof(out->_ucount));')
223226
self.dump(f' out->MPI_ERROR = {ConvertFuncs.ERROR_CLASS}(inp->MPI_ERROR);')
224227
# Ignoring the private fields for now
225228
self.dump('}')
@@ -229,8 +232,11 @@ def generate_status_convert_fn_intern_to_abi(self):
229232
abi_type = self.mangle_name(type_)
230233
self.dump(f'{consts.INLINE_ATTRS} void {ConvertOMPIToStandard.STATUS}({abi_type} *out, {type_} *inp)')
231234
self.dump('{')
235+
self.dump(' void *ptr = &out->MPI_Internal[1];')
232236
self.dump(' out->MPI_SOURCE = inp->MPI_SOURCE;')
233237
self.dump(' out->MPI_TAG = inp->MPI_TAG;')
238+
self.dump(' out->MPI_Internal[0] =inp->_cancelled;')
239+
self.dump(' memcpy(ptr, &inp->_ucount,sizeof(inp->_ucount));')
234240
# self.dump(f' out->MPI_ERROR = {ConvertOMPIToStandard.ERROR_CLASS}(inp->MPI_ERROR);')
235241
# Ignoring the private fields for now
236242
self.dump('}')
@@ -309,47 +315,72 @@ def dump_header(self):
309315
int MPI_SOURCE;
310316
int MPI_TAG;
311317
int MPI_ERROR;
312-
int mpi_abi_private[5];
318+
int MPI_Internal[5];
313319
};""")
314320
self.dump(f'typedef struct MPI_Status_ABI {self.mangle_name("MPI_Status")};')
315321
self.dump()
316322
# user functions
317323
self.dump('typedef int (MPI_Copy_function)(MPI_Comm_ABI_INTERNAL, int, void *, void *, void *, int *);')
318324
self.dump('typedef int (MPI_Delete_function)(MPI_Comm_ABI_INTERNAL, int, void *, void *);')
325+
#
326+
# generate prototypes for user call back functions
327+
#
328+
for handle in consts.C_ATTRIBUTE_OBJS:
329+
prefix, suffix = handle.split('_')
330+
copy_callback_func_name = f'{handle}_copy_attr_function'
331+
copy_callback_func_name = f'{self.mangle_name(copy_callback_func_name)}'
332+
delete_callback_func_name = f'{handle}_delete_attr_function'
333+
delete_callback_func_name = f'{self.mangle_name(delete_callback_func_name)}'
334+
#
335+
# stupid MPI standard naming consistency
336+
#
337+
if handle == 'MPI_Type':
338+
obj_arg_type = f'{self.mangle_name("MPI_Datatype")}'
339+
else:
340+
obj_arg_type = f'{self.mangle_name(handle)}'
341+
obj_arg_name = f'old{suffix}'.lower()
342+
obj_arg = f'{obj_arg_type} {obj_arg_name}'
343+
keyval_arg = f'int {suffix}_keyval'.lower()
344+
self.dump(f'typedef int ({copy_callback_func_name})({obj_arg}, {keyval_arg}, void *, void *, void *,int *);')
345+
self.dump(f'typedef int ({delete_callback_func_name})({obj_arg}, {keyval_arg}, void *, void *);')
346+
319347
# Function signatures
320348
for sig in self.signatures:
321349
self.dump(f'{sig};')
322-
# print("Working on signature " + str(sig))
323350
self.dump('int MPI_Abi_details(int *buflen, char *details, MPI_Info *info);')
324351
self.dump('int MPI_Abi_supported(int *flag);')
325352
self.dump('int MPI_Abi_version(int *abi_major, int *abi_minor);')
326-
if not self.external:
327-
# Now generate the conversion code
328-
self.generate_error_convert_fn()
329-
self.generate_comm_convert_fn()
330-
self.generate_comm_convert_fn_intern_to_abi()
331-
self.generate_info_convert_fn()
332-
self.generate_info_convert_fn_intern_to_abi()
333-
self.generate_file_convert_fn()
334-
self.generate_file_convert_fn_intern_to_abi()
335-
self.generate_group_convert_fn()
336-
self.generate_group_convert_fn_intern_to_abi()
337-
self.generate_datatype_convert_fn()
338-
self.generate_datatype_convert_fn_intern_to_abi()
339-
self.generate_errhandler_convert_fn()
340-
self.generate_errhandler_convert_fn_intern_to_abi()
341-
self.generate_message_convert_fn()
342-
self.generate_message_convert_fn_intern_to_abi()
343-
self.generate_op_convert_fn()
344-
self.generate_op_convert_fn_intern_to_abi()
345-
self.generate_session_convert_fn()
346-
self.generate_session_convert_fn_intern_to_abi()
347-
self.generate_win_convert_fn()
348-
self.generate_win_convert_fn_intern_to_abi()
349-
self.generate_request_convert_fn()
350-
self.generate_request_convert_fn_intern_to_abi()
351-
self.generate_status_convert_fn()
352-
self.generate_status_convert_fn_intern_to_abi()
353+
354+
#
355+
# the converters are no longer generated
356+
#
357+
# if not self.external:
358+
# # Now generate the conversion code
359+
# self.generate_error_convert_fn()
360+
# self.generate_comm_convert_fn()
361+
# self.generate_comm_convert_fn_intern_to_abi()
362+
# self.generate_info_convert_fn()
363+
# self.generate_info_convert_fn_intern_to_abi()
364+
# self.generate_file_convert_fn()
365+
# self.generate_file_convert_fn_intern_to_abi()
366+
# self.generate_group_convert_fn()
367+
# self.generate_group_convert_fn_intern_to_abi()
368+
# self.generate_datatype_convert_fn()
369+
# self.generate_datatype_convert_fn_intern_to_abi()
370+
# self.generate_errhandler_convert_fn()
371+
# self.generate_errhandler_convert_fn_intern_to_abi()
372+
# self.generate_message_convert_fn()
373+
# self.generate_message_convert_fn_intern_to_abi()
374+
# self.generate_op_convert_fn()
375+
# self.generate_op_convert_fn_intern_to_abi()
376+
# self.generate_session_convert_fn()
377+
# self.generate_session_convert_fn_intern_to_abi()
378+
# self.generate_win_convert_fn()
379+
# self.generate_win_convert_fn_intern_to_abi()
380+
# self.generate_request_convert_fn()
381+
# self.generate_request_convert_fn_intern_to_abi()
382+
# self.generate_status_convert_fn()
383+
# self.generate_status_convert_fn_intern_to_abi()
353384

354385
self.dump("""
355386
#if defined(c_plusplus) || defined(__cplusplus)
@@ -377,40 +408,66 @@ def print_cdefs_for_bigcount(out, enable_count=False):
377408
out.dump('#undef OMPI_BIGCOUNT_SRC')
378409
out.dump('#define OMPI_BIGCOUNT_SRC 0')
379410

411+
def print_cdefs_for_abi(out, abi_type='ompi'):
412+
if abi_type == 'ompi':
413+
out.dump('#undef OMPI_ABI_SRC')
414+
out.dump('#define OMPI_ABI_SRC 0')
415+
else:
416+
out.dump('#undef OMPI_ABI_SRC')
417+
out.dump('#define OMPI_ABI_SRC 1')
418+
380419
def ompi_abi(base_name, template, out):
381420
"""Generate the OMPI ABI functions."""
382421
template.print_header(out)
383422
print_profiling_header(base_name, out)
384423
print_cdefs_for_bigcount(out)
424+
print_cdefs_for_abi(out)
385425
out.dump(template.prototype.signature(base_name, abi_type='ompi'))
386426
template.print_body(func_name=base_name, out=out)
387427
# Check if we need to generate the bigcount interface
388428
if util.prototype_has_bigcount(template.prototype):
389429
base_name_c = f'{base_name}_c'
390430
print_profiling_header(base_name_c, out)
391431
print_cdefs_for_bigcount(out, enable_count=True)
432+
print_cdefs_for_abi(out)
392433
out.dump(template.prototype.signature(base_name_c, abi_type='ompi', enable_count=True))
393434
template.print_body(func_name=base_name_c, out=out)
394435

395436

396437
ABI_INTERNAL_HEADER = 'ompi/mpi/c/abi.h'
438+
ABI_INTERNAL_CONVERTOR = 'ompi/mpi/c/abi_converters.h'
397439

398440

399441
def standard_abi(base_name, template, out):
400442
"""Generate the standard ABI functions."""
401443
template.print_header(out)
402444
out.dump(f'#include "{ABI_INTERNAL_HEADER}"')
445+
out.dump(f'#include "{ABI_INTERNAL_CONVERTOR}"')
446+
print_cdefs_for_abi(out,abi_type='standard')
447+
448+
# If any parameters are pointers to user callback functions, generate code
449+
# for callback wrappers
450+
if util.prototype_needs_callback_wrappers(template.prototype):
451+
params = [param.construct(abi_type='standard') for param in template.prototype.params]
452+
for param in params:
453+
if param.callback_wrapper_code:
454+
lines = []
455+
lines.extend(param.callback_wrapper_code)
456+
for line in lines:
457+
out.dump(line)
403458

404459
# Static internal function (add a random component to avoid conflicts)
405460
internal_name = f'ompi_abi_{template.prototype.name}'
406461
print_cdefs_for_bigcount(out)
462+
print_cdefs_for_abi(out, abi_type='standard')
407463
internal_sig = template.prototype.signature(internal_name, abi_type='ompi',
408464
enable_count=False)
409465
out.dump(consts.INLINE_ATTRS, internal_sig)
410466
template.print_body(func_name=base_name, out=out)
411467
if util.prototype_has_bigcount(template.prototype):
412468
internal_name = f'ompi_abi_{template.prototype.name}_c'
413469
print_cdefs_for_bigcount(out, enable_count=True)
470+
print_cdefs_for_abi(out, abi_type='standard')
414471
internal_sig = template.prototype.signature(internal_name, abi_type='ompi',
415472
enable_count=True)
416473
out.dump(consts.INLINE_ATTRS, internal_sig)

0 commit comments

Comments
 (0)