Skip to content

Commit ffc1dc9

Browse files
committed
compiler: Refactor clean-up
1 parent 18dba9d commit ffc1dc9

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

devito/ir/iet/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ def _same_as_before(old, new):
16831683
if type(old) is not type(new):
16841684
return False
16851685

1686-
if isinstance(old, dict):
1686+
if isinstance(old, dict) and isinstance(new, dict):
16871687
return old.keys() == new.keys() and all(
16881688
_same_as_before(v, new[k]) for k, v in old.items()
16891689
)

devito/ir/iet/visitors.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,14 +1560,10 @@ def visit_KernelLaunch(self, o):
15601560

15611561

15621562
def reuse_if_unchanged(o, *children, **kwargs):
1563-
if children:
1564-
same_children = all(
1565-
_same_as_before(i, j) for i, j in zip(o.children, children, strict=True)
1566-
)
1567-
if not same_children:
1568-
return o._rebuild(*children, **kwargs)
1569-
1570-
if kwargs and not all(o._same_arg(k, v) for k, v in kwargs.items()):
1563+
if children and not _same_as_before(o.children, children):
1564+
return o._rebuild(*children, **kwargs)
1565+
1566+
if kwargs:
15711567
return o._rebuild(*children, **kwargs)
15721568

15731569
return o

devito/ir/support/basic.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,7 @@ class TimedAccess(IterationInstance, AccessMode, CacheInstances):
218218
"""
219219

220220
@classmethod
221-
def _preprocess_args(cls, access, mode, timestamp, ispace=None):
222-
if ispace is None:
223-
ispace = null_ispace
221+
def _preprocess_args(cls, access, mode, timestamp, ispace=null_ispace):
224222
return (access, mode, timestamp, ispace), {}
225223

226224
def __new__(cls, access, mode, timestamp, ispace=None):

devito/passes/clusters/fusion.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424

2525
@memoized_func(scope='build')
2626
def _fusion_hazards(scope0, scope1, prefix):
27+
"""
28+
Classify the dependence hazard that would arise from fusing two scopes.
29+
"""
2730
scope = Scope.from_scopes(scope0, scope1)
2831
if scope is None:
2932
return NO_HAZARD

0 commit comments

Comments
 (0)