Skip to content

Commit 56d4626

Browse files
committed
compiler: prevent premature reducermap->dict conversion
1 parent 6ded0a0 commit 56d4626

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

devito/operator/operator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,15 +637,16 @@ def _prepare_arguments(self, autotune=None, estimate_memory=False, **kwargs):
637637
# E.g., given a ConditionalDimension `t_sub` with factor `fact`
638638
# and a TimeFunction `usave(t_sub, x, y)`, an override for
639639
# `fact` is supplied w/o overriding `usave`; that's legal
640-
args[k] = args.unique(k, candidate=v)
641-
elif is_integer(args[k]) and not contains_val(args[k], v):
640+
continue
641+
if is_integer(args[k]) and not contains_val(args[k], v):
642642
raise InvalidArgument(
643643
f"Default `{p}` is incompatible with other args as "
644644
f"`{k}={v}`, while `{k}={args[k]}` is expected. Perhaps "
645645
f"you forgot to override `{p}`?"
646646
)
647+
args[k] = args.unique(k, candidate=v)
647648

648-
args = kwargs['args'] = args.reduce_all()
649+
kwargs['args'] = args.reduce_inplace()
649650

650651
for i in discretizations:
651652
args.update(i._arg_values(**kwargs))

devito/tools/data_structures.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ def reduce_inplace(self):
223223
for k, v in self.reduce_all().items():
224224
self[k] = v
225225

226+
return self
227+
226228

227229
class DefaultOrderedDict(OrderedDict):
228230
# Source: http://stackoverflow.com/a/6190500/562769

devito/types/dimension.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,8 @@ def _arg_defaults(self, _min=None, size=None, alias=None):
10421042
f"{self.name}: {size} < {size0}")
10431043
else:
10441044
# Given a factor the last time index is factor*(size - 1)
1045-
defaults[dim.parent.max_name] = range(d0, d0 + factor*(size - 1) + 1)
1045+
# The maximum allowed value is then factor*size - 1
1046+
defaults[dim.parent.max_name] = range(d0, d0 + factor*size)
10461047

10471048
return defaults
10481049

0 commit comments

Comments
 (0)