Skip to content

Commit

Permalink
dsl: testing patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Leitevmd committed Apr 30, 2021
1 parent 5af459a commit 7216936
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions devito/ir/equations/equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ def __new__(cls, *args, **kwargs):
# Analyze the expression
mapper = detect_accesses(expr)
oobs = detect_oobs(mapper)

for d in oobs:
if d.is_Space:
if d.is_Sub:
if not d.is_NonlinearDerived:
raise ValueError(' OOB access\n')

conditional_dimensions = [i for i in ordering if i.is_Conditional]

# Construct Intervals for IterationSpace and DataSpace
Expand Down
18 changes: 15 additions & 3 deletions devito/ir/support/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,27 @@ def detect_oobs(mapper):
for f, stencil in mapper.items():
if f is None or not (f.is_DiscreteFunction or f.is_Array):
continue
dim_sizes = dict(zip(f.dimensions, f.shape))
for d, v in stencil.items():
p = d.parent if d.is_Sub else d
try:
test0 = min(v) < 0
test1 = max(v) > f._size_nodomain[p].left + f._size_halo[p].right
if d.is_Sub:
size = dim_sizes[d if d in dim_sizes else d.parent]
if d._offset_left[1] == d.parent.symbolic_min:
test0 = min(v) < - d._offset_left[0]
else:
test0 = min(v) < - (size - 1 + d._offset_left[0])
if d._offset_right[1] == d.parent.symbolic_max:
test1 = max(v) > f._size_halo[p].left + f._size_halo[p].right - d._offset_right[0]
else:
test1 = max(v) > f._size_halo[p].left + f._size_halo[p].right + (size - 1 - d._offset_right[0])
else:
test0 = min(v) < 0
test1 = max(v) > f._size_halo[p].left + f._size_halo[p].right
if test0 or test1:
# It'd mean trying to access a point before the
# left padding (test0) or after the right halo (test1)
found.add(p)
found.add(d)
except KeyError:
# Unable to detect presence of OOB accesses
# (/p/ not in /f._size_halo/, typical of indirect
Expand Down

0 comments on commit 7216936

Please sign in to comment.