Skip to content

Commit

Permalink
dsl: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Leitevmd committed Mar 22, 2021
1 parent b497a91 commit 8f2d3e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion devito/ir/equations/equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from devito.ir.equations.algorithms import dimension_sort, lower_exprs
from devito.finite_differences.differentiable import diff2sympy
from devito.ir.support import (IterationSpace, DataSpace, Interval, IntervalGroup,
Stencil, detect_accesses, detect_oobs, detect_io,
Stencil, detect_accesses, detect_oobs, detect_oobs_test, detect_io,
build_intervals, build_iterators)
from devito.symbolics import CondEq, IntDiv, uxreplace
from devito.tools import Pickable, frozendict
Expand Down Expand Up @@ -138,6 +138,7 @@ def __new__(cls, *args, **kwargs):
# Analyze the expression
mapper = detect_accesses(expr)
oobs = detect_oobs(mapper)
detect_oobs_test(mapper)
conditional_dimensions = [i for i in ordering if i.is_Conditional]

# Construct Intervals for IterationSpace and DataSpace
Expand Down
26 changes: 25 additions & 1 deletion devito/ir/support/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from devito.tools import as_tuple, flatten, filter_sorted
from devito.types import Dimension

__all__ = ['detect_accesses', 'detect_oobs', 'build_iterators', 'build_intervals',
__all__ = ['detect_accesses', 'detect_oobs', 'detect_oobs_test', 'build_iterators', 'build_intervals',
'detect_io']


Expand Down Expand Up @@ -69,6 +69,30 @@ def detect_oobs(mapper):
return found | set().union(*[i._defines for i in found if i.is_Derived])


def detect_oobs_test(mapper):
found = set()
for f, stencil in mapper.items():
if f is None or not f.is_DiscreteFunction:
continue
for d, v in stencil.items():
if not d.is_Space:
continue
if d.is_Sub:
if not all(tick[1] == 0 for tick in d.thickness):
continue
try:
Min = 0
Max = f._size_nodomain[d].left + f._size_halo[d].right
test0 = min(v) < 0
test1 = max(v) > Max
if test0 or test1:
raise ValueError('OOB access')

except KeyError:
pass
return found


def build_iterators(mapper):
"""
Given M as produced by :func:`detect_accesses`, return a mapper ``M' : D -> V``,
Expand Down

0 comments on commit 8f2d3e2

Please sign in to comment.