From d004b7188f0f1036198c74344428d22e7d7582ee 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, 22 Dec 2016 16:52:35 +0100 Subject: [PATCH] Update opcounter --- dune/perftool/common/opcounter.hh | 62 ++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/dune/perftool/common/opcounter.hh b/dune/perftool/common/opcounter.hh index 67358129..48d4c11c 100644 --- a/dune/perftool/common/opcounter.hh +++ b/dune/perftool/common/opcounter.hh @@ -126,6 +126,7 @@ namespace oc { size_type sin_count; size_type sqrt_count; size_type comparison_count; + size_type blend_count; Counters() : addition_count(0) @@ -136,6 +137,7 @@ namespace oc { , sin_count(0) , sqrt_count(0) , comparison_count(0) + , blend_count(0) {} void reset() @@ -148,10 +150,11 @@ namespace oc { sin_count = 0; sqrt_count = 0; comparison_count = 0; + blend_count = 0; } template<typename Stream> - void reportOperations(Stream& os, std::string exec, std::string kernel, bool doReset = false) + void reportOperations(Stream& os, bool doReset = false) { auto total = addition_count + multiplication_count + division_count + exp_count + pow_count + sin_count + sqrt_count + comparison_count; if (total == 0) @@ -164,6 +167,7 @@ namespace oc { << 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; if (doReset) @@ -180,6 +184,7 @@ namespace oc { sin_count += rhs.sin_count; sqrt_count += rhs.sqrt_count; comparison_count += rhs.comparison_count; + blend_count += rhs.blend_count; return *this; } @@ -194,6 +199,7 @@ namespace oc { r.sin_count = sin_count - rhs.sin_count; r.sqrt_count = sqrt_count - rhs.sqrt_count; r.comparison_count = comparison_count - rhs.comparison_count; + r.blend_count = blend_count - rhs.blend_count; return r; } @@ -214,6 +220,16 @@ namespace oc { counters.division_count += n; } + static void comparisons(std::size_t n) + { + counters.comparison_count += n; + } + + static void blends(std::size_t n) + { + counters.blend_count += n; + } + static void reset() { counters.reset(); @@ -876,6 +892,50 @@ namespace oc { return {std::abs(a._v)}; } + template<typename F> + OpCounter<F> max(const OpCounter<F>& a, const OpCounter<F>& b) + { + ++OpCounter<F>::counters.comparison_count; + using std::max; + return {max(a._v,b._v)}; + } + + template<typename F> + OpCounter<F> min(const OpCounter<F>& a, const OpCounter<F>& b) + { + ++OpCounter<F>::counters.comparison_count; + using std::min; + return {min(a._v,b._v)}; + } + + template<typename F> + OpCounter<F> round(const OpCounter<F>& a) + { + using std::round; + return {round(a._v)}; + } + + template<typename F> + OpCounter<F> trunc(const OpCounter<F>& a) + { + using std::trunc; + return {trunc(a._v)}; + } + + template<typename F> + OpCounter<F> ceil(const OpCounter<F>& a) + { + using std::ceil; + return {ceil(a._v)}; + } + + template<typename F> + OpCounter<F> floor(const OpCounter<F>& a) + { + using std::floor; + return {floor(a._v)}; + } + } #endif // __OPCOUNTER__ -- GitLab