From d5bf77e52dd2702f843cf7ffc0be4cfb1ac04373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20He=C3=9F?= <rene.hess@iwr.uni-heidelberg.de> Date: Fri, 2 Dec 2016 15:06:19 +0100 Subject: [PATCH] Time residual evaluation --- python/dune/perftool/pdelab/driver.py | 67 ++++++++++++++++++++------- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/python/dune/perftool/pdelab/driver.py b/python/dune/perftool/pdelab/driver.py index 842c2323..c256784a 100644 --- a/python/dune/perftool/pdelab/driver.py +++ b/python/dune/perftool/pdelab/driver.py @@ -1313,23 +1313,6 @@ def name_test_fail_variable(): return name -@preamble -def print_residual(): - ini = name_initree() - formdata = _driver_data['formdata'] - n_go = name_gridoperator(formdata) - v = name_vector(formdata) - t_v = type_vector(formdata) - - return ["if ({}.get<bool>(\"printresidual\", false)) {{".format(ini), - " using Dune::PDELab::Backend::native;", - " {} r({});".format(t_v, v), - " r=0.0;", - " {}.residual({}, r);".format(n_go, v), - " Dune::printvector(std::cout, native(r), \"residual vector\", \"row\");", - "}"] - - @cached def setup_timer(): assert(get_option('timer')) @@ -1349,6 +1332,38 @@ def define_exec(): return "char* exec = argv[0];" +@preamble +def evaluate_residual_timer(): + formdata = _driver_data['formdata'] + n_go = name_gridoperator(formdata) + v = name_vector(formdata) + t_v = type_vector(formdata) + + # Write back times + setup_timer() + from dune.perftool.generation import post_include + post_include("HP_DECLARE_TIMER(residual_evaluation);", filetag="driver") + timestream = name_timing_stream() + define_exec() + print_times = [] + from dune.perftool.generation import get_global_context_value + formdatas = get_global_context_value("formdatas") + for formdata in formdatas: + lop_name = name_localoperator(formdata) + print_times.append("{}.dump_timers({}, argv[0], true);".format(lop_name, timestream)) + + evaluation = ["using Dune::PDELab::Backend::native;", + "{} r({});".format(t_v, v), + "r=0.0;", + "HP_TIMER_START(residual_evaluation);", + "{}.residual({}, r);".format(n_go, v), + "HP_TIMER_STOP(residual_evaluation);", + "DUMP_TIMER(residual_evaluation, {}, true);".format(timestream)] + evaluation.extend(print_times) + + return evaluation + + @preamble def assemble_matrix_timer(): formdata = _driver_data['formdata'] @@ -1381,6 +1396,23 @@ def assemble_matrix_timer(): return assembly +@preamble +def print_residual(): + ini = name_initree() + formdata = _driver_data['formdata'] + n_go = name_gridoperator(formdata) + v = name_vector(formdata) + t_v = type_vector(formdata) + + return ["if ({}.get<bool>(\"printresidual\", false)) {{".format(ini), + " using Dune::PDELab::Backend::native;", + " {} r({});".format(t_v, v), + " r=0.0;", + " {}.residual({}, r);".format(n_go, v), + " Dune::printvector(std::cout, native(r), \"residual vector\", \"row\");", + "}"] + + @preamble def print_matrix(): formdata = _driver_data['formdata'] @@ -1593,6 +1625,7 @@ def generate_driver(formdatas, data): if get_option("opcounter"): # In case of operator conunting we only assemble the matrix and evaluate the residual assemble_matrix_timer() + evaluate_residual_timer() elif is_stationary(): # We could also use solve if we are not interested in visualization vtkoutput() -- GitLab