From 14375621d2bcfdee0cc4aea9463756d26402b4e6 Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> Date: Thu, 1 Mar 2018 12:49:03 +0100 Subject: [PATCH] Add traits to extract the underlying scalar type from vectors --- dune/perftool/common/vectorclass.hh | 38 ++++++++++++++++++++++++++ dune/perftool/sumfact/horizontaladd.hh | 7 +++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/dune/perftool/common/vectorclass.hh b/dune/perftool/common/vectorclass.hh index 16955159..e686e9f7 100644 --- a/dune/perftool/common/vectorclass.hh +++ b/dune/perftool/common/vectorclass.hh @@ -30,6 +30,29 @@ #include <numeric> + +template<typename T> +struct base_floatingpoint +{}; + +template<> +struct base_floatingpoint<_vcl::Vec4d> +{ + using value = double; +} + +template<> +struct base_floatingpoint<_vcl::Vec8d> +{ + using value = double; +} + +template<> +struct base_floatingpoint<_vcl::Vec8f> +{ + using value = float; +} + struct Vec4d { oc::OpCounter<double> _d[4]; @@ -111,6 +134,11 @@ struct Vec4d }; +template<> +struct base_floatingpoint<Vec4d> +{ + using value = typename Vec4d::F; +} /***************************************************************************** * @@ -776,6 +804,11 @@ struct Vec8d }; +template<> +struct base_floatingpoint<Vec8d> +{ + using value = typename Vec8d::F; +} /***************************************************************************** * @@ -1196,6 +1229,11 @@ struct Vec8f }; +template<> +struct base_floatingpoint<Vec8f> +{ + using value = typename Vec8f::F; +} /***************************************************************************** * diff --git a/dune/perftool/sumfact/horizontaladd.hh b/dune/perftool/sumfact/horizontaladd.hh index f7303168..db7634f0 100644 --- a/dune/perftool/sumfact/horizontaladd.hh +++ b/dune/perftool/sumfact/horizontaladd.hh @@ -1,14 +1,17 @@ #ifndef DUNE_PERFTOOL_SUMFACT_HORIZONTALADD_HH #define DUNE_PERFTOOL_SUMFACT_HORIZONTALADD_HH +#include<dune/perftool/common/vectorclass.hh> + + template<class V> -double horizontal_add_lower(const V& x) +typename base_floatingpoint<V>::value horizontal_add_lower(const V& x) { return horizontal_add(x.get_low()); } template<class V> -double horizontal_add_upper(const V& x) +typename base_floatingpoint<V>::value horizontal_add_upper(const V& x) { return horizontal_add(x.get_high()); } -- GitLab