diff --git a/python/dune/perftool/loopy/target.py b/python/dune/perftool/loopy/target.py index aa9d015197cfbae328aff1873d831afd167dd40e..cffb30b7215d1472768a995e2ddeecfef25280d0 100644 --- a/python/dune/perftool/loopy/target.py +++ b/python/dune/perftool/loopy/target.py @@ -1,8 +1,8 @@ from dune.perftool.generation import post_include from dune.perftool.loopy.temporary import DuneTemporaryVariable -from dune.perftool.pdelab.spaces import LFSLocalIndex -from dune.perftool.loopy.types import VCLTypeRegistry +from dune.perftool.loopy.vcl import VCLTypeRegistry +from dune.perftool.generation import retrieve_cache_functions from loopy.target import (TargetBase, ASTBuilderBase, @@ -10,12 +10,10 @@ from loopy.target import (TargetBase, ) from loopy.target.c import CASTBuilder from loopy.target.c.codegen.expression import ExpressionToCExpressionMapper, CExpressionToCodeMapper -from loopy.symbolic import FunctionIdentifier from loopy.types import NumpyType -from pymbolic.primitives import Call, Subscript, Variable - -from cgen import Line +import pymbolic.primitives as prim +import cgen _registry = {'float32': 'float', 'int32': 'int', @@ -29,19 +27,22 @@ class MyMapper(ExpressionToCExpressionMapper): arr = self.find_array(expr) if isinstance(arr, DuneTemporaryVariable) and not arr.managed: # If there is but one index, we do not need to handle this - if isinstance(expr.index, (Variable, int)): + if isinstance(expr.index, (prim.Variable, int)): return expr # Else, we construct a nested Subscript chain ret = expr.aggregate for i in expr.index: - ret = Subscript(ret, i) + ret = prim.Subscript(ret, i) return ret else: return ExpressionToCExpressionMapper.map_subscript(self, expr, type_context) class DuneASTBuilder(CASTBuilder): + def function_manglers(self): + return CASTBuilder.function_manglers(self) + retrieve_cache_functions("mangler") + def get_expression_to_c_expression_mapper(self, codegen_state): return MyMapper(codegen_state) @@ -52,14 +53,14 @@ class DuneASTBuilder(CASTBuilder): return CASTBuilder.get_temporary_decl(self, knl, schedule_index, temp_var, decl_info) if temp_var.decl_method: - return Line(temp_var.decl_method(temp_var.name, temp_var.shape, temp_var.shape_impl)) + return cgen.Line(temp_var.decl_method(temp_var.name, temp_var.shape, temp_var.shape_impl)) def add_vector_access(self, access_expr, index): # There is no generic way of implementing a vector access with VCL, as # it might be that the entire statement needs to be rewritten. Consider # the example of an assignment to a vector component. It is *not* of the # form 'x.0 = 2' but instead its 'x.insert(0, 2)'. It is currently not - # clear to me how this can be done, so I avoid the sitauation entirely. + # clear to me how this can be done, so I avoid the situation entirely. raise NotImplementedError() def emit_barrier(self, kind, comment): diff --git a/python/dune/perftool/loopy/types.py b/python/dune/perftool/loopy/vcl.py similarity index 100% rename from python/dune/perftool/loopy/types.py rename to python/dune/perftool/loopy/vcl.py diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py index a8234f20a7425e2efe223b9934928cae070363c8..8c48334121000df5d0707a9594438787e25f58f1 100644 --- a/python/dune/perftool/pdelab/localoperator.py +++ b/python/dune/perftool/pdelab/localoperator.py @@ -480,7 +480,6 @@ def generate_kernel(integrals): instructions = [i for i in retrieve_cache_items("instruction")] temporaries = {i.name: i for i in retrieve_cache_items("temporary")} arguments = [i for i in retrieve_cache_items("argument")] - manglers = retrieve_cache_functions("mangler") silenced = [l for l in retrieve_cache_items("silenced_warning")] transformations = [t for t in retrieve_cache_items("transformation")] @@ -494,7 +493,6 @@ def generate_kernel(integrals): instructions, arguments, temporary_variables=temporaries, - function_manglers=manglers, target=DuneTarget(), options=opt, silenced_warnings=silenced,