From a9c816a26883056c367ea5972bca41fc1b24b3a3 Mon Sep 17 00:00:00 2001 From: Nils Meyer Date: Tue, 27 Jun 2017 21:39:15 +0200 Subject: [PATCH] moved file to correct folder --- Grid_vector_types.h | 857 ----------------------------------- lib/simd/Grid_vector_types.h | 75 +-- 2 files changed, 22 insertions(+), 910 deletions(-) delete mode 100644 Grid_vector_types.h diff --git a/Grid_vector_types.h b/Grid_vector_types.h deleted file mode 100644 index e05fecc4..00000000 --- a/Grid_vector_types.h +++ /dev/null @@ -1,857 +0,0 @@ -/************************************************************************************* - -Grid physics library, www.github.com/paboyle/Grid - -Source file: ./lib/simd/Grid_vector_type.h - -Copyright (C) 2015 - -Author: Azusa Yamaguchi -Author: Guido Cossu -Author: Peter Boyle -Author: neo - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -See the full license in the file "LICENSE" in the top level distribution -directory -*************************************************************************************/ -/* END LEGAL */ -//--------------------------------------------------------------------------- -/*! @file Grid_vector_types.h - @brief Defines templated class Grid_simd to deal with inner vector types -*/ -// Time-stamp: <2015-07-10 17:45:33 neo> -//--------------------------------------------------------------------------- -#ifndef GRID_VECTOR_TYPES -#define GRID_VECTOR_TYPES - -#ifdef GEN -#include "Grid_generic.h" -#endif -#ifdef SSE4 -#include "Grid_sse4.h" -#endif -#if defined(AVX1) || defined (AVXFMA) || defined(AVX2) || defined(AVXFMA4) -#include "Grid_avx.h" -#endif -#if defined AVX512 -#include "Grid_avx512.h" -#endif -#if defined IMCI -#include "Grid_imci.h" -#endif -#ifdef NEONv8 -#include "Grid_neon.h" -#endif -#if defined QPX -#include "Grid_qpx.h" -#endif - -#include "l1p.h" - -namespace Grid { - -////////////////////////////////////// -// To take the floating point type of real/complex type -////////////////////////////////////// -template -struct RealPart { - typedef T type; -}; -template -struct RealPart > { - typedef T type; -}; - -#include - -////////////////////////////////////// -// demote a vector to real type -////////////////////////////////////// -// type alias used to simplify the syntax of std::enable_if -template using Invoke = typename T::type; -template using EnableIf = Invoke >; -template using NotEnableIf = Invoke >; - -//////////////////////////////////////////////////////// -// Check for complexity with type traits -template struct is_complex : public std::false_type {}; -template <> struct is_complex > : public std::true_type {}; -template <> struct is_complex > : public std::true_type {}; - -template using IfReal = Invoke::value, int> >; -template using IfComplex = Invoke::value, int> >; -template using IfInteger = Invoke::value, int> >; -template using IfSame = Invoke::value, int> >; - -template using IfNotReal = Invoke::value, int> >; -template using IfNotComplex = Invoke::value, int> >; -template using IfNotInteger = Invoke::value, int> >; -template using IfNotSame = Invoke::value, int> >; - -//////////////////////////////////////////////////////// -// Define the operation templates functors -// general forms to allow for vsplat syntax -// need explicit declaration of types when used since -// clang cannot automatically determine the output type sometimes -template -Out trinary(Input1 src_1, Input2 src_2, Input3 src_3, Operation op) { - return op(src_1, src_2, src_3); -} - -template -Out binary(Input1 src_1, Input2 src_2, Operation op) { - return op(src_1, src_2); -} - -template -Out unary(Input src, Operation op) { - return op(src); -} -/////////////////////////////////////////////// - -/* - @brief Grid_simd class for the SIMD vector type operations - */ -template -class Grid_simd { - public: - typedef typename RealPart::type Real; - typedef Vector_type vector_type; - typedef Scalar_type scalar_type; - - typedef union conv_t_union { - Vector_type v; - Scalar_type s[sizeof(Vector_type) / sizeof(Scalar_type)]; - conv_t_union(){}; - } conv_t; - - Vector_type v; - - static inline constexpr int Nsimd(void) { - return sizeof(Vector_type) / sizeof(Scalar_type); - } - - Grid_simd &operator=(const Grid_simd &&rhs) { - v = rhs.v; - return *this; - }; - Grid_simd &operator=(const Grid_simd &rhs) { - v = rhs.v; - return *this; - }; // faster than not declaring it and leaving to the compiler - Grid_simd() = default; - Grid_simd(const Grid_simd &rhs) : v(rhs.v){}; // compiles in movaps - Grid_simd(const Grid_simd &&rhs) : v(rhs.v){}; - - ///////////////////////////// - // Constructors - ///////////////////////////// - Grid_simd &operator=(Zero &z) { - vzero(*this); - return (*this); - } - - // Enable if complex type - template - Grid_simd(const typename std::enable_if::value, S>::type a) { - vsplat(*this, a); - }; - - Grid_simd(const Real a) { vsplat(*this, Scalar_type(a)); }; - - /////////////////////////////////////////////// - // mac, mult, sub, add, adj - /////////////////////////////////////////////// - - // FIXME -- alias this to an inline MAC struct. - friend inline void mac(Grid_simd *__restrict__ y, - const Grid_simd *__restrict__ a, - const Grid_simd *__restrict__ x) { - *y = (*a) * (*x) + (*y); - }; - - friend inline void mult(Grid_simd *__restrict__ y, - const Grid_simd *__restrict__ l, - const Grid_simd *__restrict__ r) { - *y = (*l) * (*r); - } - - friend inline void sub(Grid_simd *__restrict__ y, - const Grid_simd *__restrict__ l, - const Grid_simd *__restrict__ r) { - *y = (*l) - (*r); - } - friend inline void add(Grid_simd *__restrict__ y, - const Grid_simd *__restrict__ l, - const Grid_simd *__restrict__ r) { - *y = (*l) + (*r); - } - friend inline void mac(Grid_simd *__restrict__ y, - const Scalar_type *__restrict__ a, - const Grid_simd *__restrict__ x) { - *y = (*a) * (*x) + (*y); - }; - friend inline void mult(Grid_simd *__restrict__ y, - const Scalar_type *__restrict__ l, - const Grid_simd *__restrict__ r) { - *y = (*l) * (*r); - } - friend inline void sub(Grid_simd *__restrict__ y, - const Scalar_type *__restrict__ l, - const Grid_simd *__restrict__ r) { - *y = (*l) - (*r); - } - friend inline void add(Grid_simd *__restrict__ y, - const Scalar_type *__restrict__ l, - const Grid_simd *__restrict__ r) { - *y = (*l) + (*r); - } - - friend inline void mac(Grid_simd *__restrict__ y, - const Grid_simd *__restrict__ a, - const Scalar_type *__restrict__ x) { - *y = (*a) * (*x) + (*y); - }; - friend inline void mult(Grid_simd *__restrict__ y, - const Grid_simd *__restrict__ l, - const Scalar_type *__restrict__ r) { - *y = (*l) * (*r); - } - friend inline void sub(Grid_simd *__restrict__ y, - const Grid_simd *__restrict__ l, - const Scalar_type *__restrict__ r) { - *y = (*l) - (*r); - } - friend inline void add(Grid_simd *__restrict__ y, - const Grid_simd *__restrict__ l, - const Scalar_type *__restrict__ r) { - *y = (*l) + (*r); - } - - //////////////////////////////////////////////////////////////////////// - // FIXME: gonna remove these load/store, get, set, prefetch - //////////////////////////////////////////////////////////////////////// - friend inline void vset(Grid_simd &ret, Scalar_type *a) { - ret.v = unary(a, VsetSIMD()); - } - - /////////////////////// - // Vstore - /////////////////////// - friend inline void vstore(const Grid_simd &ret, Scalar_type *a) { - binary(ret.v, (Real *)a, VstoreSIMD()); - } - - /////////////////////// - // Vprefetch - /////////////////////// - friend inline void vprefetch(const Grid_simd &v) { - prefetch_HINT_T0((const char *)&v.v); - } - - /////////////////////// - // Reduce - /////////////////////// - friend inline Scalar_type Reduce(const Grid_simd &in) { - return unary(in.v, ReduceSIMD()); - } - - //////////////////////////// - // operator scalar * simd - //////////////////////////// - friend inline Grid_simd operator*(const Scalar_type &a, Grid_simd b) { - Grid_simd va; - vsplat(va, a); - return va * b; - } - friend inline Grid_simd operator*(Grid_simd b, const Scalar_type &a) { - return a * b; - } - - ////////////////////////////////// - // Divides - ////////////////////////////////// - friend inline Grid_simd operator/(const Scalar_type &a, Grid_simd b) { - Grid_simd va; - vsplat(va, a); - return va / b; - } - friend inline Grid_simd operator/(Grid_simd b, const Scalar_type &a) { - Grid_simd va; - vsplat(va, a); - return b / a; - } - - /////////////////////// - // Unary negation - /////////////////////// - friend inline Grid_simd operator-(const Grid_simd &r) { - Grid_simd ret; - vzero(ret); - ret = ret - r; - return ret; - } - // *=,+=,-= operators - inline Grid_simd &operator*=(const Grid_simd &r) { - *this = (*this) * r; - return *this; - // return (*this)*r; ? - } - inline Grid_simd &operator+=(const Grid_simd &r) { - *this = *this + r; - return *this; - } - inline Grid_simd &operator-=(const Grid_simd &r) { - *this = *this - r; - return *this; - } - - /////////////////////////////////////// - // Not all functions are supported - // through SIMD and must breakout to - // scalar type and back again. This - // provides support - /////////////////////////////////////// - - template - friend inline Grid_simd SimdApply(const functor &func, const Grid_simd &v) { - Grid_simd ret; - Grid_simd::conv_t conv; - Grid_simd::scalar_type s; - - conv.v = v.v; - for (int i = 0; i < Nsimd(); i++) { - s = conv.s[i]; - conv.s[i] = func(s); - } - ret.v = conv.v; - return ret; - } - template - friend inline Grid_simd SimdApplyBinop(const functor &func, - const Grid_simd &x, - const Grid_simd &y) { - Grid_simd ret; - Grid_simd::conv_t cx; - Grid_simd::conv_t cy; - Grid_simd::scalar_type sx,sy; - - cx.v = x.v; - cy.v = y.v; - for (int i = 0; i < Nsimd(); i++) { - sx = cx.s[i]; - sy = cy.s[i]; - cx.s[i] = func(sx,sy); - } - ret.v = cx.v; - return ret; - } - /////////////////////// - // Exchange - // Al Ah , Bl Bh -> Al Bl Ah,Bh - /////////////////////// - friend inline void exchange(Grid_simd &out1,Grid_simd &out2,Grid_simd in1,Grid_simd in2,int n) - { - if (n==3) { - Optimization::Exchange::Exchange3(out1.v,out2.v,in1.v,in2.v); - } else if(n==2) { - Optimization::Exchange::Exchange2(out1.v,out2.v,in1.v,in2.v); - } else if(n==1) { - Optimization::Exchange::Exchange1(out1.v,out2.v,in1.v,in2.v); - } else if(n==0) { - Optimization::Exchange::Exchange0(out1.v,out2.v,in1.v,in2.v); - } - } - - //////////////////////////////////////////////////////////////////// - // General permute; assumes vector length is same across - // all subtypes; may not be a good assumption, but could - // add the vector width as a template param for BG/Q for example - //////////////////////////////////////////////////////////////////// - friend inline void permute0(Grid_simd &y, Grid_simd b) { - y.v = Optimization::Permute::Permute0(b.v); - } - friend inline void permute1(Grid_simd &y, Grid_simd b) { - y.v = Optimization::Permute::Permute1(b.v); - } - friend inline void permute2(Grid_simd &y, Grid_simd b) { - y.v = Optimization::Permute::Permute2(b.v); - } - friend inline void permute3(Grid_simd &y, Grid_simd b) { - y.v = Optimization::Permute::Permute3(b.v); - } - friend inline void permute(Grid_simd &y, Grid_simd b, int perm) { - if (perm & RotateBit) { - int dist = perm & 0xF; - y = rotate(b, dist); - return; - } - else if(perm==3) permute3(y, b); - else if(perm==2) permute2(y, b); - else if(perm==1) permute1(y, b); - else if(perm==0) permute0(y, b); - } - - /////////////////////////////// - // Getting single lanes - /////////////////////////////// - inline Scalar_type getlane(int lane) { - return ((Scalar_type*)&v)[lane]; - } - - inline void putlane(const Scalar_type &S, int lane){ - ((Scalar_type*)&v)[lane] = S; - } - - - -}; // end of Grid_simd class definition - -inline void permute(ComplexD &y,ComplexD b, int perm) { y=b; } -inline void permute(ComplexF &y,ComplexF b, int perm) { y=b; } -inline void permute(RealD &y,RealD b, int perm) { y=b; } -inline void permute(RealF &y,RealF b, int perm) { y=b; } - -//////////////////////////////////////////////////////////////////// -// General rotate -//////////////////////////////////////////////////////////////////// -template = 0> -inline Grid_simd rotate(Grid_simd b, int nrot) { - nrot = nrot % Grid_simd::Nsimd(); - Grid_simd ret; - ret.v = Optimization::Rotate::rotate(b.v, nrot); - return ret; -} -template = 0> -inline Grid_simd rotate(Grid_simd b, int nrot) { - nrot = nrot % Grid_simd::Nsimd(); - Grid_simd ret; - ret.v = Optimization::Rotate::rotate(b.v, 2 * nrot); - return ret; -} -template =0> -inline void rotate( Grid_simd &ret,Grid_simd b,int nrot) -{ - nrot = nrot % Grid_simd::Nsimd(); - ret.v = Optimization::Rotate::rotate(b.v,nrot); -} -template =0> -inline void rotate(Grid_simd &ret,Grid_simd b,int nrot) -{ - nrot = nrot % Grid_simd::Nsimd(); - ret.v = Optimization::Rotate::rotate(b.v,2*nrot); -} - -template -inline void vbroadcast(Grid_simd &ret,const Grid_simd &src,int lane){ - S* typepun =(S*) &src; - vsplat(ret,typepun[lane]); -} -template =0> -inline void rbroadcast(Grid_simd &ret,const Grid_simd &src,int lane){ - S* typepun =(S*) &src; - ret.v = unary(real(typepun[lane]), VsplatSIMD()); -} - - - -/////////////////////// -// Splat -/////////////////////// - -// this is only for the complex version -template = 0, class ABtype> -inline void vsplat(Grid_simd &ret, ABtype a, ABtype b) { - ret.v = binary(a, b, VsplatSIMD()); -} - -// overload if complex -template -inline void vsplat(Grid_simd &ret, EnableIf, S> c) { - vsplat(ret, real(c), imag(c)); -} -template -inline void rsplat(Grid_simd &ret, EnableIf, S> c) { - vsplat(ret, real(c), real(c)); -} - -// if real fill with a, if complex fill with a in the real part (first function -// above) -template -inline void vsplat(Grid_simd &ret, NotEnableIf, S> a) { - ret.v = unary(a, VsplatSIMD()); -} -////////////////////////// - -/////////////////////////////////////////////// -// Initialise to 1,0,i for the correct types -/////////////////////////////////////////////// -// For complex types -template = 0> -inline void vone(Grid_simd &ret) { - vsplat(ret, S(1.0, 0.0)); -} -template = 0> -inline void vzero(Grid_simd &ret) { - vsplat(ret, S(0.0, 0.0)); -} // use xor? -template = 0> -inline void vcomplex_i(Grid_simd &ret) { - vsplat(ret, S(0.0, 1.0)); -} - -template = 0> -inline void visign(Grid_simd &ret) { - vsplat(ret, S(1.0, -1.0)); -} -template = 0> -inline void vrsign(Grid_simd &ret) { - vsplat(ret, S(-1.0, 1.0)); -} - -// if not complex overload here -template = 0> -inline void vone(Grid_simd &ret) { - vsplat(ret, S(1.0)); -} -template = 0> -inline void vzero(Grid_simd &ret) { - vsplat(ret, S(0.0)); -} - -// For integral types -template = 0> -inline void vone(Grid_simd &ret) { - vsplat(ret, 1); -} -template = 0> -inline void vzero(Grid_simd &ret) { - vsplat(ret, 0); -} -template = 0> -inline void vtrue(Grid_simd &ret) { - vsplat(ret, 0xFFFFFFFF); -} -template = 0> -inline void vfalse(Grid_simd &ret) { - vsplat(ret, 0); -} -template -inline void zeroit(Grid_simd &z) { - vzero(z); -} - -/////////////////////// -// Vstream -/////////////////////// -template = 0> -inline void vstream(Grid_simd &out, const Grid_simd &in) { - binary((S *)&out.v, in.v, VstreamSIMD()); -} -template = 0> -inline void vstream(Grid_simd &out, const Grid_simd &in) { - typedef typename S::value_type T; - binary((T *)&out.v, in.v, VstreamSIMD()); -} -template = 0> -inline void vstream(Grid_simd &out, const Grid_simd &in) { - out = in; -} - -//////////////////////////////////// -// Arithmetic operator overloads +,-,* -//////////////////////////////////// -template -inline Grid_simd operator+(Grid_simd a, Grid_simd b) { - Grid_simd ret; - ret.v = binary(a.v, b.v, SumSIMD()); - return ret; -}; - -template -inline Grid_simd operator-(Grid_simd a, Grid_simd b) { - Grid_simd ret; - ret.v = binary(a.v, b.v, SubSIMD()); - return ret; -}; - -// Distinguish between complex types and others -template = 0> -inline Grid_simd real_mult(Grid_simd a, Grid_simd b) { - Grid_simd ret; - ret.v = binary(a.v, b.v, MultRealPartSIMD()); - return ret; -}; -template = 0> -inline Grid_simd real_madd(Grid_simd a, Grid_simd b, Grid_simd c) { - Grid_simd ret; - ret.v = trinary(a.v, b.v, c.v, MaddRealPartSIMD()); - return ret; -}; - - -// Distinguish between complex types and others -template = 0> -inline Grid_simd operator*(Grid_simd a, Grid_simd b) { - Grid_simd ret; - ret.v = binary(a.v, b.v, MultComplexSIMD()); - return ret; -}; - -// Real/Integer types -template = 0> -inline Grid_simd operator*(Grid_simd a, Grid_simd b) { - Grid_simd ret; - ret.v = binary(a.v, b.v, MultSIMD()); - return ret; -}; - -// Distinguish between complex types and others -template = 0> -inline Grid_simd operator/(Grid_simd a, Grid_simd b) { - typedef Grid_simd simd; - - simd ret; - simd den; - typename simd::conv_t conv; - - ret = a * conjugate(b) ; - den = b * conjugate(b) ; - - - auto real_den = toReal(den); - - ret.v=binary(ret.v, real_den.v, DivSIMD()); - - return ret; -}; - -// Real/Integer types -template = 0> -inline Grid_simd operator/(Grid_simd a, Grid_simd b) { - Grid_simd ret; - ret.v = binary(a.v, b.v, DivSIMD()); - return ret; -}; - -/////////////////////// -// Conjugate -/////////////////////// -template = 0> -inline Grid_simd conjugate(const Grid_simd &in) { - Grid_simd ret; - ret.v = unary(in.v, ConjSIMD()); - return ret; -} -template = 0> -inline Grid_simd conjugate(const Grid_simd &in) { - return in; // for real objects -} -// Suppress adj for integer types... // odd; why conjugate above but not adj?? -template = 0> -inline Grid_simd adj(const Grid_simd &in) { - return conjugate(in); -} - -/////////////////////// -// timesMinusI -/////////////////////// -template = 0> -inline void timesMinusI(Grid_simd &ret, const Grid_simd &in) { - ret.v = binary(in.v, ret.v, TimesMinusISIMD()); -} -template = 0> -inline Grid_simd timesMinusI(const Grid_simd &in) { - Grid_simd ret; - timesMinusI(ret, in); - return ret; -} -template = 0> -inline Grid_simd timesMinusI(const Grid_simd &in) { - return in; -} - -/////////////////////// -// timesI -/////////////////////// -template = 0> -inline void timesI(Grid_simd &ret, const Grid_simd &in) { - ret.v = binary(in.v, ret.v, TimesISIMD()); -} -template = 0> -inline Grid_simd timesI(const Grid_simd &in) { - Grid_simd ret; - timesI(ret, in); - return ret; -} -template = 0> -inline Grid_simd timesI(const Grid_simd &in) { - return in; -} - -///////////////////// -// Inner, outer -///////////////////// - -template -inline Grid_simd innerProduct(const Grid_simd &l, - const Grid_simd &r) { - return conjugate(l) * r; -} -template -inline Grid_simd outerProduct(const Grid_simd &l, - const Grid_simd &r) { - return l * conjugate(r); -} - -template -inline Grid_simd trace(const Grid_simd &arg) { - return arg; -} - -//////////////////////////////////////////////////////////// -// copy/splat complex real parts into real; -// insert real into complex and zero imag; -//////////////////////////////////////////////////////////// - -// real = toReal( complex ) -template = 0> -inline Grid_simd toReal(const Grid_simd, V> &in) { - typedef Grid_simd simd; - simd ret; - typename simd::conv_t conv; - conv.v = in.v; // copy the vector content (bytewise) - for (int i = 0; i < simd::Nsimd(); i += 2) { - conv.s[i + 1] = conv.s[i]; // duplicate (r,r);(r,r);(r,r); etc... - } - ret.v = conv.v; - return ret; -} - -// complex = toComplex( real ) -template = 0> // must be a real arg -inline Grid_simd, V> toComplex(const Grid_simd &in) { - typedef Grid_simd Rsimd; - typedef Grid_simd, V> Csimd; - typename Rsimd::conv_t conv; // address as real - - conv.v = in.v; - for (int i = 0; i < Rsimd::Nsimd(); i += 2) { - assert(conv.s[i + 1] == conv.s[i]); - // trap any cases where real was not duplicated - // indicating the SIMD grids of real and imag assignment did not correctly - // match - conv.s[i + 1] = 0.0; // zero imaginary parts - } - Csimd ret; - ret.v = conv.v; - return ret; -} - -/////////////////////////////// -// Define available types -/////////////////////////////// -typedef Grid_simd vRealF; -typedef Grid_simd vRealD; -typedef Grid_simd, SIMD_Ftype> vComplexF; -typedef Grid_simd, SIMD_Dtype> vComplexD; -typedef Grid_simd vInteger; - -// Half precision; no arithmetic support -typedef Grid_simd vRealH; -typedef Grid_simd, SIMD_Htype> vComplexH; - -inline void precisionChange(vRealF *out,vRealD *in,int nvec) -{ - assert((nvec&0x1)==0); - for(int m=0;m*2 -struct is_simd : public std::false_type {}; -template <> struct is_simd : public std::true_type {}; -template <> struct is_simd : public std::true_type {}; -template <> struct is_simd : public std::true_type {}; -template <> struct is_simd : public std::true_type {}; -template <> struct is_simd : public std::true_type {}; - -template using IfSimd = Invoke::value, int> >; -template using IfNotSimd = Invoke::value, unsigned> >; -} - -#endif diff --git a/lib/simd/Grid_vector_types.h b/lib/simd/Grid_vector_types.h index 424b5573..e05fecc4 100644 --- a/lib/simd/Grid_vector_types.h +++ b/lib/simd/Grid_vector_types.h @@ -327,16 +327,12 @@ class Grid_simd { // provides support /////////////////////////////////////// - //#if (__GNUC__ == 5 ) || ( ( __GNUC__ == 6 ) && __GNUC_MINOR__ < 3 ) - //#pragma GCC push_options - //#pragma GCC optimize ("O0") - //#endif template friend inline Grid_simd SimdApply(const functor &func, const Grid_simd &v) { Grid_simd ret; Grid_simd::conv_t conv; Grid_simd::scalar_type s; - + conv.v = v.v; for (int i = 0; i < Nsimd(); i++) { s = conv.s[i]; @@ -364,11 +360,8 @@ class Grid_simd { ret.v = cx.v; return ret; } - //#if (__GNUC__ == 5 ) || ( ( __GNUC__ == 6 ) && __GNUC_MINOR__ < 3 ) - //#pragma GCC pop_options - //#endif /////////////////////// - // Exchange + // Exchange // Al Ah , Bl Bh -> Al Bl Ah,Bh /////////////////////// friend inline void exchange(Grid_simd &out1,Grid_simd &out2,Grid_simd in1,Grid_simd in2,int n) @@ -379,7 +372,7 @@ class Grid_simd { Optimization::Exchange::Exchange2(out1.v,out2.v,in1.v,in2.v); } else if(n==1) { Optimization::Exchange::Exchange1(out1.v,out2.v,in1.v,in2.v); - } else if(n==0) { + } else if(n==0) { Optimization::Exchange::Exchange0(out1.v,out2.v,in1.v,in2.v); } } @@ -406,7 +399,7 @@ class Grid_simd { int dist = perm & 0xF; y = rotate(b, dist); return; - } + } else if(perm==3) permute3(y, b); else if(perm==2) permute2(y, b); else if(perm==1) permute1(y, b); @@ -425,10 +418,9 @@ class Grid_simd { } - + }; // end of Grid_simd class definition - inline void permute(ComplexD &y,ComplexD b, int perm) { y=b; } inline void permute(ComplexF &y,ComplexF b, int perm) { y=b; } inline void permute(RealD &y,RealD b, int perm) { y=b; } @@ -451,29 +443,29 @@ inline Grid_simd rotate(Grid_simd b, int nrot) { ret.v = Optimization::Rotate::rotate(b.v, 2 * nrot); return ret; } -template =0> +template =0> inline void rotate( Grid_simd &ret,Grid_simd b,int nrot) { nrot = nrot % Grid_simd::Nsimd(); ret.v = Optimization::Rotate::rotate(b.v,nrot); } -template =0> +template =0> inline void rotate(Grid_simd &ret,Grid_simd b,int nrot) { nrot = nrot % Grid_simd::Nsimd(); ret.v = Optimization::Rotate::rotate(b.v,2*nrot); } -template +template inline void vbroadcast(Grid_simd &ret,const Grid_simd &src,int lane){ S* typepun =(S*) &src; vsplat(ret,typepun[lane]); -} -template =0> +} +template =0> inline void rbroadcast(Grid_simd &ret,const Grid_simd &src,int lane){ S* typepun =(S*) &src; ret.v = unary(real(typepun[lane]), VsplatSIMD()); -} +} @@ -604,27 +596,13 @@ inline Grid_simd real_mult(Grid_simd a, Grid_simd b) { ret.v = binary(a.v, b.v, MultRealPartSIMD()); return ret; }; -// TEST for Test_simd -template = 0> -inline Grid_simd real_mult(std::complex a, std::complex b) { - Grid_simd ret; - //ret.v = binary(a.v, b.v, MultRealPartSIMD()); - return ret; -}; - template = 0> inline Grid_simd real_madd(Grid_simd a, Grid_simd b, Grid_simd c) { Grid_simd ret; ret.v = trinary(a.v, b.v, c.v, MaddRealPartSIMD()); return ret; }; -// TEST for Test_simd -template = 0> -inline Grid_simd real_madd(std::complex a, std::complex b) { - Grid_simd ret; - //ret.v = binary(a.v, b.v, MultRealPartSIMD()); - return ret; -}; + // Distinguish between complex types and others template = 0> @@ -654,7 +632,7 @@ inline Grid_simd operator/(Grid_simd a, Grid_simd b) { ret = a * conjugate(b) ; den = b * conjugate(b) ; - + auto real_den = toReal(den); ret.v=binary(ret.v, real_den.v, DivSIMD()); @@ -773,8 +751,8 @@ inline Grid_simd, V> toComplex(const Grid_simd &in) { conv.v = in.v; for (int i = 0; i < Rsimd::Nsimd(); i += 2) { - assert(conv.s[i + 1] == - conv.s[i]); // trap any cases where real was not duplicated + assert(conv.s[i + 1] == conv.s[i]); + // trap any cases where real was not duplicated // indicating the SIMD grids of real and imag assignment did not correctly // match conv.s[i + 1] = 0.0; // zero imaginary parts @@ -852,8 +830,6 @@ inline void precisionChange(vComplexD *out,vComplexF *in,int nvec){ precisionCha inline void precisionChange(vComplexD *out,vComplexH *in,int nvec){ precisionChange((vRealD *)out,(vRealH *)in,nvec);} inline void precisionChange(vComplexF *out,vComplexH *in,int nvec){ precisionChange((vRealF *)out,(vRealH *)in,nvec);} - - // Check our vector types are of an appropriate size. #if defined QPX static_assert(2*sizeof(SIMD_Ftype) == sizeof(SIMD_Dtype), "SIMD vector lengths incorrect"); @@ -868,21 +844,14 @@ static_assert(sizeof(SIMD_Ftype) == sizeof(SIMD_Itype), "SIMD vector lengths inc ///////////////////////////////////////// template struct is_simd : public std::false_type {}; -template <> -struct is_simd : public std::true_type {}; -template <> -struct is_simd : public std::true_type {}; -template <> -struct is_simd : public std::true_type {}; -template <> -struct is_simd : public std::true_type {}; -template <> -struct is_simd : public std::true_type {}; +template <> struct is_simd : public std::true_type {}; +template <> struct is_simd : public std::true_type {}; +template <> struct is_simd : public std::true_type {}; +template <> struct is_simd : public std::true_type {}; +template <> struct is_simd : public std::true_type {}; -template -using IfSimd = Invoke::value, int> >; -template -using IfNotSimd = Invoke::value, unsigned> >; +template using IfSimd = Invoke::value, int> >; +template using IfNotSimd = Invoke::value, unsigned> >; } #endif