diff --git a/python/dune/perftool/loopy/target.py b/python/dune/perftool/loopy/target.py index b492f1374b7b7f3057aea78cf2a28921a320c15a..e60151028fe7857680728df5aeebe88f44a30c6f 100644 --- a/python/dune/perftool/loopy/target.py +++ b/python/dune/perftool/loopy/target.py @@ -161,7 +161,7 @@ class DuneASTBuilder(CASTBuilder): return CASTBuilder.get_temporary_decl(self, codegen_state, schedule_index, temp_var, decl_info) if temp_var.custom_declaration: - decl = temp_var.decl_method(temp_var.name, temp_var.shape, temp_var.shape_impl) + decl = temp_var.decl_method(temp_var.name, codegen_state.kernel, decl_info) if decl: return cgen.Line(decl) diff --git a/python/dune/perftool/loopy/temporary.py b/python/dune/perftool/loopy/temporary.py index 21e0e9d0117ad5872d298f3b0cab4fc88b4a69f0..2bf78ce94c573ca0f1614fc89b72fee52fa16333 100644 --- a/python/dune/perftool/loopy/temporary.py +++ b/python/dune/perftool/loopy/temporary.py @@ -28,7 +28,10 @@ def _temporary_type(shape_impl, shape, first=True): return "Dune::FieldMatrix<{}, {}, {}>".format(_type, shape[0], shape[1]) -def default_declaration(name, shape=(), shape_impl=()): +def default_declaration(name, kernel, decl_info): + shape = kernel.temporary_variables[name].shape + shape_impl = kernel.temporary_variables[name].shape_impl + # Determine the C++ type to use for this temporary. t = _temporary_type(shape_impl, shape) if len(shape_impl) == 0: @@ -45,10 +48,10 @@ def default_declaration(name, shape=(), shape_impl=()): return '{} {}(0.0);'.format(t, name) -def custom_base_storage_temporary_declaration(storage, dtype): - def _decl(name, *a): - from dune.perftool.loopy.target import numpy_to_cpp_dtype - _type = numpy_to_cpp_dtype(lp.types.NumpyType(dtype).dtype.name) +def custom_base_storage_temporary_declaration(storage): + def _decl(name, kernel, decl_info): + dtype = kernel.temporary_variables[name].dtype + _type = kernel.target.dtype_to_typename(decl_info.dtype) return "{0} *{1} = ({0} *){2};".format(_type, name, storage) return _decl @@ -71,7 +74,7 @@ class DuneTemporaryVariable(TemporaryVariable): if custom_base_storage and self.decl_method is None: assert shape_impl is None - self.decl_method = custom_base_storage_temporary_declaration(custom_base_storage, kwargs["dtype"]) + self.decl_method = custom_base_storage_temporary_declaration(custom_base_storage) self.custom_declaration = self.decl_method is not None diff --git a/python/dune/perftool/pdelab/basis.py b/python/dune/perftool/pdelab/basis.py index d4db8834090378d5f037bc037c11a91176a7ebf3..2c724f8e4a716c46475434d4f1949de6ba512632 100644 --- a/python/dune/perftool/pdelab/basis.py +++ b/python/dune/perftool/pdelab/basis.py @@ -86,7 +86,7 @@ def declare_cache_temporary(element, restriction, which): t_cache = type_localbasis_cache(element) lfs = name_leaf_lfs(element, restriction) - def decl(name, shape, shape_impl): + def decl(name, kernel, decl_info): return "typename {}::{}ReturnType {};".format(t_cache, which, name, diff --git a/python/dune/perftool/pdelab/function.py b/python/dune/perftool/pdelab/function.py index c10324003955d0bbe2bbbf53f3adc73c57fd10c4..c1dadef18fdcb8a60a88d06aff5fac186a80432d 100644 --- a/python/dune/perftool/pdelab/function.py +++ b/python/dune/perftool/pdelab/function.py @@ -19,7 +19,7 @@ def bind_gridfunction_to_element(gf, restriction): def declare_grid_function_range(gridfunction): - def _decl(name, *args): + def _decl(name, kernel, decl_info): return "typename decltype({})::Range {};".format(gridfunction, name) return _decl diff --git a/python/dune/perftool/pdelab/geometry.py b/python/dune/perftool/pdelab/geometry.py index c382faeea09e13208aa7155b120fb070789c80e6..d308917adbd3391d4b61832938b3a1c4f3355eb5 100644 --- a/python/dune/perftool/pdelab/geometry.py +++ b/python/dune/perftool/pdelab/geometry.py @@ -261,7 +261,7 @@ def evaluate_unit_outer_normal(name): @preamble -def declare_normal(name, shape, shape_impl): +def declare_normal(name, kernel, decl_info): ig = name_intersection_geometry_wrapper() return "auto {} = {}.centerUnitOuterNormal();".format(name, ig) @@ -300,7 +300,7 @@ def type_jacobian_inverse_transposed(restriction): @kernel_cached def define_jacobian_inverse_transposed_temporary(restriction): @preamble - def _define_jacobian_inverse_transposed_temporary(name, shape, shape_impl): + def _define_jacobian_inverse_transposed_temporary(name, kernel, decl_info): t = type_jacobian_inverse_transposed(restriction) return "{} {};".format(t, name, diff --git a/python/dune/perftool/sumfact/geometry.py b/python/dune/perftool/sumfact/geometry.py index 6afbe6238b6a7f7ce735dbbadb04b4ae791e6d23..9725688672c0c99329ca373b9ae158e21ac14c4a 100644 --- a/python/dune/perftool/sumfact/geometry.py +++ b/python/dune/perftool/sumfact/geometry.py @@ -40,11 +40,11 @@ class GeoCornersInput(SumfactKernelInputBase, ImmutableRecord): ImmutableRecord.__init__(self, dir=dir) def realize(self, sf, index, insn_dep): - from dune.perftool.sumfact.realization import name_buffer_storage, buffer_decl, get_sumfact_dtype - storage = name_buffer_storage(sf.buffer, 0) + from dune.perftool.sumfact.realization import name_buffer_storage name = name="input_{}".format(sf.buffer) temporary_variable(name, shape=(2 ** local_dimension(), sf.vector_width), + custom_base_storage=name_buffer_storage(sf.buffer, 0), decl_method=buffer_decl(storage, get_sumfact_dtype(sf)), managed=True, ) diff --git a/python/dune/perftool/sumfact/realization.py b/python/dune/perftool/sumfact/realization.py index 1d6c6219c0a8ca01a1156b0d2fd9a9a1b5ad599b..0ce8a59565da22d9e861ec55038b7617eb328bc0 100644 --- a/python/dune/perftool/sumfact/realization.py +++ b/python/dune/perftool/sumfact/realization.py @@ -90,7 +90,7 @@ def _realize_sum_factorization_kernel(sf): temporary_variable("{}_dummy".format(buf), shape=(10000,), custom_base_storage=buf, - decl_method=lambda *a: None, + decl_method=lambda n, k, di: None, ) # Realize the input if it is not direct