From 7d6936a196cc3b5a884c1ad7d5bcfb8e035e5b8e Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> Date: Wed, 11 Apr 2018 16:39:09 +0200 Subject: [PATCH] Adapt to using dune-opcounter Simple test passes already --- dune.module | 1 + dune/perftool/common/CMakeLists.txt | 3 +- dune/perftool/common/opcounter.hh | 974 --------------------------- dune/perftool/common/timer_chrono.hh | 2 +- dune/perftool/common/timer_tsc.hh | 24 +- python/dune/perftool/loopy/target.py | 3 +- 6 files changed, 21 insertions(+), 986 deletions(-) delete mode 100644 dune/perftool/common/opcounter.hh diff --git a/dune.module b/dune.module index 264e9fb2..c6a0e7bb 100644 --- a/dune.module +++ b/dune.module @@ -8,3 +8,4 @@ Version: 0.0 Maintainer: dominic.kempf@iwr.uni-heidelberg.de #depending on Depends: dune-testtools dune-pdelab dune-alugrid +Suggests: dune-opcounter diff --git a/dune/perftool/common/CMakeLists.txt b/dune/perftool/common/CMakeLists.txt index 31520e34..6cd10063 100644 --- a/dune/perftool/common/CMakeLists.txt +++ b/dune/perftool/common/CMakeLists.txt @@ -1,6 +1,7 @@ install(FILES muladd_workarounds.hh - opcounter.hh timer.hh + timer_tsc.hh + timer_chrono.hh tsc.hh vectorclass.hh DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/perftool/common diff --git a/dune/perftool/common/opcounter.hh b/dune/perftool/common/opcounter.hh deleted file mode 100644 index edb16eaa..00000000 --- a/dune/perftool/common/opcounter.hh +++ /dev/null @@ -1,974 +0,0 @@ -#ifndef __OPCOUNTER__ -#define __OPCOUNTER__ - -#include <type_traits> -#include <iostream> -#include <cmath> -#include <cstdlib> -#include <ostream> -#include <sstream> -#include <istream> - -#include <dune/common/typetraits.hh> - -namespace oc { - - template<typename F> - class OpCounter; - - template<typename T> - struct isOpCounter : public std::false_type - {}; - - template<typename F> - struct isOpCounter<OpCounter<F>> : public std::true_type - {}; - - template<typename T> - constexpr bool isOpCounterV = isOpCounter<T>::value; -} - -namespace Dune { - - template <typename T> - struct IsNumber<oc::OpCounter<T>> - : public std::integral_constant<bool, IsNumber<T>::value>{ - }; - - template<typename T, int n> - class FieldVector; - -} - -namespace oc { - - template<typename F> - class OpCounter - { - - public: - - using size_type = std::size_t; - - using value_type = F; - - OpCounter() - : _v() - {} - - template<typename T> - OpCounter(const T& t, typename std::enable_if<std::is_same<T,int>::value and !std::is_same<F,int>::value>::type* = nullptr) - : _v(t) - {} - - OpCounter(const F& f) - : _v(f) - {} - - OpCounter(F&& f) - : _v(f) - {} - - explicit OpCounter(const char* s) - : _v(strtod(s,nullptr)) - {} - - OpCounter& operator=(const char* s) - { - _v = strtod(s,nullptr); - return *this; - } - - explicit operator F() const - { - return _v; - } - - OpCounter& operator=(const F& f) - { - _v = f; - return *this; - } - - OpCounter& operator=(F&& f) - { - _v = f; - return *this; - } - - friend std::ostream& operator<<(std::ostream& os, const OpCounter& f) - { - os << "OC(" << f._v << ")"; - return os; - } - - friend std::istringstream& operator>>(std::istringstream& iss, OpCounter& f) - { - iss >> f._v; - return iss; - } - - friend std::istream& operator>>(std::istream& is, OpCounter& f) - { - is >> f._v; - return is; - } - - F* data() - { - return &_v; - } - - const F* data() const - { - return &_v; - } - - F _v; - - // The alignment is necessary to work around - // https://bugs.llvm.org/show_bug.cgi?id=34219: - // "SLP vectorizer: aligned store to unaligned address" - // The bug is present in 3.8.0 (tags/RELEASE_380/final 263969) and in - // clang version 6.0.0 (trunk 310993) - struct alignas(16) Counters { - - size_type addition_count; - size_type multiplication_count; - size_type division_count; - size_type exp_count; - size_type pow_count; - size_type sin_count; - size_type sqrt_count; - size_type comparison_count; - size_type blend_count; - size_type permute_count; - - Counters() - : addition_count(0) - , multiplication_count(0) - , division_count(0) - , exp_count(0) - , pow_count(0) - , sin_count(0) - , sqrt_count(0) - , comparison_count(0) - , blend_count(0) - , permute_count(0) - {} - - void reset() - { - addition_count = 0; - multiplication_count = 0; - division_count = 0; - exp_count = 0; - pow_count = 0; - sin_count = 0; - sqrt_count = 0; - comparison_count = 0; - blend_count = 0; - permute_count = 0; - } - - template<typename Stream, typename T> - void reportOperations(Stream& os, T 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 << 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 << " permutes " << permute_count << std::endl - << level << " " << exec << " " << kernel << " totalops " << total << std::endl; - - if (doReset) - reset(); - } - - Counters& operator+=(const Counters& rhs) - { - addition_count += rhs.addition_count; - multiplication_count += rhs.multiplication_count; - division_count += rhs.division_count; - exp_count += rhs.exp_count; - pow_count += rhs.pow_count; - sin_count += rhs.sin_count; - sqrt_count += rhs.sqrt_count; - comparison_count += rhs.comparison_count; - blend_count += rhs.blend_count; - permute_count += rhs.permute_count; - return *this; - } - - Counters operator-(const Counters& rhs) - { - Counters r; - r.addition_count = addition_count - rhs.addition_count; - r.multiplication_count = multiplication_count - rhs.multiplication_count; - r.division_count = division_count - rhs.division_count; - r.exp_count = exp_count - rhs.exp_count; - r.pow_count = pow_count - rhs.pow_count; - 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; - r.permute_count = permute_count - rhs.permute_count; - return r; - } - - }; - - static void additions(std::size_t n) - { - counters.addition_count += n; - } - - static void multiplications(std::size_t n) - { - counters.multiplication_count += n; - } - - static void divisions(std::size_t n) - { - 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 permutes(std::size_t n) - { - counters.permute_count += n; - } - - static void reset() - { - counters.reset(); - } - - template<typename Stream, typename T> - static void reportOperations(Stream& os, T level, std::string exec, std::string kernel, bool doReset = false) - { - counters.reportOperations(os, level, exec, kernel, doReset); - } - - static Counters counters; - - }; - - template<typename F> - typename OpCounter<F>::Counters OpCounter<F>::counters; - - // ******************************************************************************** - // negation - // ******************************************************************************** - - template<typename F> - OpCounter<F> operator-(const OpCounter<F>& a) - { - ++OpCounter<F>::counters.addition_count; - return {-a._v}; - } - - - // ******************************************************************************** - // addition - // ******************************************************************************** - - template<typename F> - OpCounter<F> operator+(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.addition_count; - return {a._v + b._v}; - } - - template<typename F> - OpCounter<F> operator+(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.addition_count; - return {a._v + b}; - } - - template<typename F> - OpCounter<F> operator+(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.addition_count; - return {a + b._v}; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F> - >::type - operator+(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.addition_count; - return {a._v + b}; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F> - >::type - operator+(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.addition_count; - return {a + b._v}; - } - - template<typename F> - OpCounter<F>& operator+=(OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.addition_count; - a._v += b._v; - return a; - } - - template<typename F> - OpCounter<F>& operator+=(OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.addition_count; - a._v += b; - return a; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F>& - >::type - operator+=(OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.addition_count; - a._v += b; - return a; - } - - template<typename F> - OpCounter<F>& operator+=(OpCounter<F>& a, const Dune::FieldVector<OpCounter<F>,1>& b) - { - ++OpCounter<F>::counters.addition_count; - a._v += b[0]._v; - return a; - } - - // ******************************************************************************** - // subtraction - // ******************************************************************************** - - template<typename F> - OpCounter<F> operator-(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.addition_count; - return {a._v - b._v}; - } - - template<typename F> - OpCounter<F> operator-(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.addition_count; - return {a._v - b}; - } - - template<typename F> - OpCounter<F> operator-(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.addition_count; - return {a - b._v}; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F> - >::type - operator-(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.addition_count; - return {a._v - b}; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F> - >::type - operator-(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.addition_count; - return {a - b._v}; - } - - template<typename F> - OpCounter<F>& operator-=(OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.addition_count; - a._v -= b._v; - return a; - } - - template<typename F> - OpCounter<F>& operator-=(OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.addition_count; - a._v -= b; - return a; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F>& - >::type - operator-=(OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.addition_count; - a._v -= b; - return a; - } - - - // ******************************************************************************** - // multiplication - // ******************************************************************************** - - template<typename F> - OpCounter<F> operator*(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.multiplication_count; - return {a._v * b._v}; - } - - template<typename F> - OpCounter<F> operator*(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.multiplication_count; - return {a._v * b}; - } - - template<typename F> - OpCounter<F> operator*(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.multiplication_count; - return {a * b._v}; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F> - >::type - operator*(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.multiplication_count; - return {a._v * b}; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F> - >::type - operator*(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.multiplication_count; - return {a * b._v}; - } - - template<typename F> - OpCounter<F>& operator*=(OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.multiplication_count; - a._v *= b._v; - return a; - } - - template<typename F> - OpCounter<F>& operator*=(OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.multiplication_count; - a._v *= b; - return a; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F>& - >::type - operator*=(OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.multiplication_count; - a._v *= b; - return a; - } - - - // ******************************************************************************** - // division - // ******************************************************************************** - - template<typename F> - OpCounter<F> operator/(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.division_count; - return {a._v / b._v}; - } - - template<typename F> - OpCounter<F> operator/(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.division_count; - return {a._v / b}; - } - - template<typename F> - OpCounter<F> operator/(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.division_count; - return {a / b._v}; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F> - >::type - operator/(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.division_count; - return {a._v / b}; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F> - >::type - operator/(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.division_count; - return {a / b._v}; - } - - template<typename F> - OpCounter<F>& operator/=(OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.division_count; - a._v /= b._v; - return a; - } - - template<typename F> - OpCounter<F>& operator/=(OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.division_count; - a._v /= b; - return a; - } - - template<typename F, typename T> - typename std::enable_if< - std::is_arithmetic<T>::value, - OpCounter<F>& - >::type - operator/=(OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.division_count; - a._v /= b; - return a; - } - - - - // ******************************************************************************** - // comparisons - // ******************************************************************************** - - - // ******************************************************************************** - // less - // ******************************************************************************** - - template<typename F> - bool operator<(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v < b._v}; - } - - template<typename F> - bool operator<(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v < b}; - } - - template<typename F> - bool operator<(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a < b._v}; - } - - template<typename F, typename T> - bool operator<(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v < b}; - } - - template<typename F, typename T> - bool operator<(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a < b._v}; - } - - - // ******************************************************************************** - // less_or_equals - // ******************************************************************************** - - template<typename F> - bool operator<=(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v <= b._v}; - } - - template<typename F> - bool operator<=(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v <= b}; - } - - template<typename F> - bool operator<=(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a <= b._v}; - } - - template<typename F, typename T> - bool operator<=(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v <= b}; - } - - template<typename F, typename T> - bool operator<=(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a <= b._v}; - } - - - // ******************************************************************************** - // greater - // ******************************************************************************** - - template<typename F> - bool operator>(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v > b._v}; - } - - template<typename F> - bool operator>(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v > b}; - } - - template<typename F> - bool operator>(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a > b._v}; - } - - template<typename F, typename T> - bool operator>(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v > b}; - } - - template<typename F, typename T> - bool operator>(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a > b._v}; - } - - - // ******************************************************************************** - // greater_or_equals - // ******************************************************************************** - - template<typename F> - bool operator>=(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v >= b._v}; - } - - template<typename F> - bool operator>=(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v >= b}; - } - - template<typename F> - bool operator>=(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a >= b._v}; - } - - template<typename F, typename T> - bool operator>=(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v >= b}; - } - - template<typename F, typename T> - bool operator>=(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a >= b._v}; - } - - - // ******************************************************************************** - // inequals - // ******************************************************************************** - - template<typename F> - bool operator!=(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v != b._v}; - } - - template<typename F> - bool operator!=(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v != b}; - } - - template<typename F> - bool operator!=(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a != b._v}; - } - - template<typename F, typename T> - bool operator!=(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v != b}; - } - - template<typename F, typename T> - bool operator!=(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a != b._v}; - } - - - // ******************************************************************************** - // equals - // ******************************************************************************** - - template<typename F> - bool operator==(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v == b._v}; - } - - template<typename F> - bool operator==(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v == b}; - } - - template<typename F> - bool operator==(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a == b._v}; - } - - template<typename F, typename T> - bool operator==(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a._v == b}; - } - - template<typename F, typename T> - bool operator==(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.comparison_count; - return {a == b._v}; - } - - - - // ******************************************************************************** - // functions - // ******************************************************************************** - - template<typename F> - OpCounter<F> exp(const OpCounter<F>& a) - { - ++OpCounter<F>::counters.exp_count; - return {std::exp(a._v)}; - } - - template<typename F> - OpCounter<F> pow(const OpCounter<F>& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.pow_count; - return {std::pow(a._v,b._v)}; - } - - template<typename F> - OpCounter<F> pow(const OpCounter<F>& a, const F& b) - { - ++OpCounter<F>::counters.pow_count; - return {std::pow(a._v,b)}; - } - - template<typename F, typename T> - OpCounter<F> pow(const OpCounter<F>& a, const T& b) - { - ++OpCounter<F>::counters.pow_count; - return {std::pow(a._v,b)}; - } - - template<typename F> - OpCounter<F> pow(const F& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.pow_count; - return {std::pow(a,b._v)}; - } - - template<typename F, typename T> - OpCounter<F> pow(const T& a, const OpCounter<F>& b) - { - ++OpCounter<F>::counters.pow_count; - return {std::pow(a,b._v)}; - } - - template<typename F> - OpCounter<F> sin(const OpCounter<F>& a) - { - ++OpCounter<F>::counters.sin_count; - return {std::sin(a._v)}; - } - - template<typename F> - OpCounter<F> cos(const OpCounter<F>& a) - { - ++OpCounter<F>::counters.sin_count; - return {std::cos(a._v)}; - } - - template<typename F> - OpCounter<F> sqrt(const OpCounter<F>& a) - { - ++OpCounter<F>::counters.sqrt_count; - return {std::sqrt(a._v)}; - } - - template<typename F> - OpCounter<F> abs(const OpCounter<F>& a) - { - ++OpCounter<F>::counters.comparison_count; - 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)}; - } - - template<typename F> - bool isnan(const OpCounter<F>& a) - { - using std::isnan; - return {isnan(a._v)}; - } - -} - -#endif // __OPCOUNTER__ diff --git a/dune/perftool/common/timer_chrono.hh b/dune/perftool/common/timer_chrono.hh index d1b0bd9b..8e96a70a 100644 --- a/dune/perftool/common/timer_chrono.hh +++ b/dune/perftool/common/timer_chrono.hh @@ -7,7 +7,7 @@ #include <chrono> -#include <dune/perftool/common/opcounter.hh> +#include <dune/opcounter/opcounter.hh> #define HP_TIMER_OPCOUNTER oc::OpCounter<double> diff --git a/dune/perftool/common/timer_tsc.hh b/dune/perftool/common/timer_tsc.hh index 0f9e1e04..10ec75d9 100644 --- a/dune/perftool/common/timer_tsc.hh +++ b/dune/perftool/common/timer_tsc.hh @@ -6,7 +6,7 @@ #endif #include <dune/perftool/common/tsc.hh> -#include <dune/perftool/common/opcounter.hh> +#include <dune/opcounter/opcounter.hh> #define HP_TIMER_DURATION(name) __hp_timer_##name##_duration #define HP_TIMER_STARTTIME(name) __hp_timer_##name##_start @@ -76,16 +76,22 @@ #ifdef ENABLE_COUNTER #define DUMP_TIMER(level,name,os,reset)\ - if (HP_TIMER_DURATION(name) > 1e-12) \ - os << #level << " " << ident << " " << #name << " time " << Dune::PDELab::TSC::seconds(HP_TIMER_DURATION(name)) << std::endl; \ - HP_TIMER_OPCOUNTERS(name).reportOperations(os,#level,ident,#name,reset); + { \ + std::string prefix = std::string(#level) + " " + ident + " " + std::string(#name); \ + if (HP_TIMER_DURATION(name) > 1e-12) \ + os << prefix << " time " << Dune::PDELab::TSC::seconds(HP_TIMER_DURATION(name)) << std::endl; \ + HP_TIMER_OPCOUNTERS(name).reportOperations(os,prefix,reset); \ + } #define DUMP_AND_ACCUMULATE_TIMER(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,#level,ident,#name,reset); + { \ + std::string prefix = std::string(#level) + " " + ident + " " + std::string(#name); \ + if (HP_TIMER_DURATION(name) > 1e-12) \ + os << prefix << " 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,prefix,reset); \ + } #elif defined ENABLE_HP_TIMERS diff --git a/python/dune/perftool/loopy/target.py b/python/dune/perftool/loopy/target.py index 22a0c317..72cdbca3 100644 --- a/python/dune/perftool/loopy/target.py +++ b/python/dune/perftool/loopy/target.py @@ -30,7 +30,8 @@ import cgen def _type_to_op_counter_type(name): - return "oc::OpCounter<{}>".format(name) + include_file("dune/opcounter/opcounter.hh") + return "Dune::OpCounter::OpCounter<{}>".format(name) def dtype_floatingpoint(): -- GitLab