diff --git a/python/dune/perftool/__init__.py b/python/dune/perftool/__init__.py index 02ef874ff476ba7fc9bca5ecf261f0fcf7073edb..b907a8008731bcb55225ce08fc250d821da4a26e 100644 --- a/python/dune/perftool/__init__.py +++ b/python/dune/perftool/__init__.py @@ -1,4 +1,6 @@ -class Restriction: - NONE = 0 - NEGATIVE = 1 - POSITIVE = 2 +from dune.perftool.options import get_option + +# Trigger some imports that are needed to have all backend implementations visible +# to the selection mechanisms +import dune.perftool.pdelab +import dune.perftool.sumfact diff --git a/python/dune/perftool/pdelab/__init__.py b/python/dune/perftool/pdelab/__init__.py index abbc10ffa31ea40dc38fa46bdcfe32a7fdbf26b7..d8d6ab1d84b8759dcdc241498441e048a6222d23 100644 --- a/python/dune/perftool/pdelab/__init__.py +++ b/python/dune/perftool/pdelab/__init__.py @@ -1,30 +1,13 @@ """ The pdelab specific parts of the code generation process """ -from dune.perftool.generation import (preamble, - cached, - ) - - -# Now define some commonly used generators that do not fall into a specific category -@cached -def name_index(index): - from ufl.classes import MultiIndex, Index - if isinstance(index, Index): - # This failed for index > 9 because ufl placed curly brackets around - # return str(index) - return "i_{}".format(index.count()) - if isinstance(index, MultiIndex): - assert len(index) == 1 - # return str(index._indices[0]) - return "i_{}".format(index._indices[0].count()) - raise NotImplementedError - - -def restricted_name(name, restriction): - from dune.perftool import Restriction - if restriction == Restriction.NONE: - return name - if restriction == Restriction.POSITIVE: - return name + '_n' - if restriction == Restriction.NEGATIVE: - return name + '_s' +# Trigger some imports that are needed to have all backend implementations visible +# to the selection mechanisms +import dune.perftool.pdelab.argument +import dune.perftool.pdelab.basis +import dune.perftool.pdelab.driver +import dune.perftool.pdelab.geometry +import dune.perftool.pdelab.localoperator +import dune.perftool.pdelab.parameter +import dune.perftool.pdelab.quadrature +import dune.perftool.pdelab.signatures +import dune.perftool.pdelab.spaces \ No newline at end of file diff --git a/python/dune/perftool/pdelab/argument.py b/python/dune/perftool/pdelab/argument.py index 06d4a75dc02bfb21051eb16311ed2c7d03c0c55a..0e81542cd1259e42c7823159187a03500dc72dcf 100644 --- a/python/dune/perftool/pdelab/argument.py +++ b/python/dune/perftool/pdelab/argument.py @@ -8,15 +8,14 @@ Namely: from dune.perftool.options import get_option from dune.perftool.generation import (domain, function_mangler, + get_backend, iname, pymbolic_expr, globalarg, valuearg, get_global_context_value ) -from dune.perftool.pdelab import (name_index, - restricted_name, - ) +from dune.perftool.pdelab.index import name_index from dune.perftool.pdelab.basis import (evaluate_coefficient, evaluate_coefficient_gradient, name_basis, @@ -24,7 +23,8 @@ from dune.perftool.pdelab.basis import (evaluate_coefficient, from dune.perftool.pdelab.spaces import (lfs_iname, name_lfs_bound, ) -from dune.perftool import Restriction +from dune.perftool.pdelab.restriction import restricted_name +from dune.perftool.ufl.modified_terminals import Restriction from pymbolic.primitives import Call, Subscript, Variable @@ -95,16 +95,6 @@ def name_trialfunction_gradient(element, restriction, component): rawname = "gradu" + "_".join(str(c) for c in component) name = restricted_name(rawname, restriction) container = name_coefficientcontainer(restriction) - - # TODO - # - # This is just a temporary test used to create an A-matrix as - # local operator class member. Right now it doesn't evaluate - # anything. - if get_option("sumfact") and restriction == Restriction.NONE: - from dune.perftool.sumfact import start_sumfactorization - start_sumfactorization(element, container, restriction, component) - evaluate_coefficient_gradient(element, name, container, restriction, component) return name diff --git a/python/dune/perftool/pdelab/basis.py b/python/dune/perftool/pdelab/basis.py index ced7d2da58613b7ac8e6d583861ff0220fe3ace8..09ecddb0e0c6cdd4908bcd7c77b7b1f45b44004e 100644 --- a/python/dune/perftool/pdelab/basis.py +++ b/python/dune/perftool/pdelab/basis.py @@ -27,8 +27,7 @@ from dune.perftool.pdelab.localoperator import (lop_template_ansatz_gfs, lop_template_test_gfs, ) from dune.perftool.pdelab.driver import FEM_name_mangling - -from dune.perftool.pdelab import restricted_name +from dune.perftool.pdelab.restriction import restricted_name from pymbolic.primitives import Product, Subscript, Variable from loopy import Reduction diff --git a/python/dune/perftool/pdelab/geometry.py b/python/dune/perftool/pdelab/geometry.py index f4d476bc6d2c1f07291e12a6b8d88393f029e9ae..8dd41c1237c43e76d11a10d4b94365d98fbdd472 100644 --- a/python/dune/perftool/pdelab/geometry.py +++ b/python/dune/perftool/pdelab/geometry.py @@ -1,5 +1,5 @@ -from dune.perftool import Restriction -from dune.perftool.pdelab import restricted_name +from dune.perftool.ufl.modified_terminals import Restriction +from dune.perftool.pdelab.restriction import restricted_name from dune.perftool.generation import (cached, domain, get_global_context_value, diff --git a/python/dune/perftool/pdelab/index.py b/python/dune/perftool/pdelab/index.py new file mode 100644 index 0000000000000000000000000000000000000000..cc87edfdcb3ff2be39ec3fe4fa136c49e389b5cf --- /dev/null +++ b/python/dune/perftool/pdelab/index.py @@ -0,0 +1,17 @@ +from dune.perftool.generation import cached + +from ufl.classes import MultiIndex, Index + + +# Now define some commonly used generators that do not fall into a specific category +@cached +def name_index(index): + if isinstance(index, Index): + # This failed for index > 9 because ufl placed curly brackets around + # return str(index) + return "i_{}".format(index.count()) + if isinstance(index, MultiIndex): + assert len(index) == 1 + # return str(index._indices[0]) + return "i_{}".format(index._indices[0].count()) + raise NotImplementedError diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py index 3c008a173b98bcfcd06fb77f2948d4b6a76e2462..7a299ab70e4da7ccc339f9e5ff39e346722ef040 100644 --- a/python/dune/perftool/pdelab/localoperator.py +++ b/python/dune/perftool/pdelab/localoperator.py @@ -20,7 +20,7 @@ from dune.perftool.cgen.clazz import (AccessModifier, BaseClass, ClassMember, ) -from dune.perftool import Restriction +from dune.perftool.ufl.modified_terminals import Restriction from pymbolic.primitives import Variable from pytools import Record @@ -355,7 +355,7 @@ def boundary_predicates(expr, measure, subdomain_id): @iname def grad_iname(index, dim): - from dune.perftool.pdelab import name_index + from dune.perftool.pdelab.index import name_index name = name_index(index) domain(name, dim) return name diff --git a/python/dune/perftool/pdelab/quadrature.py b/python/dune/perftool/pdelab/quadrature.py index bf9431779060dbb33bd1c49a9cd84c2a4aad9441..b778de54c01aeb7160a0af100caff893d2c1c85d 100644 --- a/python/dune/perftool/pdelab/quadrature.py +++ b/python/dune/perftool/pdelab/quadrature.py @@ -1,5 +1,5 @@ -from dune.perftool import Restriction -from dune.perftool.generation import (cached, +from dune.perftool.generation import (backend, + cached, domain, get_global_context_value, iname, @@ -8,6 +8,7 @@ from dune.perftool.generation import (cached, temporary_variable, ) from dune.perftool.options import get_option +from dune.perftool.ufl.modified_terminals import Restriction @iname diff --git a/python/dune/perftool/pdelab/restriction.py b/python/dune/perftool/pdelab/restriction.py new file mode 100644 index 0000000000000000000000000000000000000000..e889fcd64c743e6cc301aa46fa1d71162c2662d7 --- /dev/null +++ b/python/dune/perftool/pdelab/restriction.py @@ -0,0 +1,10 @@ +from dune.perftool.ufl.modified_terminals import Restriction + + +def restricted_name(name, restriction): + if restriction == Restriction.NONE: + return name + if restriction == Restriction.POSITIVE: + return name + '_n' + if restriction == Restriction.NEGATIVE: + return name + '_s' \ No newline at end of file diff --git a/python/dune/perftool/pdelab/signatures.py b/python/dune/perftool/pdelab/signatures.py index 3a40e636de6ba3224fdd1aaab2102419d3b4f1e6..b329245d2d6d2c5e04f60cc4ebcdca1439df9666 100644 --- a/python/dune/perftool/pdelab/signatures.py +++ b/python/dune/perftool/pdelab/signatures.py @@ -1,6 +1,6 @@ """ Signatures for PDELab local opreator assembly functions """ -from dune.perftool import Restriction +from dune.perftool.ufl.modified_terminals import Restriction from dune.perftool.pdelab.geometry import (name_geometry_wrapper, type_geometry_wrapper, ) diff --git a/python/dune/perftool/pdelab/spaces.py b/python/dune/perftool/pdelab/spaces.py index e439425f36e8964d407814a2042337578b12dc34..07403a8641ba8701ccd3a89a8c9c619ef8167df9 100644 --- a/python/dune/perftool/pdelab/spaces.py +++ b/python/dune/perftool/pdelab/spaces.py @@ -6,7 +6,7 @@ from dune.perftool.generation import (domain, include_file, preamble, ) -from dune.perftool.pdelab import restricted_name +from dune.perftool.pdelab.restriction import restricted_name from loopy import CallMangleInfo from loopy.symbolic import FunctionIdentifier diff --git a/python/dune/perftool/sumfact/__init__.py b/python/dune/perftool/sumfact/__init__.py index 793cbde027e0e7c6a9b8278adbfa66cd60d38156..4f1ce7c9d8dbe7946c664dc9ebe2f1b51fd340f7 100644 --- a/python/dune/perftool/sumfact/__init__.py +++ b/python/dune/perftool/sumfact/__init__.py @@ -1 +1,7 @@ +# Trigger some imports that are needed to have all backend implementations visible +# to the selection mechanisms +import dune.perftool.sumfact.amatrix +import dune.perftool.sumfact.quadrature +import dune.perftool.sumfact.sumfact + from dune.perftool.sumfact.sumfact import start_sumfactorization diff --git a/python/dune/perftool/sumfact/amatrix.py b/python/dune/perftool/sumfact/amatrix.py index 9d2e249886c0075fe318449cfede12183ec24d2d..968f4f16de04ce7daace2e19f74185ff24380222 100644 --- a/python/dune/perftool/sumfact/amatrix.py +++ b/python/dune/perftool/sumfact/amatrix.py @@ -1,4 +1,4 @@ -from dune.perftool import Restriction +from dune.perftool.ufl.modified_terminals import Restriction from dune.perftool.options import get_option diff --git a/python/dune/perftool/ufl/modified_terminals.py b/python/dune/perftool/ufl/modified_terminals.py index 33319b273143455b599bcc1665ea4ff81d35182f..4ba1d0a3d34673b19cf04a3819f12ebaee03e353 100644 --- a/python/dune/perftool/ufl/modified_terminals.py +++ b/python/dune/perftool/ufl/modified_terminals.py @@ -1,11 +1,16 @@ """ A module mimicking some functionality of uflacs' modified terminals """ from ufl.algorithms import MultiFunction -from dune.perftool import Restriction from ufl.classes import MultiIndex from pytools import Record +class Restriction: + NONE = 0 + NEGATIVE = 1 + POSITIVE = 2 + + class ModifiedArgument(Record): def __init__(self, expr=None, diff --git a/python/dune/perftool/ufl/visitor.py b/python/dune/perftool/ufl/visitor.py index 70d77358bdb105eeb5d09b7635214190d2517510..ba3d98c5c87d1b75016ce301ea76a30910478b77 100644 --- a/python/dune/perftool/ufl/visitor.py +++ b/python/dune/perftool/ufl/visitor.py @@ -3,8 +3,7 @@ This module defines the main visitor algorithm transforming ufl expressions to pymbolic and loopy. """ -from dune.perftool import Restriction -from dune.perftool.ufl.modified_terminals import ModifiedTerminalTracker +from dune.perftool.ufl.modified_terminals import ModifiedTerminalTracker, Restriction from dune.perftool.generation import (domain, get_temporary_name, global_context, @@ -185,7 +184,7 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker): ind = o.ufl_operands[1][0] redinames = additional_inames + (ind,) shape = o.ufl_operands[0].ufl_index_dimensions[0] - from dune.perftool.pdelab import name_index + from dune.perftool.pdelab.index import name_index domain(name_index(ind), shape) # If the left operand is an index sum to, we do it in one reduction @@ -211,7 +210,7 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker): return index._value else: from pymbolic.primitives import Variable - from dune.perftool.pdelab import name_index + from dune.perftool.pdelab.index import name_index if index in self.dimension_indices: from dune.perftool.pdelab.geometry import dimension_iname self.inames.append(self.dimension_indices[index])