From f7fba4c0b83ce910f282353a5cdf924ca84c6e68 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Wed, 25 Jan 2017 10:32:42 +0100
Subject: [PATCH] Take substitutions from the kernel to avoid them being
 eliminated

---
 python/dune/perftool/pdelab/localoperator.py | 29 +++++++++-----------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py
index 271432b5..74d6b336 100644
--- a/python/dune/perftool/pdelab/localoperator.py
+++ b/python/dune/perftool/pdelab/localoperator.py
@@ -498,27 +498,24 @@ def extract_kernel_from_cache(tag, wrap_in_cgen=True):
                          name=name,
                          )
 
+    from loopy import make_reduction_inames_unique
+    kernel = make_reduction_inames_unique(kernel)
+
     # Apply the transformations that were gathered during tree traversals
     for trafo in transformations:
         kernel = trafo[0](kernel, *trafo[1])
 
     # Precompute all the substrules
-    for sr in substrules:
-        try:
-            tmpname = "precompute_{}".format(sr.name)
-            kernel = lp.precompute(kernel,
-                                   sr.name,
-                                   temporary_name=tmpname,
-                                   )
-            # Vectorization strategies are actually very likely to eliminate the
-            # precomputation temporary. To avoid the temporary elimination warning
-            # we need to explicitly disable it.
-            kernel = kernel.copy(silenced_warnings=kernel.silenced_warnings + ["temp_to_write({})".format(tmpname)])
-        except RunTimeError:
-            pass
-
-    from loopy import make_reduction_inames_unique
-    kernel = make_reduction_inames_unique(kernel)
+    for sr in kernel.substitutions:
+        tmpname = "precompute_{}".format(sr)
+        kernel = lp.precompute(kernel,
+                               sr,
+                               temporary_name=tmpname,
+                               )
+        # Vectorization strategies are actually very likely to eliminate the
+        # precomputation temporary. To avoid the temporary elimination warning
+        # we need to explicitly disable it.
+        kernel = kernel.copy(silenced_warnings=kernel.silenced_warnings + ["temp_to_write({})".format(tmpname)])
 
     from dune.perftool.loopy import heuristic_duplication
     kernel = heuristic_duplication(kernel)
-- 
GitLab