Skip to content

Commit c1a36f8

Browse files
compiler: Honor zero initialization for mapped host arrays (#3101)
1 parent a0f73a3 commit c1a36f8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎devito/passes/iet/definitions.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
261261

262262
# Allocate the underlying host data
263263
memptr = VOID(Byref(ffp0), '**')
264-
alloc2 = self.langbb['host-alloc-pin'](memptr, alignment, ffp3)
264+
alloc2 = [self.langbb['host-alloc-pin'](memptr, alignment, ffp3)]
265+
if obj._is_zero_init and self.zero_init:
266+
alloc2.append(self.langbb['host-memset'](ffp0, 0, ffp3))
267+
storage.include('string.h')
265268

266269
# Free all of the allocated data
267270
frees = [self.langbb['host-free-pin'](ffp0),
@@ -276,7 +279,7 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
276279
# Wrap everything in a Callable so that we can reuse the same code
277280
# for equivalent Array structs
278281
name = self.sregistry.make_name(prefix='alloc')
279-
body = (decl, alloc0, alloc1, *init, alloc2, *as_tuple(alloc_dmap), ret)
282+
body = (decl, alloc0, alloc1, *init, *alloc2, *as_tuple(alloc_dmap), ret)
280283
efunc0 = make_callable(name, body, retval=obj)
281284
args = list(efunc0.parameters)
282285
args[args.index(arity_param)] = arity_arg

0 commit comments

Comments
 (0)