Skip to content

Commit 974106a

Browse files
committed
handle dargs for darray_create correctly
Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 5eba4d7 commit 974106a

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

ompi/mpi/bindings/ompi_bindings/c.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ def generate_subarray_order_convert_fn(self):
537537
def generate_subarray_distrib_types_convert_fn(self):
538538
self.generic_convert(ConvertFuncs.SUBARRAY_DISTRIB_TYPES, 'dist', 'int', consts.SUBARRAY_DISTRIB_TYPES)
539539

540+
def generate_subarray_dargs_types_convert_fn(self):
541+
self.generic_convert(ConvertFuncs.SUBARRAY_DARGS_TYPES, 'darg', 'int', consts.SUBARRAY_DARGS_TYPES)
542+
540543
def generate_whence_convert_fn(self):
541544
self.generic_convert(ConvertFuncs.WHENCE, 'whence', 'int', consts.WHENCE_VALUES)
542545

@@ -786,6 +789,7 @@ def dump_code(self):
786789
self.generate_weight_convert_fn()
787790
self.generate_subarray_order_convert_fn()
788791
self.generate_subarray_distrib_types_convert_fn()
792+
self.generate_subarray_dargs_types_convert_fn()
789793
self.generate_root_convert_fn()
790794
self.generate_t_cb_safety_convert_fn()
791795
self.generate_win_lock_convert_fn()

ompi/mpi/bindings/ompi_bindings/c_type.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3202,6 +3202,46 @@ def type_text(self, enable_count=False):
32023202
def parameter(self, enable_count=False, **kwargs):
32033203
return f'const int {self.name}[]'
32043204

3205+
@Type.add_type('DARGS_ARRAY', abi_type=['ompi'])
3206+
class TypeDargsArray(Type):
3207+
3208+
def type_text(self, enable_count=False):
3209+
return 'const int *'
3210+
3211+
def parameter(self, enable_count=False, **kwargs):
3212+
return f'const int {self.name}[]'
3213+
3214+
@Type.add_type('DARGS_ARRAY', abi_type=['standard'])
3215+
class TypeDargsArrayStandard(StandardABIType):
3216+
3217+
@property
3218+
def init_code(self):
3219+
code = [f'int size_{self.tmpname} = {self.count_param};']
3220+
code.append(f'int *{self.tmpname} = NULL;')
3221+
code.append('if('+f'{self.name}' + '!= NULL)' + '{')
3222+
code.append(f'{self.tmpname} = (int *)ompi_abi_malloc(size_{self.tmpname}, sizeof(int));')
3223+
code.append(f'if (NULL != {self.tmpname}){{')
3224+
code.append(f'for(int i=0;i<size_{self.tmpname};i++){{')
3225+
code.append(f'{self.tmpname}[i] = {ConvertFuncs.SUBARRAY_DARGS_TYPES}({self.name}[i]);')
3226+
code.append('}')
3227+
code.append('}')
3228+
code.append('}')
3229+
return code
3230+
3231+
3232+
@property
3233+
def final_code(self):
3234+
code = [f'if({self.tmpname} != NULL){{']
3235+
code.append(f'free({self.tmpname});')
3236+
code.append('}')
3237+
return code
3238+
3239+
def type_text(self, enable_count=False):
3240+
return 'const int *'
3241+
3242+
def parameter(self, enable_count=False, **kwargs):
3243+
return f'const int {self.name}[]'
3244+
32053245
@Type.add_type('MODE_BITS', abi_type=['ompi'])
32063246
class TypeModeBits(Type):
32073247

ompi/mpi/bindings/ompi_bindings/consts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@
200200
'MPI_DISTRIBUTE_NONE',
201201
'MPI_DISTRIBUTE_BLOCK',
202202
'MPI_DISTRIBUTE_CYCLIC',
203+
]
204+
205+
SUBARRAY_DARGS_TYPES = [
203206
'MPI_DISTRIBUTE_DFLT_DARG',
204207
]
205208

@@ -581,6 +584,7 @@ class ConvertFuncs:
581584
WEIGHTS = 'ompi_convert_weight_intern_weight'
582585
SUBARRAY_ORDER = 'ompi_convert_subarray_order_intern_subarray_order'
583586
SUBARRAY_DISTRIB_TYPES = 'ompi_convert_subarray_distrib_type_intern_distrib_type'
587+
SUBARRAY_DARGS_TYPES = 'ompi_convert_subarray_dargs_type_intern_dargs_type'
584588
MODE_BITS = 'ompi_convert_mode_bits_intern_mode_bits'
585589
RMA_MODE_BITS = 'ompi_convert_rma_mode_bits_intern_mode_bits'
586590
WHENCE = 'ompi_convert_whence_intern_whence'

ompi/mpi/c/type_create_darray.c.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
PROTOTYPE ERROR_CLASS type_create_darray(INT size,
4343
INT rank,
4444
INT ndims,
45-
COUNT_ARRAY gsize_array,
45+
COUNT_ARRAY gsize_array:ndims,
4646
DISTRIB_ARRAY distrib_array:ndims,
47-
INT_ARRAY darg_array,
48-
INT_ARRAY psize_array,
47+
DARGS_ARRAY darg_array:ndims,
48+
INT_ARRAY psize_array:ndims,
4949
SUBARRAY_ORDER order,
5050
DATATYPE oldtype,
5151
DATATYPE_OUT newtype)

0 commit comments

Comments
 (0)