From 9757ba411d50c2e206790643509606cbab9caec1 Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> Date: Fri, 15 Mar 2019 11:39:37 +0100 Subject: [PATCH] Add a bit more traits concept around the vector class library --- dune/codegen/common/simdtraits.hh | 16 ++++++ dune/codegen/common/vcltraits.hh | 86 ++++++++++++++++++++++++++++++ dune/codegen/common/vectorclass.hh | 58 ++------------------ 3 files changed, 107 insertions(+), 53 deletions(-) create mode 100644 dune/codegen/common/simdtraits.hh create mode 100644 dune/codegen/common/vcltraits.hh diff --git a/dune/codegen/common/simdtraits.hh b/dune/codegen/common/simdtraits.hh new file mode 100644 index 00000000..73ee4caf --- /dev/null +++ b/dune/codegen/common/simdtraits.hh @@ -0,0 +1,16 @@ +#ifndef DUNE_CODEGEN_COMMON_SIMD_TRAITS_HH +#define DUNE_CODEGEN_COMMON_SIMD_TRAITS_HH + +/** This is just the declaration of the traits classes, specialization for VCL and + * OpCounter VCL are elsewhere. + */ + +template<typename T> +struct base_floatingpoint +{}; + +template<typename T> +struct simd_size +{}; + +#endif diff --git a/dune/codegen/common/vcltraits.hh b/dune/codegen/common/vcltraits.hh new file mode 100644 index 00000000..de764dbe --- /dev/null +++ b/dune/codegen/common/vcltraits.hh @@ -0,0 +1,86 @@ +#ifndef DUNE_CODEGEN_COMMON_VCLTRAITS_HH +#define DUNE_CODEGEN_COMMON_VCLTRAITS_HH + +/** A collection of traits tools for the Vector Class Library */ + +#include<dune/codegen/common/vectorclass.hh> + + +template<> +struct base_floatingpoint<Vec2d> +{ + using value = double; +}; + +template<> +struct base_floatingpoint<Vec4f> +{ + using value = float; +}; + +template<> +struct simd_size<Vec2d> +{ + static constexpr std::size_t value = 2; +}; + +template<> +struct simd_size<Vec4f> +{ + static constexpr std::size_t value = 4; +}; + +#if MAX_VECTOR_SIZE >= 256 +template<> +struct base_floatingpoint<Vec4d> +{ + using value = double; +}; + +template<> +struct base_floatingpoint<Vec8f> +{ + using value = float; +}; + +template<> +struct simd_size<Vec4d> +{ + static constexpr std::size_t value = 4; +}; + +template<> +struct simd_size<Vec8f> +{ + static constexpr std::size_t value = 8; +}; +#endif + +#if MAX_VECTOR_SIZE >= 512 +template<> +struct base_floatingpoint<Vec8d> +{ + using value = double; +}; + +template<> +struct base_floatingpoint<Vec16f> +{ + using value = float; +}; + +template<> +struct simd_size<Vec8d> +{ + static constexpr std::size_t value = 8; +}; + +template<> +struct simd_size<Vec16f> +{ + static constexpr std::size_t value = 16; +}; + +#endif + +#endif diff --git a/dune/codegen/common/vectorclass.hh b/dune/codegen/common/vectorclass.hh index aa3bba7b..648ea52f 100644 --- a/dune/codegen/common/vectorclass.hh +++ b/dune/codegen/common/vectorclass.hh @@ -1,71 +1,23 @@ #ifndef DUNE_CODEGEN_COMMON_VECTORCLASS_HH #define DUNE_CODEGEN_COMMON_VECTORCLASS_HH - -template<typename T> -struct base_floatingpoint -{}; +#include<dune/codegen/common/simdtraits.hh> #ifdef ENABLE_COUNTER + #if HAVE_DUNE_OPCOUNTER #include<dune/opcounter/vectorclass.hh> - -template<typename F, int size> -struct base_floatingpoint<OpCounter::impl::OpCounterVector<F, size>> -{ - using value = OpCounter::OpCounter<F>; -}; - - #else #error "dune-opcounter is needed for opcounted vector types" #endif + #else + #include<dune/codegen/vectorclass/vectorclass.h> #include<dune/codegen/vectorclass/vectormath_exp.h> #include<dune/codegen/vectorclass/vectormath_hyp.h> #include<dune/codegen/vectorclass/vectormath_trig.h> - -template<> -struct base_floatingpoint<Vec2d> -{ - using value = double; -}; - -template<> -struct base_floatingpoint<Vec4f> -{ - using value = float; -}; - - -#if MAX_VECTOR_SIZE >= 256 -template<> -struct base_floatingpoint<Vec4d> -{ - using value = double; -}; - -template<> -struct base_floatingpoint<Vec8f> -{ - using value = float; -}; -#endif - -#if MAX_VECTOR_SIZE >= 512 -template<> -struct base_floatingpoint<Vec8d> -{ - using value = double; -}; - -template<> -struct base_floatingpoint<Vec16f> -{ - using value = float; -}; -#endif +#include<dune/codegen/common/vcltraits.hh> #endif -- GitLab