diff --git a/devito/ir/clusters/cluster.py b/devito/ir/clusters/cluster.py index f3758b5a5a..d3c9a7c50f 100644 --- a/devito/ir/clusters/cluster.py +++ b/devito/ir/clusters/cluster.py @@ -392,7 +392,12 @@ def dspace(self): for f, v in parts.items(): for i in v: if i.dim in oobs: - intervals = intervals.ceil(v[i.dim]) + try: + if intervals[i.dim].upper > v[i.dim].upper and \ + bool(i.dim in f.dimensions): + intervals = intervals.ceil(v[i.dim]) + except AttributeError: + pass return DataSpace(intervals, parts) diff --git a/devito/types/dimension.py b/devito/types/dimension.py index 1f8b4c1f78..92f476e0a2 100644 --- a/devito/types/dimension.py +++ b/devito/types/dimension.py @@ -346,7 +346,7 @@ def _arg_check(self, args, size, interval): # Autopadding causes non-integer upper limit from devito.symbolics import normalize_args upper = interval.upper.subs(normalize_args(args)) - if args[self.max_name] + upper > size: + if args[self.max_name] + upper >= size: raise InvalidArgument("OOB detected due to %s=%d" % (self.max_name, args[self.max_name])) diff --git a/examples/userapi/02_apply.ipynb b/examples/userapi/02_apply.ipynb index 80584051bd..f8f730dd52 100644 --- a/examples/userapi/02_apply.ipynb +++ b/examples/userapi/02_apply.ipynb @@ -250,14 +250,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "OOB detected due to time_M=3\n" + "OOB detected due to time_M=2\n" ] } ], "source": [ "from devito.exceptions import InvalidArgument\n", "try:\n", - " op.apply(time_M=3)\n", + " op.apply(time_M=2)\n", "except InvalidArgument as e:\n", " print(e)" ]