From db8b9a8b96e67a1a3d3a8e601bce1172fed7c941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20He=C3=9F?= <rene.hess@iwr.uni-heidelberg.de> Date: Thu, 1 Dec 2016 14:29:19 +0100 Subject: [PATCH] Make it possible to activate opcounting without really doing anything --- dune/perftool/common/timer.hh | 2 +- python/dune/perftool/options.py | 1 + python/dune/perftool/pdelab/driver.py | 6 +++++- python/dune/perftool/pdelab/localoperator.py | 6 ++++-- .../poisson_2d_dg_quadrilateral.mini | 1 + 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dune/perftool/common/timer.hh b/dune/perftool/common/timer.hh index dda15b35..84f7caf4 100644 --- a/dune/perftool/common/timer.hh +++ b/dune/perftool/common/timer.hh @@ -3,7 +3,7 @@ #include <chrono> -# include <dune/perftool/common/opcounter.hh> +#include <dune/perftool/common/opcounter.hh> #define HP_TIMER_OPCOUNTER oc::OpCounter<double> diff --git a/python/dune/perftool/options.py b/python/dune/perftool/options.py index 16d45c59..ee86ec1f 100644 --- a/python/dune/perftool/options.py +++ b/python/dune/perftool/options.py @@ -40,6 +40,7 @@ def get_form_compiler_arguments(): parser.add_argument("--constant-transformation-matrix", action="store_true", help="set option if the jacobian of the transformation is constant on a cell") parser.add_argument("--ini-file", type=str, help="An inifile to use. A generated driver will be hard-coded to it, a [formcompiler] section will be used as default values to form compiler arguments (use snake case)") parser.add_argument("--timer", action="store_true", help="measure times") + parser.add_argument("--opcounter", action="store_false", help="Count operations. Should only be used with yaspgrid. Timer should be set.") parser.add_argument("--project-basedir", type=str, help="The base (build) directory of the dune-perftool project") # TODO at some point this help description should be updated parser.add_argument("--sumfact", action="store_true", help="Use sumfactorization") diff --git a/python/dune/perftool/pdelab/driver.py b/python/dune/perftool/pdelab/driver.py index 9b8efbea..79707114 100644 --- a/python/dune/perftool/pdelab/driver.py +++ b/python/dune/perftool/pdelab/driver.py @@ -1110,6 +1110,10 @@ def dune_solve(): # Necessary includes and defines from dune.perftool.generation import pre_include from dune.perftool.generation import post_include + + # TODO check that we are using YASP? + if get_option('opcounter'): + pre_include("#define ENABLE_COUNTER", filetag="driver") pre_include("#define ENABLE_HP_TIMERS", filetag="driver") include_file("dune/perftool/common/timer.hh", filetag="driver") post_include("HP_DECLARE_TIMER(total);", filetag="driver") @@ -1125,7 +1129,7 @@ def dune_solve(): solve = ["HP_TIMER_START(total);", "{}".format(solve), "HP_TIMER_STOP(total);", - "char* exec = argv[0];" + "char* exec = argv[0];", "DUMP_TIMER(total, {}, true);".format(timestream), ] solve.extend(print_times) diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py index 30454153..b53eefb5 100644 --- a/python/dune/perftool/pdelab/localoperator.py +++ b/python/dune/perftool/pdelab/localoperator.py @@ -575,12 +575,14 @@ class TimerMethod(ClassMember): reset = name_time_dumper_reset() t = name_time_dumper_t() ex = name_time_dumper_exec() + + # TODO: operator counting only works if alpha_volume_kernel exists content = ["template <typename Stream>", "void dump_timers(Stream& {}, char* {}, bool {})".format(os, ex, reset), "{", " double {} = 0.0;".format(t), - "#ifdef ENABLE_COUNTERS", - " auto counter = HP_TIMER_OPCOUNTERS({})", + "#ifdef ENABLE_COUNTER", + " auto counter = HP_TIMER_OPCOUNTERS(alpha_volume_kernel);", " counter.reset();", "#endif", ""] diff --git a/test/poisson/dimension-grid-variations/poisson_2d_dg_quadrilateral.mini b/test/poisson/dimension-grid-variations/poisson_2d_dg_quadrilateral.mini index ca35eccb..d7507ae5 100644 --- a/test/poisson/dimension-grid-variations/poisson_2d_dg_quadrilateral.mini +++ b/test/poisson/dimension-grid-variations/poisson_2d_dg_quadrilateral.mini @@ -11,3 +11,4 @@ extension = vtu exact_solution_expression = g compare_dofs = 1e-1 compare_l2errorsquared = 1e-4 +opcounter = 1 \ No newline at end of file -- GitLab