@@ -177,8 +177,12 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
177177 """
178178 decl = Definition (obj )
179179
180+ # NOTE: the `arity` is calculated such as `sizeof(float3)/sizeof(float)`
181+ # for portability reasons (since we don't know the size of compound
182+ # types a priori)
180183 arity_param = Symbol (name = 'arity' , dtype = size_t )
181- arity_arg = SizeOf (obj .indexed ._C_typedata )
184+ arity_arg = (SizeOf (obj .indexed ._C_typedata ) /
185+ SizeOf (obj .c0 .indexed ._C_typedata ))
182186 ndims_param = Symbol (name = 'ndims' , dtype = size_t )
183187 ndims_arg = obj .ndim
184188 shape_param = Array (name = f'{ obj .name } _shape' , dtype = np .uint64 ,
@@ -189,6 +193,7 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
189193 ffp1 = FieldFromPointer (obj ._C_field_shape , obj ._C_symbol )
190194 ffp2 = FieldFromPointer (obj ._C_field_size , obj ._C_symbol )
191195 ffp3 = FieldFromPointer (obj ._C_field_nbytes , obj ._C_symbol )
196+ ffp4 = FieldFromPointer (obj ._C_field_arity , obj ._C_symbol )
192197
193198 # Allocate the Array struct
194199 memptr = VOID (Byref (obj ._C_symbol ), '**' )
@@ -213,6 +218,7 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
213218 ndims_param - 1 ,
214219 ))
215220 init .append (DummyExpr (ffp3 , ffp2 * arity_param ))
221+ init .append (DummyExpr (ffp4 , arity_param ))
216222
217223 # Allocate the underlying host data
218224 memptr = VOID (Byref (ffp0 ), '**' )
@@ -254,8 +260,12 @@ def _alloc_bundle_struct_on_high_bw_mem(self, site, obj, storage):
254260 """
255261 decl = Definition (obj )
256262
263+ # NOTE: the `arity` is calculated such as `sizeof(float3)/sizeof(float)`
264+ # for portability reasons (since we don't know the size of compound
265+ # types a priori)
257266 arity_param = Symbol (name = 'arity' , dtype = size_t )
258- arity_arg = SizeOf (obj .indexed ._C_typedata )
267+ arity_arg = (SizeOf (obj .indexed ._C_typedata ) /
268+ SizeOf (obj .c0 .indexed ._C_typedata ))
259269 ndims_param = Symbol (name = 'ndims' , dtype = size_t )
260270 ndims_arg = obj .ndim
261271 shape_param = Array (name = f'{ obj .name } _shape' , dtype = np .uint64 ,
@@ -265,6 +275,7 @@ def _alloc_bundle_struct_on_high_bw_mem(self, site, obj, storage):
265275 ffp1 = FieldFromPointer (obj ._C_field_shape , obj ._C_symbol )
266276 ffp2 = FieldFromPointer (obj ._C_field_size , obj ._C_symbol )
267277 ffp3 = FieldFromPointer (obj ._C_field_nbytes , obj ._C_symbol )
278+ ffp4 = FieldFromPointer (obj ._C_field_arity , obj ._C_symbol )
268279
269280 # Allocate the Bundle struct
270281 memptr = VOID (Byref (obj ._C_symbol ), '**' )
@@ -289,6 +300,7 @@ def _alloc_bundle_struct_on_high_bw_mem(self, site, obj, storage):
289300 ndims_param - 1 ,
290301 ))
291302 init .append (DummyExpr (ffp3 , ffp2 * arity_param ))
303+ init .append (DummyExpr (ffp4 , arity_param ))
292304
293305 # Free all of the allocated data
294306 frees = [self .langbb ['host-free' ](ffp1 ),
0 commit comments