diff --git a/python/dune/perftool/loopy/target.py b/python/dune/perftool/loopy/target.py index cc27bf814d71bae47fa427454a5fa8e123de2734..50796ef981c624f7bf7f3e360b15c29ac566d7fe 100644 --- a/python/dune/perftool/loopy/target.py +++ b/python/dune/perftool/loopy/target.py @@ -5,7 +5,6 @@ from dune.perftool.generation import post_include from dune.perftool.generation.loopy import DuneGlobalArg from dune.perftool.loopy.temporary import DuneTemporaryVariable from dune.perftool.loopy.vcl import VCLTypeRegistry -from dune.perftool.options import get_option from dune.perftool.generation import (include_file, retrieve_cache_functions, ) @@ -30,6 +29,7 @@ def _type_to_op_counter_type(type): def numpy_to_cpp_dtype(key): + from dune.perftool.options import get_option _registry = {'float32': 'float', 'int32': 'int', 'float64': 'double', @@ -76,12 +76,12 @@ class DuneExpressionToCExpressionMapper(ExpressionToCExpressionMapper): if type_context == "f": if get_option('opcounter'): type = _type_to_op_counter_type('float') - return Literal("{}({})".format(type,repr(float(expr))+'f')) - return Literal(repr(float(expr))+"f") + return Literal("{}({})".format(type, repr(float(expr)) + 'f')) + return Literal(repr(float(expr)) + "f") elif type_context == "d": if get_option('opcounter'): type = _type_to_op_counter_type('double') - return Literal("{}({})".format(type,repr(float(expr)))) + return Literal("{}({})".format(type, repr(float(expr)))) return Literal(repr(float(expr))) elif type_context == "i": return int(expr) @@ -90,7 +90,7 @@ class DuneExpressionToCExpressionMapper(ExpressionToCExpressionMapper): return int(expr) raise RuntimeError("don't know how to generate code " - "for constant '%s'" % expr) + "for constant '%s'" % expr) class DuneCExpressionToCodeMapper(CExpressionToCodeMapper): diff --git a/python/dune/perftool/pdelab/parameter.py b/python/dune/perftool/pdelab/parameter.py index 8b48eb3bc2bc851c579cd7f4e2b896d1c341000e..0e7ffe69c2fbdae21d18edca4af424aa1a793d01 100644 --- a/python/dune/perftool/pdelab/parameter.py +++ b/python/dune/perftool/pdelab/parameter.py @@ -10,7 +10,6 @@ from dune.perftool.generation import (class_basename, preamble, temporary_variable ) -from dune.perftool.loopy.target import numpy_to_cpp_dtype from dune.perftool.pdelab.geometry import (name_cell, name_dimension, name_intersection, @@ -212,9 +211,11 @@ def construct_nested_fieldvector(t, shape): @kernel_cached -def cell_parameter_function(name, expr, restriction, cellwise_constant, t=numpy_to_cpp_dtype('float64')): +def cell_parameter_function(name, expr, restriction, cellwise_constant, t='float64'): shape = expr.ufl_element().value_shape() shape_impl = ('fv',) * len(shape) + from dune.perftool.loopy.target import numpy_to_cpp_dtype + t = numpy_to_cpp_dtype(t) define_parameter_function_class_member(name, expr, t, shape, True) if cellwise_constant: evaluate_cellwise_constant_parameter_function(name, restriction) @@ -224,9 +225,11 @@ def cell_parameter_function(name, expr, restriction, cellwise_constant, t=numpy_ @kernel_cached -def intersection_parameter_function(name, expr, cellwise_constant, t=numpy_to_cpp_dtype('float64')): +def intersection_parameter_function(name, expr, cellwise_constant, t='float64'): shape = expr.ufl_element().value_shape() shape_impl = ('fv',) * len(shape) + from dune.perftool.loopy.target import numpy_to_cpp_dtype + t = numpy_to_cpp_dtype(t) define_parameter_function_class_member(name, expr, t, shape, False) if cellwise_constant: evaluate_intersectionwise_constant_parameter_function(name)