From 1d3a80351ade6d296f1b76918da8aff9c0502af3 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Tue, 20 Sep 2016 01:09:42 +0200 Subject: [PATCH] Add operators for simd::vector operations --- include/vectorwrapper/vectorwrapper_simd.hpp | 32 ++++++++++++- include/vectorwrapper/vectorwrapper_simd.inl | 48 ++++++++++++++++++++ test/CMakeLists.txt | 2 +- test/speed/speed.cpp | 34 ++++++++++++-- 4 files changed, 108 insertions(+), 8 deletions(-) diff --git a/include/vectorwrapper/vectorwrapper_simd.hpp b/include/vectorwrapper/vectorwrapper_simd.hpp index 04470ec..2e836eb 100644 --- a/include/vectorwrapper/vectorwrapper_simd.hpp +++ b/include/vectorwrapper/vectorwrapper_simd.hpp @@ -26,27 +26,55 @@ namespace vwr { template ::dimensions, typename=typename ::vwr::Vec::scalar_type> class Vec; + template ::dimensions, typename=typename ::vwr::Vec::scalar_type> + class VecPack; + template - class Vec : public ::vwr::Vec { - typedef ::vwr::Vec base_class; + class Vec : public implem::VecBase, public implem::VecAccessors { + typedef ::vwr::implem::VecBase base_class; public: static_assert(alignof(V) % 16 == 0, "Wrapped type must be aligned to 16"); static_assert(base_class::is_interleaved_mem == 0, "Expected tightly packed vector_type"); using typename base_class::vector_type; + typedef VecPack pack_type; typedef float scalar_type; Vec ( void ) = default; Vec ( const Vec& ) = default; + Vec ( VecPack parPack ) __attribute__((always_inline)); explicit Vec ( const vector_type& parIn ) : base_class(parIn) { } explicit Vec ( const scalar_type parX ) : base_class(parX) { } explicit Vec ( const base_class& parIn ) : base_class(parIn) { } + Vec& operator= ( VecPack parPack ) __attribute__((always_inline)); + template Vec& operator+= ( const Vec& parOther ); template Vec& operator-= ( const Vec& parOther ); template Vec& operator*= ( const Vec& parOther ); template Vec& operator/= ( const Vec& parOther ); }; + + template + class VecPack { + public: + VecPack ( const Vec& parVec ) __attribute__((always_inline)); + VecPack ( __m128 parPack ) __attribute__((always_inline)); + VecPack ( float parValue ) __attribute__((always_inline)); + + __m128 pack; + }; + + template