@@ -322,13 +322,35 @@ def dump_header(self):
322322 # user functions
323323 self .dump ('typedef int (MPI_Copy_function)(MPI_Comm_ABI_INTERNAL, int, void *, void *, void *, int *);' )
324324 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+
325347 # Function signatures
326348 for sig in self .signatures :
327349 self .dump (f'{ sig } ;' )
328- # print("Working on signature " + str(sig))
329350 self .dump ('int MPI_Abi_details(int *buflen, char *details, MPI_Info *info);' )
330351 self .dump ('int MPI_Abi_supported(int *flag);' )
331352 self .dump ('int MPI_Abi_version(int *abi_major, int *abi_minor);' )
353+
332354 if not self .external :
333355 # Now generate the conversion code
334356 self .generate_error_convert_fn ()
@@ -383,18 +405,28 @@ def print_cdefs_for_bigcount(out, enable_count=False):
383405 out .dump ('#undef OMPI_BIGCOUNT_SRC' )
384406 out .dump ('#define OMPI_BIGCOUNT_SRC 0' )
385407
408+ def print_cdefs_for_abi (out , abi_type = 'ompi' ):
409+ if abi_type == 'ompi' :
410+ out .dump ('#undef OMPI_ABI_SRC' )
411+ out .dump ('#define OMPI_ABI_SRC 0' )
412+ else :
413+ out .dump ('#undef OMPI_ABI_SRC' )
414+ out .dump ('#define OMPI_ABI_SRC 1' )
415+
386416def ompi_abi (base_name , template , out ):
387417 """Generate the OMPI ABI functions."""
388418 template .print_header (out )
389419 print_profiling_header (base_name , out )
390420 print_cdefs_for_bigcount (out )
421+ print_cdefs_for_abi (out )
391422 out .dump (template .prototype .signature (base_name , abi_type = 'ompi' ))
392423 template .print_body (func_name = base_name , out = out )
393424 # Check if we need to generate the bigcount interface
394425 if util .prototype_has_bigcount (template .prototype ):
395426 base_name_c = f'{ base_name } _c'
396427 print_profiling_header (base_name_c , out )
397428 print_cdefs_for_bigcount (out , enable_count = True )
429+ print_cdefs_for_abi (out )
398430 out .dump (template .prototype .signature (base_name_c , abi_type = 'ompi' , enable_count = True ))
399431 template .print_body (func_name = base_name_c , out = out )
400432
@@ -406,17 +438,26 @@ def standard_abi(base_name, template, out):
406438 """Generate the standard ABI functions."""
407439 template .print_header (out )
408440 out .dump (f'#include "{ ABI_INTERNAL_HEADER } "' )
441+ print_cdefs_for_abi (out ,abi_type = 'standard' )
442+
443+ # If any parameters are pointers to user callback functions, generate code
444+ # for callback wrappers
445+ # if util.prototype_needs_callback_wrappers(template.prototype):
446+ # for param in prototype.params:
447+ # if param.callback_wrapper_code:
409448
410449 # Static internal function (add a random component to avoid conflicts)
411450 internal_name = f'ompi_abi_{ template .prototype .name } '
412451 print_cdefs_for_bigcount (out )
452+ print_cdefs_for_abi (out , abi_type = 'standard' )
413453 internal_sig = template .prototype .signature (internal_name , abi_type = 'ompi' ,
414454 enable_count = False )
415455 out .dump (consts .INLINE_ATTRS , internal_sig )
416456 template .print_body (func_name = base_name , out = out )
417457 if util .prototype_has_bigcount (template .prototype ):
418458 internal_name = f'ompi_abi_{ template .prototype .name } _c'
419459 print_cdefs_for_bigcount (out , enable_count = True )
460+ print_cdefs_for_abi (out , abi_type = 'standard' )
420461 internal_sig = template .prototype .signature (internal_name , abi_type = 'ompi' ,
421462 enable_count = True )
422463 out .dump (consts .INLINE_ATTRS , internal_sig )
0 commit comments