Skip to content

Commit 571833f

Browse files
committed
compiler: Postpone opt_pows until before unevaluation
1 parent ad447a3 commit 571833f

6 files changed

Lines changed: 31 additions & 64 deletions

File tree

devito/core/cpu.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ def _specialize_clusters(cls, clusters, **kwargs):
177177
# Reduce flops
178178
clusters = cire(clusters, 'sops', sregistry, options, platform)
179179
clusters = factorize(clusters, **kwargs)
180-
clusters = optimize_pows(clusters)
181180

182181
# The previous passes may have created fusion opportunities
183182
clusters = fuse(clusters)

devito/core/gpu.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ def _specialize_clusters(cls, clusters, **kwargs):
218218
# Reduce flops
219219
clusters = cire(clusters, 'sops', sregistry, options, platform)
220220
clusters = factorize(clusters, **kwargs)
221-
clusters = optimize_pows(clusters)
222221

223222
# The previous passes may have created fusion opportunities
224223
clusters = fuse(clusters)

devito/operator/operator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
from devito.parameters import configuration
3030
from devito.passes import (
3131
Graph, lower_index_derivatives, generate_implicit, generate_macros,
32-
minimize_symbols, unevaluate, error_mapper, is_on_device, lower_dtypes
32+
minimize_symbols, optimize_pows, unevaluate, error_mapper, is_on_device,
33+
lower_dtypes
3334
)
3435
from devito.symbolics import estimate_cost, subs_op_args
3536
from devito.tools import (DAG, OrderedSet, Signer, ReducerMap, as_mapper, as_tuple,
@@ -409,6 +410,10 @@ def _lower_clusters(cls, expressions, profiler=None, **kwargs):
409410
# Lower all remaining high order symbolic objects
410411
clusters = lower_index_derivatives(clusters, **kwargs)
411412

413+
# Turn pows into multiplications. This must happen as late as possible
414+
# in the compilation process to maximize the optimization potential
415+
clusters = optimize_pows(clusters)
416+
412417
# Make sure no reconstructions can unpick any of the symbolic
413418
# optimizations performed so far
414419
clusters = unevaluate(clusters)

0 commit comments

Comments
 (0)