@@ -322,40 +322,65 @@ 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);' )
332- if not self .external :
333- # Now generate the conversion code
334- self .generate_error_convert_fn ()
335- self .generate_comm_convert_fn ()
336- self .generate_comm_convert_fn_intern_to_abi ()
337- self .generate_info_convert_fn ()
338- self .generate_info_convert_fn_intern_to_abi ()
339- self .generate_file_convert_fn ()
340- self .generate_file_convert_fn_intern_to_abi ()
341- self .generate_group_convert_fn ()
342- self .generate_group_convert_fn_intern_to_abi ()
343- self .generate_datatype_convert_fn ()
344- self .generate_datatype_convert_fn_intern_to_abi ()
345- self .generate_errhandler_convert_fn ()
346- self .generate_errhandler_convert_fn_intern_to_abi ()
347- self .generate_message_convert_fn ()
348- self .generate_message_convert_fn_intern_to_abi ()
349- self .generate_op_convert_fn ()
350- self .generate_op_convert_fn_intern_to_abi ()
351- self .generate_session_convert_fn ()
352- self .generate_session_convert_fn_intern_to_abi ()
353- self .generate_win_convert_fn ()
354- self .generate_win_convert_fn_intern_to_abi ()
355- self .generate_request_convert_fn ()
356- self .generate_request_convert_fn_intern_to_abi ()
357- self .generate_status_convert_fn ()
358- 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()
359384
360385 self .dump ("""
361386#if defined(c_plusplus) || defined(__cplusplus)
@@ -383,40 +408,66 @@ def print_cdefs_for_bigcount(out, enable_count=False):
383408 out .dump ('#undef OMPI_BIGCOUNT_SRC' )
384409 out .dump ('#define OMPI_BIGCOUNT_SRC 0' )
385410
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+
386419def ompi_abi (base_name , template , out ):
387420 """Generate the OMPI ABI functions."""
388421 template .print_header (out )
389422 print_profiling_header (base_name , out )
390423 print_cdefs_for_bigcount (out )
424+ print_cdefs_for_abi (out )
391425 out .dump (template .prototype .signature (base_name , abi_type = 'ompi' ))
392426 template .print_body (func_name = base_name , out = out )
393427 # Check if we need to generate the bigcount interface
394428 if util .prototype_has_bigcount (template .prototype ):
395429 base_name_c = f'{ base_name } _c'
396430 print_profiling_header (base_name_c , out )
397431 print_cdefs_for_bigcount (out , enable_count = True )
432+ print_cdefs_for_abi (out )
398433 out .dump (template .prototype .signature (base_name_c , abi_type = 'ompi' , enable_count = True ))
399434 template .print_body (func_name = base_name_c , out = out )
400435
401436
402437ABI_INTERNAL_HEADER = 'ompi/mpi/c/abi.h'
438+ ABI_INTERNAL_CONVERTOR = 'ompi/mpi/c/abi_converters.h'
403439
404440
405441def standard_abi (base_name , template , out ):
406442 """Generate the standard ABI functions."""
407443 template .print_header (out )
408444 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 )
409458
410459 # Static internal function (add a random component to avoid conflicts)
411460 internal_name = f'ompi_abi_{ template .prototype .name } '
412461 print_cdefs_for_bigcount (out )
462+ print_cdefs_for_abi (out , abi_type = 'standard' )
413463 internal_sig = template .prototype .signature (internal_name , abi_type = 'ompi' ,
414464 enable_count = False )
415465 out .dump (consts .INLINE_ATTRS , internal_sig )
416466 template .print_body (func_name = base_name , out = out )
417467 if util .prototype_has_bigcount (template .prototype ):
418468 internal_name = f'ompi_abi_{ template .prototype .name } _c'
419469 print_cdefs_for_bigcount (out , enable_count = True )
470+ print_cdefs_for_abi (out , abi_type = 'standard' )
420471 internal_sig = template .prototype .signature (internal_name , abi_type = 'ompi' ,
421472 enable_count = True )
422473 out .dump (consts .INLINE_ATTRS , internal_sig )
0 commit comments