From 334ab645c00c7bb2255c826c0cf7956f23695ae5 Mon Sep 17 00:00:00 2001
From: Kaushik Kulkarni <kaushikcfd@gmail.com>
Date: Tue, 27 Mar 2018 09:57:23 -0500
Subject: [PATCH] Fixes minor error regarding realizing simil_reduce, reduce

---
 loopy/preprocess.py | 10 +++++++++-
 loopy/symbolic.py   |  4 ++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/loopy/preprocess.py b/loopy/preprocess.py
index bc4c84524..f6bf6ab88 100644
--- a/loopy/preprocess.py
+++ b/loopy/preprocess.py
@@ -2141,14 +2141,20 @@ class UnScopedCallCollector(CombineMapper):
 
     map_variable = map_constant
     map_function_symbol = map_constant
+    map_tagged_variable = map_constant
 
 
 def check_functions_are_scoped(kernel):
     """ Checks if all the calls in the instruction expression have been scoped,
     otherwise indicate to what all calls we await signature.
     """
+
+    from loopy.symbolic import SubstitutionRuleExpander
+    subst_expander = SubstitutionRuleExpander(kernel.substitutions)
+
     for insn in kernel.instructions:
-        unscoped_calls = UnScopedCallCollector()(insn.expression)
+        unscoped_calls = UnScopedCallCollector()(subst_expander(
+            insn.expression))
         if unscoped_calls:
             raise LoopyError("Unknown function '%s' obtained -- register a function"
                     " or a kernel corresponding to it." % set(unscoped_calls).pop())
@@ -2278,6 +2284,7 @@ class ArgDescriptionInferer(CombineMapper):
 
     map_variable = map_constant
     map_function_symbol = map_constant
+    map_tagged_variable = map_constant
 
 
 def infer_arg_descr(kernel):
@@ -2355,6 +2362,7 @@ class ReadyForCodegen(CombineMapper):
 
     map_variable = map_constant
     map_function_symbol = map_constant
+    map_tagged_variable = map_constant
 
 
 def specializing_incomplete_callables(kernel):
diff --git a/loopy/symbolic.py b/loopy/symbolic.py
index 831bab5c2..62de58e76 100644
--- a/loopy/symbolic.py
+++ b/loopy/symbolic.py
@@ -1192,12 +1192,12 @@ class FunctionToPrimitiveMapper(IdentityMapper):
             else:
                 raise TypeError("cse takes two arguments")
 
-        elif name in set(["reduce, simul_reduce"]):
+        elif name in ["reduce", "simul_reduce"]:
             if len(expr.parameters) >= 3:
                 function, inames = expr.parameters[:2]
                 red_exprs = expr.parameters[2:]
 
-                return self._parse_reduction(str(function), inames,
+                return self._parse_reduction(str(function.name), inames,
                         tuple(self.rec(red_expr) for red_expr in red_exprs),
                         allow_simultaneous=(name == "simul_reduce"))
             else:
-- 
GitLab