Skip to content
Snippets Groups Projects
Commit c042f1ae authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Cleanup

parent 81ddaf86
No related branches found
No related tags found
No related merge requests found
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):
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment