@@ -672,6 +672,36 @@ def generate_status_convert_fn_intern_to_abi(self):
672672 # Ignoring the private fields for now
673673 self .dump ('}' )
674674
675+ def generate_errhandler_args_convert_fn_intern_to_abi (self ):
676+ self .dump (f'{ consts .INLINE_ATTRS } void ompi_convert_errhandler_args_intern_to_abi(void *object, int object_type, int *err_code)' )
677+ self .dump ('{' )
678+ lines = []
679+ lines .append ('ompi_communicator_t **comm;' )
680+ lines .append ('ompi_file_t **file;' )
681+ lines .append ('ompi_instance_t **instance;' )
682+ lines .append ('ompi_win_t **win;' )
683+ lines .append (f'*err_code = { ConvertOMPIToStandard .ERROR_CLASS } (*err_code);' )
684+ lines .append ('switch(object_type) {' )
685+ lines .append ('case OMPI_ERRHANDLER_TYPE_COMM:' )
686+ lines .append ('comm = (ompi_communicator_t **)object;' )
687+ lines .append (f'*comm = (MPI_Comm *){ ConvertOMPIToStandard .COMM } (*comm);' )
688+ lines .append ('break;' )
689+ lines .append ('case OMPI_ERRHANDLER_TYPE_WIN:' )
690+ lines .append ('win = (ompi_win_t **)object;' )
691+ lines .append (f'*win = (MPI_Win *){ ConvertOMPIToStandard .WIN } (*win);' )
692+ lines .append ('break;' )
693+ lines .append ('case OMPI_ERRHANDLER_TYPE_FILE:' )
694+ lines .append ('file = (ompi_file_t **)object;' )
695+ lines .append (f'*file = (MPI_File *){ ConvertOMPIToStandard .FILE } (*file);' )
696+ lines .append ('break;' )
697+ lines .append ('case OMPI_ERRHANDLER_TYPE_INSTANCE:' )
698+ lines .append ('instance = (ompi_instance_t **)object;' )
699+ lines .append (f'*instance = (MPI_Session *){ ConvertOMPIToStandard .SESSION } (*instance);' )
700+ lines .append ('break;' )
701+ lines .append ('};' )
702+ self .dump_lines (lines );
703+ self .dump ('}' )
704+
675705 def define (self , type_ , name , value ):
676706 self .dump (f'#define { name } OMPI_CAST_CONSTANT({ type_ } , { value } )' )
677707
@@ -713,6 +743,12 @@ def dump_code(self):
713743 lines .append ('}' )
714744 lines .append ('\n ' )
715745 self .dump_lines (lines )
746+ #
747+ # TODO: need to do something smarter
748+ #
749+ self .dump ('\n ' )
750+ self .dump (f'void ompi_convert_errhandler_args_intern_to_abi(void *object, int object_type, int *err_code);' )
751+ self .dump ('\n ' )
716752
717753 # Now generate the conversion code - there's a reason for the order here
718754 # some converters depend on others being declared earlier in the include
@@ -810,6 +846,55 @@ def dump_code(self):
810846""" )
811847 self .dump (f'#endif /* { header_guard } */' )
812848
849+ class ABIConverterGlobalBuilder (ABIConverterBuilder ):
850+
851+ def generate_errhandler_args_convert_fn_intern_to_abi (self ):
852+ self .dump (f'void ompi_convert_errhandler_args_intern_to_abi(void *object, int object_type, int *err_code)' )
853+ self .dump ('{' )
854+ lines = []
855+ lines .append ('ompi_communicator_t **comm;' )
856+ lines .append ('ompi_file_t **file;' )
857+ lines .append ('ompi_instance_t **instance;' )
858+ lines .append ('ompi_win_t **win;' )
859+ lines .append (f'*err_code = { ConvertOMPIToStandard .ERROR_CLASS } (*err_code);' )
860+ lines .append ('switch(object_type) {' )
861+ lines .append ('case OMPI_ERRHANDLER_TYPE_COMM:' )
862+ lines .append ('comm = (ompi_communicator_t **)object;' )
863+ lines .append (f'*comm = (ompi_communicator_t *){ ConvertOMPIToStandard .COMM } (*comm);' )
864+ lines .append ('break;' )
865+ lines .append ('case OMPI_ERRHANDLER_TYPE_WIN:' )
866+ lines .append ('win = (ompi_win_t **)object;' )
867+ lines .append (f'*win = (ompi_win_t *){ ConvertOMPIToStandard .WIN } (*win);' )
868+ lines .append ('break;' )
869+ lines .append ('case OMPI_ERRHANDLER_TYPE_FILE:' )
870+ lines .append ('file = (ompi_file_t **)object;' )
871+ lines .append (f'*file = (ompi_file_t *){ ConvertOMPIToStandard .FILE } (*file);' )
872+ lines .append ('break;' )
873+ lines .append ('case OMPI_ERRHANDLER_TYPE_INSTANCE:' )
874+ lines .append ('instance = (ompi_instance_t **)object;' )
875+ lines .append (f'*instance = (ompi_instance_t *){ ConvertOMPIToStandard .SESSION } (*instance);' )
876+ lines .append ('break;' )
877+ lines .append ('};' )
878+ self .dump_lines (lines );
879+ self .dump ('}' )
880+
881+ def dump_code (self ):
882+ self .dump ('#include "stddef.h"' )
883+ self .dump ('#include "stdint.h"' )
884+ self .dump ('#include "ompi/communicator/communicator.h"' )
885+ self .dump ('#include "ompi/win/win.h"' )
886+ self .dump ('#include "ompi/file/file.h"' )
887+ self .dump ('#include "ompi/instance/instance.h"' )
888+ self .dump ('#include "ompi/errhandler/errhandler.h"' )
889+ self .dump ('#include "ompi/mpi/c/abi.h"' )
890+ self .dump ('#include "ompi/mpi/c/abi_converters.h"' )
891+
892+ #
893+ # special case converters:
894+ # - errhandler functions convert
895+ #
896+ self .generate_errhandler_args_convert_fn_intern_to_abi ()
897+
813898def print_profiling_header (fn_name , out ):
814899 """Print the profiling header code."""
815900 out .dump ('#if OMPI_BUILD_MPI_PROFILING' )
@@ -956,6 +1041,12 @@ def generate_function(prototype, fn_name, internal_fn, out, enable_count=False):
9561041 enable_count = True )
9571042
9581043
1044+ def generate_converter_auxiliary_funcs (args , out ):
1045+ """Generate ABI auxiliary files. """
1046+ out .dump (f'/* { consts .GENERATED_MESSAGE } */' )
1047+ builder = ABIConverterGlobalBuilder (out )
1048+ builder .dump_code ()
1049+
9591050def generate_converters (args , out ):
9601051 """Generate ABI conversion methods. """
9611052 out .dump (f'/* { consts .GENERATED_MESSAGE } */' )
0 commit comments