Skip to content

Commit d44b2e3

Browse files
committed
compiler: Move expose_tuning_knobs to utils
1 parent e67f33f commit d44b2e3

2 files changed

Lines changed: 24 additions & 22 deletions

File tree

devito/passes/clusters/aliases.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
maximum, minimum, normalize_properties, relax_properties, unbounded, vmax, vmin
1414
)
1515
from devito.passes.clusters.cse import _cse
16+
from devito.passes.clusters.utils import expose_tuning_knobs
1617
from devito.symbolics import (
1718
Uxmapper, estimate_cost, retrieve_functions, reuse_if_untouched, search, sympy_dtype,
1819
uxreplace
@@ -1079,27 +1080,6 @@ def optimize_clusters_msds(clusters):
10791080
return processed
10801081

10811082

1082-
def expose_tuning_knobs(clusters, sregistry):
1083-
"""
1084-
Replace all pre-existing BlockDimensions with fresh ones, to enable
1085-
separate tuning for the CIRE-generated temporaries.
1086-
"""
1087-
# Create the new BlockDimensions
1088-
callback = lambda i: sregistry.make_name(prefix=i)
1089-
1090-
mapper = {}
1091-
for d in set().union(*[c.used_dimensions for c in clusters]):
1092-
if d.is_Block:
1093-
mapper.update(d._rebuild_hierarchy(callback))
1094-
1095-
if not mapper:
1096-
return clusters
1097-
1098-
processed = [c.subs(mapper) for c in clusters]
1099-
1100-
return processed
1101-
1102-
11031083
def pick_best(variants):
11041084
"""
11051085
Return the variant with the best theoretical performance.

devito/passes/clusters/utils.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from devito.tools import as_tuple
33
from devito.types import CriticalRegion, Eq, Symbol
44

5-
__all__ = ['in_critical_region', 'is_memcpy', 'make_critical_sequence']
5+
__all__ = ['expose_tuning_knobs', 'in_critical_region', 'is_memcpy',
6+
'make_critical_sequence']
67

78

89
def is_memcpy(expr):
@@ -50,3 +51,24 @@ def in_critical_region(cluster, clusters):
5051
elif c.is_critical_region:
5152
maybe_found = c
5253
return None
54+
55+
56+
def expose_tuning_knobs(clusters, sregistry):
57+
"""
58+
Replace all pre-existing BlockDimensions with fresh ones, to enable
59+
separate tuning for the CIRE-generated temporaries.
60+
"""
61+
# Create the new BlockDimensions
62+
callback = lambda i: sregistry.make_name(prefix=i)
63+
64+
mapper = {}
65+
for d in set().union(*[c.used_dimensions for c in clusters]):
66+
if d.is_Block:
67+
mapper.update(d._rebuild_hierarchy(callback))
68+
69+
if not mapper:
70+
return clusters
71+
72+
processed = [c.subs(mapper) for c in clusters]
73+
74+
return processed

0 commit comments

Comments
 (0)