Skip to content

Commit d0379ba

Browse files
committed
compiler: Move expose_tuning_knobs to utils
1 parent fa680a3 commit d0379ba

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
@@ -1080,27 +1081,6 @@ def optimize_clusters_msds(clusters):
10801081
return processed
10811082

10821083

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