diff --git a/python/dune/perftool/loopy/target.py b/python/dune/perftool/loopy/target.py index ae8cd5480ebb2c69bcf3713aae2ef1d54280f39b..b1c738b359885a1c8e0434b7420799e4959c6770 100644 --- a/python/dune/perftool/loopy/target.py +++ b/python/dune/perftool/loopy/target.py @@ -40,18 +40,6 @@ class DuneASTBuilder(CASTBuilder): # type system! return [] - # def emit_sequential_loop(self, codegen_state, iname, iname_dtype, static_lbound, static_ubound, inner): - # # Some of our loops are special as they use PDELab specific concepts. - # # Fortunately those loops are tied to specific inames. - # from dune.perftool.pdelab.quadrature import quadrature_iname - # if iname == quadrature_iname(): - # from cgen import CustomLoop - # from dune.perftool.pdelab.quadrature import quadrature_loop_statement - # loop_stmt = quadrature_loop_statement() - # return CustomLoop("for({})".format(loop_stmt), inner) - # else: - # return CASTBuilder.emit_sequential_loop(self, codegen_state, iname, iname_dtype, static_lbound, static_ubound, inner) - class DuneTarget(TargetBase): def __init__(self): diff --git a/python/dune/perftool/pdelab/__init__.py b/python/dune/perftool/pdelab/__init__.py index 76aaff919dd3d63045f811ebe9896a5910b529d5..370efeecbd64001d94cfa7ff56437b81dce488ee 100644 --- a/python/dune/perftool/pdelab/__init__.py +++ b/python/dune/perftool/pdelab/__init__.py @@ -22,7 +22,8 @@ from dune.perftool.pdelab.index import (name_index, from dune.perftool.pdelab.parameter import (cell_parameter_function, intersection_parameter_function, ) -from dune.perftool.pdelab.quadrature import (name_quadrature_weight, +from dune.perftool.pdelab.quadrature import (name_quadrature_weights, + quadrature_iname, ) from dune.perftool.pdelab.spaces import (lfs_iname, ) @@ -102,5 +103,8 @@ class PDELabInterface(object): # Quadrature related generator functions # - def name_quadrature_weight(self): - return name_quadrature_weight() + def quadrature_iname(self): + return quadrature_iname() + + def name_quadrature_weights(self): + return name_quadrature_weights() diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py index 5f9ac0d9bd952d9e21cbba86a4db53477be97944..156721f4c41eb0ec61b027d4dc33518ec9a47666 100644 --- a/python/dune/perftool/pdelab/localoperator.py +++ b/python/dune/perftool/pdelab/localoperator.py @@ -504,12 +504,6 @@ def generate_kernel(integrals): from dune.perftool.loopy.stages import finalize_stage_instructions kernel = finalize_stage_instructions(kernel) - # This is also silly, but 1D DG Schemes never need the geometry, so the quadrature - # statement actually introduces a preamble at a stage where preambles cannot be generated - # anymore. TODO think about how to avoid this!!! - from dune.perftool.pdelab.quadrature import quadrature_loop_statement - quadrature_loop_statement() - # Loopy might have introduced some temporary variables during preprocessing. As I want to have my own # temporary declaration code right now, I call the declaration preamble manually. for added_tv in set(kernel.temporary_variables.keys()) - set(temporaries.keys()): diff --git a/python/dune/perftool/pdelab/quadrature.py b/python/dune/perftool/pdelab/quadrature.py index ae80479b5011904ef1a0e6f9e3ae006a1f7a86d8..c4bfa744a2012a457ba5359dcccf8ddfebec1a2c 100644 --- a/python/dune/perftool/pdelab/quadrature.py +++ b/python/dune/perftool/pdelab/quadrature.py @@ -1,13 +1,17 @@ +import numpy + from dune.perftool.generation import (backend, cached, class_member, domain, get_global_context_value, + globalarg, iname, include_file, instruction, preamble, temporary_variable, + valuearg, ) from dune.perftool.pdelab.localoperator import lop_template_range_field from dune.perftool.options import get_option @@ -38,6 +42,10 @@ def define_quadrature_bound(name): def name_quadrature_bound(): name = "quadrature_size" define_quadrature_bound(name) + + # Quadrature bound is a valuearg for loopy + valuearg(name, dtype=numpy.int32) + return name @@ -84,7 +92,6 @@ def fill_quadrature_points_cache(name): @class_member("operator") def typedef_quadrature_points(name): - # TODO: Maybe not consistent range_field = lop_template_range_field() dim = _local_dim() return "using {} = typename Dune::QuadraturePoint<{}, {}>::Vector;".format(name, range_field, dim) @@ -155,7 +162,6 @@ def fill_quadrature_weights_cache(name): @class_member("operator") def typedef_quadrature_weights(name): - # TODO: Maybe not consistent range_field = lop_template_range_field() dim = _local_dim() return "using {} = typename Dune::QuadraturePoint<{}, {}>::Field;".format(name, range_field, dim) @@ -179,21 +185,11 @@ def name_quadrature_weights(): name = "qw_" + str(dim) define_quadrature_weights(name) fill_quadrature_weights_cache(name) - return name - - -def define_quadrature_weight(name): - quad_weights = name_quadrature_weights() - quad_iname = quadrature_iname() - return quadrature_preamble(code="auto {} = {}[{}];".format(name, quad_weights, quad_iname), - assignees=frozenset({name}) - ) + # Quadrature weighs is a globar argument for loopy + shape = name_quadrature_bound() + globalarg(name, shape=(shape,), dtype=numpy.float64) -def name_quadrature_weight(): - name = 'weight' - temporary_variable(name, shape=()) - define_quadrature_weight(name) return name @@ -232,16 +228,3 @@ def name_quadrature_order(): # Quadrature order from UFL estimation quad_order = quadrature_order() return str(quad_order) - - -def quadrature_loop_statement(): - pass -# include_file('dune/pdelab/common/quadraturerules.hh', filetag='operatorfile') -# qp = name_quadrature_point() -# from dune.perftool.pdelab.geometry import name_geometry -# geo = name_geometry() -# order = name_quadrature_order() -# return "const auto& {} : quadratureRule({}, {})".format(qp, -# geo, -# order, -# ) diff --git a/python/dune/perftool/sumfact/amatrix.py b/python/dune/perftool/sumfact/amatrix.py index b84d1788bfea74c98d20bbc4d4bd8dea8f9bc4c1..cf9f33c41b63c2fd5c3929ba87d77ea1c1e09007 100644 --- a/python/dune/perftool/sumfact/amatrix.py +++ b/python/dune/perftool/sumfact/amatrix.py @@ -230,7 +230,7 @@ def define_theta(name, transpose): shape = (basis_functions_per_direction(), quadrature_points_per_direction()) else: shape = (quadrature_points_per_direction(), basis_functions_per_direction()) - globalarg(name, shape=shape, dtype=numpy.float32, dim_tags="f,f") + globalarg(name, shape=shape, dtype=numpy.float64, dim_tags="f,f") initializer_list(name, [str(axis) for axis in shape], classtag="operator") construct_theta(name, transpose) return "{} {};".format(theta_type, name) diff --git a/python/dune/perftool/ufl/visitor.py b/python/dune/perftool/ufl/visitor.py index d87c5dcf57f395c6f6ef47359b44825557c776d8..e05411a07378215de24b3269722fec58cebb7581 100644 --- a/python/dune/perftool/ufl/visitor.py +++ b/python/dune/perftool/ufl/visitor.py @@ -256,7 +256,8 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker): return Variable(self.interface.name_unit_inner_normal()) def quadrature_weight(self, o): - return Variable(self.interface.name_quadrature_weight()) + self.inames.append(self.interface.quadrature_iname()) + return Subscript(Variable(self.interface.name_quadrature_weights()), (Variable(self.interface.quadrature_iname()),)) def jacobian_determinant(self, o): return Variable(self.interface.name_jacobian_determinant())