@@ -177,21 +177,23 @@ 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 ,
185189 dimensions = (Dimension (name = 'd' ),), scope = 'rvalue' )
186190 shape_arg = ListInitializer (obj .c0 .symbolic_shape , dtype = shape_param .dtype )
187- sizeofelem_param = Symbol (name = 'sizeofelem' , dtype = size_t )
188- sizeofelem_arg = 1 #TODO
189191
190192 ffp0 = FieldFromPointer (obj ._C_field_data , obj ._C_symbol )
191193 ffp1 = FieldFromPointer (obj ._C_field_shape , obj ._C_symbol )
192194 ffp2 = FieldFromPointer (obj ._C_field_size , obj ._C_symbol )
193195 ffp3 = FieldFromPointer (obj ._C_field_nbytes , obj ._C_symbol )
194- ffp4 = FieldFromPointer (obj ._C_field_sizeofelem , obj ._C_symbol )
196+ ffp4 = FieldFromPointer (obj ._C_field_arity , obj ._C_symbol )
195197
196198 # Allocate the Array struct
197199 memptr = VOID (Byref (obj ._C_symbol ), '**' )
@@ -216,7 +218,7 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
216218 ndims_param - 1 ,
217219 ))
218220 init .append (DummyExpr (ffp3 , ffp2 * arity_param ))
219- init .append (DummyExpr (ffp4 , sizeofelem_param ))
221+ init .append (DummyExpr (ffp4 , arity_param ))
220222
221223 # Allocate the underlying host data
222224 memptr = VOID (Byref (ffp0 ), '**' )
@@ -241,7 +243,6 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
241243 args [args .index (arity_param )] = arity_arg
242244 args [args .index (ndims_param )] = ndims_arg
243245 args [args .index (shape_param )] = shape_arg
244- args [args .index (sizeofelem_param )] = sizeofelem_arg #TODO
245246 alloc = Call (name , args , retobj = obj )
246247
247248 # Same story for the frees
@@ -259,21 +260,22 @@ def _alloc_bundle_struct_on_high_bw_mem(self, site, obj, storage):
259260 """
260261 decl = Definition (obj )
261262
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)
262266 arity_param = Symbol (name = 'arity' , dtype = size_t )
263- arity_arg = SizeOf (obj .indexed ._C_typedata )
267+ arity_arg = (SizeOf (obj .indexed ._C_typedata ) /
268+ SizeOf (obj .c0 .indexed ._C_typedata ))
264269 ndims_param = Symbol (name = 'ndims' , dtype = size_t )
265270 ndims_arg = obj .ndim
266271 shape_param = Array (name = f'{ obj .name } _shape' , dtype = np .uint64 ,
267272 dimensions = (Dimension (name = 'd' ),), scope = 'rvalue' )
268273 shape_arg = ListInitializer (obj .c0 .symbolic_shape , dtype = shape_param .dtype )
269- sizeofelem_param = Symbol (name = 'sizeofelem' , dtype = size_t )
270- sizeofelem_arg = 1 #TODO
271- from IPython import embed ; embed ()
272274
273275 ffp1 = FieldFromPointer (obj ._C_field_shape , obj ._C_symbol )
274276 ffp2 = FieldFromPointer (obj ._C_field_size , obj ._C_symbol )
275277 ffp3 = FieldFromPointer (obj ._C_field_nbytes , obj ._C_symbol )
276- ffp4 = FieldFromPointer (obj ._C_field_sizeofelem , obj ._C_symbol )
278+ ffp4 = FieldFromPointer (obj ._C_field_arity , obj ._C_symbol )
277279
278280 # Allocate the Bundle struct
279281 memptr = VOID (Byref (obj ._C_symbol ), '**' )
@@ -298,6 +300,7 @@ def _alloc_bundle_struct_on_high_bw_mem(self, site, obj, storage):
298300 ndims_param - 1 ,
299301 ))
300302 init .append (DummyExpr (ffp3 , ffp2 * arity_param ))
303+ init .append (DummyExpr (ffp4 , arity_param ))
301304
302305 # Free all of the allocated data
303306 frees = [self .langbb ['host-free' ](ffp1 ),
@@ -314,7 +317,6 @@ def _alloc_bundle_struct_on_high_bw_mem(self, site, obj, storage):
314317 args [args .index (arity_param )] = arity_arg
315318 args [args .index (ndims_param )] = ndims_arg
316319 args [args .index (shape_param )] = shape_arg
317- args [args .index (sizeofelem_param )] = sizeofelem_arg #TODO
318320 alloc = Call (name , args , retobj = obj )
319321
320322 # Same story for the frees
0 commit comments