@@ -90,16 +90,24 @@ def callback_wrapper_code(self):
9090 """Return True if this parameter has callback wrapper code to generate."""
9191 return False
9292
93+ @property
94+ def need_async_cleanup (self ):
95+ """Return True if this parameter generates async memory cleanup code."""
96+ return False
97+
9398class StandardABIType (Type ):
9499
95100 @property
96101 def tmpname (self ):
97- return f' { self .name } _tmp'
102+ return util . abi_tmp_name ( self .name )
98103
99104 @property
100105 def argument (self ):
101106 return self .tmpname
102107
108+ @staticmethod
109+ def async_callback_index (self ):
110+ return "idx"
103111
104112@Type .add_type ('ERROR_CLASS' , abi_type = ['ompi' ])
105113class TypeErrorClass (Type ):
@@ -660,13 +668,23 @@ def argument(self):
660668@Type .add_type ('DATATYPE_ARRAY_ASYNC' , abi_type = ['standard' ])
661669class TypeDatatypeArrayAsyncStandard (TypeDatatypeArrayStandard ):
662670
671+ @property
672+ def need_async_cleanup (self ):
673+ return True
674+
663675 @property
664676 def final_code (self ):
665- code = ['{' ]
677+ request_tmp_name = util .abi_tmp_name ('request' )
678+ code = []
679+ code .append ('if((MPI_SUCCESS == ret_value) && (MPI_REQUEST_NULL != request_tmp)){' )
680+ code .append (f'ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)&{ request_tmp_name } ;' )
681+ code .append (f'nb_request->data.release_arrays[idx++] = (void *){ self .tmpname } ;' )
682+ code .append ('nb_request->data.release_arrays[idx] = NULL;' )
683+ code .append ('} else {' )
684+ code .append (f'free({ self .tmpname } );' )
666685 code .append ('}' )
667686 return code
668687
669-
670688@Type .add_type ('DATATYPE_ARRAY_OUT' , abi_type = ['standard' ])
671689class TypeDatatypeArrayOutStandard (StandardABIType ):
672690
@@ -722,9 +740,20 @@ def init_code(self):
722740@Type .add_type ('NEIGHBOR_DATATYPE_ARRAY_ASYNC' , abi_type = ['standard' ])
723741class NeighborDatatypeArrayAsyncStandard (NeighborDatatypeArrayStandard ):
724742
743+ @property
744+ def need_async_cleanup (self ):
745+ return True
746+
725747 @property
726748 def final_code (self ):
727- code = ['{' ]
749+ request_tmp_name = util .abi_tmp_name ('request' )
750+ code = []
751+ code .append ('if((MPI_SUCCESS == ret_value) && (MPI_REQUEST_NULL != request_tmp)){' )
752+ code .append (f'ompi_coll_base_nbc_request_t* nb_request = (ompi_coll_base_nbc_request_t*)&{ request_tmp_name } ;' )
753+ code .append (f'nb_request->data.release_arrays[idx++] = (void *){ self .tmpname } ;' )
754+ code .append ('nb_request->data.release_arrays[idx] = NULL;' )
755+ code .append ('} else {' )
756+ code .append (f'free({ self .tmpname } );' )
728757 code .append ('}' )
729758 return code
730759
0 commit comments