diff --git a/dune/codegen/common/simdtraits.hh b/dune/codegen/common/simdtraits.hh new file mode 100644 index 0000000000000000000000000000000000000000..73ee4caff1bb743d275e20173556416cc0bd2d30 --- /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 0000000000000000000000000000000000000000..de764dbe6f78a51d1bf5934856ca36d4b90a77d0 --- /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 aa3bba7b98f9cf57dcc223f61755e3aa26c5bdca..648ea52fe24490efc8af431fe54de4089515af33 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