From 4fd656262f27ac9323eef2dd5a1fc78f6667de01 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Tue, 10 Oct 2017 14:55:05 +0200
Subject: [PATCH] Also add level to operation counting

Just for consistency in postprocessing
---
 dune/perftool/common/opcounter.hh    | 26 +++++++++++++-------------
 dune/perftool/common/timer_chrono.hh |  4 ++--
 dune/perftool/common/timer_tsc.hh    |  4 ++--
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/dune/perftool/common/opcounter.hh b/dune/perftool/common/opcounter.hh
index 9bcd4ce2..c3d997e4 100644
--- a/dune/perftool/common/opcounter.hh
+++ b/dune/perftool/common/opcounter.hh
@@ -159,21 +159,21 @@ namespace oc {
       }
 
       template<typename Stream>
-      void reportOperations(Stream& os, std::string exec, std::string kernel, bool doReset = false)
+      void reportOperations(Stream& os, int level, std::string exec, std::string kernel, bool doReset = false)
       {
         auto total = addition_count + multiplication_count + division_count + exp_count + pow_count + sin_count + sqrt_count + comparison_count;
         if (total == 0)
           return;
-        os << exec << " " << kernel << " additions " << addition_count << std::endl
-           << exec << " " << kernel << " multiplications " << multiplication_count << std::endl
-           << exec << " " << kernel << " divisions " << division_count << std::endl
-           << exec << " " << kernel << " exp " << exp_count << std::endl
-           << exec << " " << kernel << " pow " << pow_count << std::endl
-           << exec << " " << kernel << " sin " << sin_count << std::endl
-           << exec << " " << kernel << " sqrt " << sqrt_count << std::endl
-           << exec << " " << kernel << " comparisons " << comparison_count << std::endl
-           << exec << " " << kernel << " blends " << blend_count << std::endl
-           << exec << " " << kernel << " totalops " << total << std::endl;
+        os << level << " " << exec << " " << kernel << " additions " << addition_count << std::endl
+           << level << " " << exec << " " << kernel << " multiplications " << multiplication_count << std::endl
+           << level << " " << exec << " " << kernel << " divisions " << division_count << std::endl
+           << level << " " << exec << " " << kernel << " exp " << exp_count << std::endl
+           << level << " " << exec << " " << kernel << " pow " << pow_count << std::endl
+           << level << " " << exec << " " << kernel << " sin " << sin_count << std::endl
+           << level << " " << exec << " " << kernel << " sqrt " << sqrt_count << std::endl
+           << level << " " << exec << " " << kernel << " comparisons " << comparison_count << std::endl
+           << level << " " << exec << " " << kernel << " blends " << blend_count << std::endl
+           << level << " " << exec << " " << kernel << " totalops " << total << std::endl;
 
         if (doReset)
           reset();
@@ -241,9 +241,9 @@ namespace oc {
     }
 
     template<typename Stream>
-    static void reportOperations(Stream& os, std::string exec, std::string kernel, bool doReset = false)
+    static void reportOperations(Stream& os, int level, std::string exec, std::string kernel, bool doReset = false)
     {
-      counters.reportOperations(os, exec, kernel, doReset);
+      counters.reportOperations(os, level, exec, kernel, doReset);
     }
 
     static Counters counters;
diff --git a/dune/perftool/common/timer_chrono.hh b/dune/perftool/common/timer_chrono.hh
index 91fee78e..d1b0bd9b 100644
--- a/dune/perftool/common/timer_chrono.hh
+++ b/dune/perftool/common/timer_chrono.hh
@@ -82,14 +82,14 @@
 #define DUMP_TIMER(level,name,os,reset)\
   if (HP_TIMER_ELAPSED(name) > 1e-12) \
     os << #level << " " << ident << " " << #name << " time " << HP_TIMER_ELAPSED(name) << std::endl; \
-  HP_TIMER_OPCOUNTERS(name).reportOperations(os,ident,#name,reset);
+  HP_TIMER_OPCOUNTERS(name).reportOperations(os,#level,ident,#name,reset);
 
 #define DUMP_AND_ACCUMULATE_TIMER(level,name,os,reset,time,ops)  \
   if (HP_TIMER_ELAPSED(name) > 1e-12) \
     os << #level << " " << ident << " " << #name << " time " << HP_TIMER_ELAPSED(name) << std::endl; \
   time += HP_TIMER_ELAPSED(name); \
   ops += HP_TIMER_OPCOUNTERS(name); \
-  HP_TIMER_OPCOUNTERS(name).reportOperations(os,ident,#name,reset);
+  HP_TIMER_OPCOUNTERS(name).reportOperations(os,#level,ident,#name,reset);
 
 #elif defined ENABLE_HP_TIMERS
 
diff --git a/dune/perftool/common/timer_tsc.hh b/dune/perftool/common/timer_tsc.hh
index 3089ec3f..2a92831f 100644
--- a/dune/perftool/common/timer_tsc.hh
+++ b/dune/perftool/common/timer_tsc.hh
@@ -82,12 +82,12 @@
     os << #level << " " << ident << " " << #name << " time " << Dune::PDELab::TSC::seconds(HP_TIMER_DURATION(name)) << std::endl; \
   HP_TIMER_OPCOUNTERS(name).reportOperations(os,ident,#name,reset);
 
-#define DUMP_AND_ACCUMULATE_TIMER(level,name,os,reset,time,ops)  \
+#define DUMP_AND_ACCUMULATE_TIMER(level,#level,name,os,reset,time,ops)  \
   if (HP_TIMER_DURATION(name) > 1e-12) \
     os << #level << " " << ident << " " << #name << " time " << Dune::PDELab::TSC::seconds(HP_TIMER_DURATION(name)) << std::endl; \
   time += HP_TIMER_DURATION(name); \
   ops += HP_TIMER_OPCOUNTERS(name); \
-  HP_TIMER_OPCOUNTERS(name).reportOperations(os,ident,#name,reset);
+  HP_TIMER_OPCOUNTERS(name).reportOperations(os,#level,ident,#name,reset);
 
 #elif defined ENABLE_HP_TIMERS
 
-- 
GitLab