Skip to content

Commit

Permalink
dsl: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Leitevmd committed Mar 23, 2021
1 parent b497a91 commit a992e9e
Show file tree
Hide file tree
Showing 2 changed files with 62 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
61 changes: 60 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,65 @@ 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():
# Excluding f.is_Array
if f is None or not f.is_DiscreteFunction:
continue

for d, v in stencil.items():

# Ignore time dimensions
if not d.is_Space:
continue

# This should ignore subdimentions with thickness != 0
if d.is_Sub:
if not all(tick[1] == 0 for tick in d.thickness):
continue

# Check only parent dimension limits only
p = d.parent if d.is_Sub else d

try:
Min = 0
Max = f._size_nodomain[p].left + f._size_halo[p].right
test0 = min(v) < 0
test1 = max(v) > Max
if test0 or test1:
if p.is_NonlinearDerived:
pass
else:
raise ValueError(' OOB access\n'
' func: %s, type: %s\n'
' indices: %s\n'
' indices_ref: %s\n'
' dim: %s, type: %s\n'
' is_Time: %s \n'
# ' (time_order: %s)\n'
' is_Space: %s \n'
# ' (space_order: %s)\n'
' d.is_Sub %s (%s)\n'
' stencil min max = (%s, %s)\n'
' limits = (%s, %s)'
% (f,type(f),
f.indices,
f.indices_ref,
p.name,type(p),
p.is_Time,
# f.time_order if p.is_Time else '',
p.is_Space,
# f.space_order if p.is_Space else '',
d.is_Sub, d,
min(v), max(v),
Min, Max))

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 a992e9e

Please sign in to comment.