From b5d7ff2d03c9bbf063048db37bfe8bd97ac0417c Mon Sep 17 00:00:00 2001
From: Tim Warburton <timwar@caam.rice.edu>
Date: Tue, 8 Nov 2011 23:57:06 -0600
Subject: [PATCH] Move CSE check to scheduling entrypoint.

---
 loopy/preprocess.py | 13 -------------
 loopy/schedule.py   | 12 ++++++++++++
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/loopy/preprocess.py b/loopy/preprocess.py
index fd851d3a6..3c84d835c 100644
--- a/loopy/preprocess.py
+++ b/loopy/preprocess.py
@@ -645,19 +645,6 @@ def preprocess_kernel(kernel):
     kernel = mark_local_temporaries(kernel)
     kernel = duplicate_reduction_inames(kernel)
     kernel = realize_reduction(kernel)
-
-    # {{{ check that all CSEs have been realized
-
-    from loopy.symbolic import CSECallbackMapper
-
-    def map_cse(expr, rec):
-        raise RuntimeError("all CSEs must be realized before scheduling")
-
-    for insn in kernel.instructions:
-        CSECallbackMapper(map_cse)(insn.expression)
-
-    # }}}
-
     kernel = assign_automatic_axes(kernel)
     kernel = add_boostability_and_automatic_dependencies(kernel)
     kernel = limit_boostability(kernel)
diff --git a/loopy/schedule.py b/loopy/schedule.py
index 61d9678cc..67ffbb645 100644
--- a/loopy/schedule.py
+++ b/loopy/schedule.py
@@ -597,6 +597,18 @@ def insert_barriers(kernel, schedule, level=0):
 # {{{ main scheduling entrypoint
 
 def generate_loop_schedules(kernel, loop_priority=[], debug=None):
+    # {{{ check that all CSEs have been realized
+
+    from loopy.symbolic import CSECallbackMapper
+
+    def map_cse(expr, rec):
+        raise RuntimeError("all CSEs must be realized before scheduling")
+
+    for insn in kernel.instructions:
+        CSECallbackMapper(map_cse)(insn.expression)
+
+    # }}}
+
     from loopy.preprocess import preprocess_kernel
     kernel = preprocess_kernel(kernel)
 
-- 
GitLab