diff --git a/python/dune/perftool/compile.py b/python/dune/perftool/compile.py index f55ec87c890b5840b7a6816a4fed2c0e083b12d6..101ed2a7e827f8369ed72df5827dd6a7f376b367 100644 --- a/python/dune/perftool/compile.py +++ b/python/dune/perftool/compile.py @@ -16,7 +16,6 @@ from ufl.algorithms.formfiles import interpret_ufl_namespace from dune.perftool.generation import (delete_cache_items, global_context, ) -from dune.perftool.interactive import start_interactive_session from dune.perftool.options import get_option, initialize_options from dune.perftool.pdelab.driver import generate_driver from dune.perftool.pdelab.localoperator import (generate_localoperator_basefile, @@ -135,10 +134,6 @@ def compile_form(): if get_option("operator_file"): kernels = generate_localoperator_kernels(formdata, data) - # TODO insert sophisticated analysis/feedback loops here - if get_option("interactive"): - start_interactive_session(kernels) - # Create c++ file from kernels if get_option("operator_file"): filename = name_localoperator_file(formdata, data) diff --git a/python/dune/perftool/interactive.py b/python/dune/perftool/interactive.py deleted file mode 100644 index 77094c7524fc2bc5d6a1dc1e0b4254458056ac35..0000000000000000000000000000000000000000 --- a/python/dune/perftool/interactive.py +++ /dev/null @@ -1,144 +0,0 @@ -from __future__ import print_function -from functools import partial - -from dune.perftool.generation import global_context -from dune.perftool.loopy.transformations import get_loopy_transformations -from dune.perftool.pdelab.localoperator import LoopyKernelMethod -from dune.perftool.pdelab.signatures import assembly_routine_signature - -import os - - -# Use the builtin 'input' in python2 and 'raw_input' in python3 -try: - input = raw_input -except: - pass - - -def clear(): - os.system('cls' if os.name == 'nt' else 'clear') - - -def kernel_name(v): - first = None - if v[1] == "residual": - first = "alpha" - if v[1] == "jacobian": - first = "jacobian" - assert first - - second = None - if v[0] == "cell": - second = "volume" - if v[0] == "exterior_facet": - second = "boundary" - if v[0] == "interior_facet": - second = "skeleton" - assert second - - return "{}_{}".format(first, second) - - -def show_kernel(which, kernel): - clear() - print("Showing the loo.py kernel for {}:\n".format(kernel_name(which))) - print(kernel.stringify(with_dependencies=True)) - print("Press Return to return to the previous menu") - input() - return kernel - - -def choose_transformation(which, kernel): - choice = None - while choice != "q": - clear() - keymap = {} - print("Choose one of the following transformations to apply to {}:\n".format(kernel_name(which))) - - print("Transformations:") - for i, v in enumerate(get_loopy_transformations().values()): - print(" {}) {}".format(chr(ord('a') + i), v.name)) - if v.description: - print(" {}".format(v.description)) - keymap[chr(ord('a') + i)] = v - - print("\n q) Return to kernel options") - print("\nYour choice:") - - choice = input().lower() - try: - kernel = keymap[choice](kernel) - except KeyError: - pass - - return kernel - - -def show_code(which, kernel): - clear() - print("Showing the generated dune-pdelab code for {}:\n".format(kernel_name(which))) - - with global_context(integral_type=which[0], form_type=which[1]): - signature = assembly_routine_signature() - print("".join(LoopyKernelMethod(signature, kernel).generate())) - - print("Press Return to return to the previous menu") - input() - return kernel - - -def optimize_kernel(which, kernels): - kernel = kernels[which] - choice = None - - while choice != "q": - clear() - print("Optimizing kernel {}:\n".format(kernel_name(which))) - - print("Available options:") - print(" a) Show the loopy kernel") - print(" b) Apply loopy transformation") - print(" c) Show generated PDELab code for this kernel.") - - print("\n q) Return to the kernel overview") - print("\nYour choice:") - - choice = input().lower() - try: - kernel = {'a': partial(show_kernel, which), - 'b': partial(choose_transformation, which), - 'c': partial(show_code, which) - }[choice](kernel) - except KeyError: - pass - - kernels[which] = kernel - - -def kernel_choice(kernels): - choice = None - while choice != "q": - clear() - print("The following kernels are in the input. Pick one to optimize:") - - keymap = {} - for i, k in enumerate(kernels.keys()): - print(" {}) {}".format(chr(ord('a') + i), kernel_name(k))) - keymap[chr(ord('a') + i)] = partial(optimize_kernel, k) - - print("\n q) End this interactive session and proceed to code generation") - - print("\nYour choice: ") - choice = input().lower() - try: - keymap[choice](kernels) - except KeyError: - pass - - -def start_interactive_session(kernels): - clear() - print("Welcome to the dune-perftool interactive mode!\n") - - kernel_choice(kernels) diff --git a/python/dune/perftool/loopy/transformations/__init__.py b/python/dune/perftool/loopy/transformations/__init__.py index db43b04544a9d0852d9181843e2a0fd554ac2bb6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/python/dune/perftool/loopy/transformations/__init__.py +++ b/python/dune/perftool/loopy/transformations/__init__.py @@ -1,35 +0,0 @@ -""" Infrastructure for loopy transformations. -These are registered to list them in interactive mode -""" - -_loopy_trafo_registry = {} - - -def get_loopy_transformations(): - return _loopy_trafo_registry - - -class LoopyTransformationWrapper(object): - def __init__(self, f, name=None, description=""): - self.func = f - self.name = name - self.description = description - - assert name - assert name not in _loopy_trafo_registry - - _loopy_trafo_registry[name] = self - - def __call__(self, kernel): - return self.func(kernel) - - -def loopy_transformation(_positional_arg=None, **kwargs): - assert not _positional_arg - return lambda f: LoopyTransformationWrapper(f, **kwargs) - - -# Just for debugging purposes we add an identity transformation here. -@loopy_transformation(name="identity", description='''Does not change the kernel. Proof of concept implementation''') -def _identity(kernel): - return kernel diff --git a/python/dune/perftool/options.py b/python/dune/perftool/options.py index e77a3fccb5a173234f98cfa3532e50fbec5f34bc..23733a7a4031fb389cc6359d7d209ffa5cb9ca18 100644 --- a/python/dune/perftool/options.py +++ b/python/dune/perftool/options.py @@ -42,7 +42,6 @@ class PerftoolOptionsArray(ImmutableRecord): explicit_time_stepping = PerftoolOption(default=False, helpstr="use explicit time stepping") exact_solution_expression = PerftoolOption(helpstr="name of the exact solution expression in the ufl file") compare_l2errorsquared = PerftoolOption(helpstr="maximal allowed l2 error squared of difference between numerical solution and interpolation of exact solution (NOTE: requires --exact-solution-expression)") - interactive = PerftoolOption(default=False, helpstr="whether the optimization process should be guided interactively (also useful for debugging)") print_transformations = PerftoolOption(default=False, helpstr="print out dot files after ufl tree transformations") print_transformations_dir = PerftoolOption(default=".", helpstr="place where to put dot files (can be omitted)") quadrature_order = PerftoolOption(_type=int, helpstr="Quadrature order used for all integrals.")