Skip to content

Commit cfcadc9

Browse files
committed
compiler: prevent hosted per-thread arrays are dereferenced within partree at read
1 parent 2065979 commit cfcadc9

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

devito/passes/iet/parpragma.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,21 @@ def _make_parregion(self, partree, parrays):
317317
i = n.write
318318
if not (i.is_Array or i.is_TempFunction):
319319
continue
320-
elif i in parrays:
321-
pi = parrays[i]
322-
else:
323-
pi = parrays.setdefault(i, i._make_pointer(dim=self.threadid))
324-
vexpandeds.append(VExpanded(i, pi))
320+
elif i not in parrays:
321+
parrays.setdefault(i, i._make_pointer(dim=self.threadid))
322+
vexpandeds.append(i)
323+
324+
# Vector-expand all read Arrays within `partree` that were not
325+
# already vector-expanded above. Those might be written to in
326+
# a previous parallel region such as hoisted time invariants.
327+
for n in FindNodes(Expression).visit(partree):
328+
for i in n.reads:
329+
if not (i.is_Array or i.is_TempFunction):
330+
continue
331+
elif i in parrays and i not in vexpandeds:
332+
vexpandeds.append(i)
333+
334+
vexpandeds = [VExpanded(i, parrays[i]) for i in vexpandeds]
325335

326336
if vexpandeds:
327337
init = self.langbb['thread-num'](retobj=self.threadid)

0 commit comments

Comments
 (0)