From a209613b16fad41512b99cb083ec0c621d62b12d Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> Date: Thu, 22 Dec 2016 15:35:38 +0100 Subject: [PATCH] Adjust opconter to the csv style --- dune/perftool/common/opcounter.hh | 28 +++++++++++++++------------- dune/perftool/common/timer.hh | 4 ++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/dune/perftool/common/opcounter.hh b/dune/perftool/common/opcounter.hh index b1af2f6c..67358129 100644 --- a/dune/perftool/common/opcounter.hh +++ b/dune/perftool/common/opcounter.hh @@ -151,18 +151,20 @@ namespace oc { } template<typename Stream> - void reportOperations(Stream& os, bool doReset = false) + void reportOperations(Stream& os, std::string exec, std::string kernel, bool doReset = false) { - os << "additions: " << addition_count << std::endl - << "multiplications: " << multiplication_count << std::endl - << "divisions: " << division_count << std::endl - << "exp: " << exp_count << std::endl - << "pow: " << pow_count << std::endl - << "sin: " << sin_count << std::endl - << "sqrt: " << sqrt_count << std::endl - << "comparisons: " << comparison_count << std::endl - << std::endl - << "total: " << addition_count + multiplication_count + division_count + exp_count + pow_count + sin_count + sqrt_count + comparison_count << std::endl; + 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 << " totalops " << total << std::endl; if (doReset) reset(); @@ -218,9 +220,9 @@ namespace oc { } template<typename Stream> - static void reportOperations(Stream& os, bool doReset = false) + static void reportOperations(Stream& os, std::string exec, std::string kernel, bool doReset = false) { - counters.reportOperations(os,doReset); + counters.reportOperations(os, exec, kernel, doReset); } static Counters counters; diff --git a/dune/perftool/common/timer.hh b/dune/perftool/common/timer.hh index 84f7caf4..b8e01baf 100644 --- a/dune/perftool/common/timer.hh +++ b/dune/perftool/common/timer.hh @@ -73,13 +73,13 @@ #define DUMP_TIMER(name,os,reset) \ os << exec << " " << #name << " " << HP_TIMER_ELAPSED(name) << std::endl; \ - HP_TIMER_OPCOUNTERS(name).reportOperations(os,reset); + HP_TIMER_OPCOUNTERS(name).reportOperations(os,exec,#name,reset); #define DUMP_AND_ACCUMULATE_TIMER(name,os,reset,time,ops) \ os << exec << " " << #name << " " << HP_TIMER_ELAPSED(name) << std::endl; \ time += HP_TIMER_ELAPSED(name); \ ops += HP_TIMER_OPCOUNTERS(name); \ - HP_TIMER_OPCOUNTERS(name).reportOperations(os,reset); + HP_TIMER_OPCOUNTERS(name).reportOperations(os,exec,#name,reset); #elif defined ENABLE_HP_TIMERS -- GitLab