From 0acbf77bc6dbc436e7e9f5df52fafd0f9f521816 Mon Sep 17 00:00:00 2001 From: Lanny91 Date: Thu, 24 Nov 2016 13:24:12 +0000 Subject: [PATCH 1/2] Add QPX Div structure --- lib/simd/Grid_qpx.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/simd/Grid_qpx.h b/lib/simd/Grid_qpx.h index 07933f52..1cd6edae 100644 --- a/lib/simd/Grid_qpx.h +++ b/lib/simd/Grid_qpx.h @@ -245,6 +245,21 @@ namespace Optimization { } }; + struct Div{ + // Real double + inline vector4double operator()(vector4double a, vector4double b){ + return vec_swdivs(a, b); + } + + // Real float + FLOAT_WRAP_2(operator(), inline) + + // Integer + inline int operator()(int a, int b){ + return a/b; + } + } + struct Conj{ // Complex double inline vector4double operator()(vector4double v){ @@ -412,6 +427,7 @@ template using ReduceSIMD = Optimization::Reduce; // Arithmetic operations typedef Optimization::Sum SumSIMD; typedef Optimization::Sub SubSIMD; +typedef Optimization::Div DivSIMD; typedef Optimization::Mult MultSIMD; typedef Optimization::MultComplex MultComplexSIMD; typedef Optimization::Conj ConjSIMD; From b18950f776954213ecda0b4785aec4cb67833680 Mon Sep 17 00:00:00 2001 From: Lanny91 Date: Fri, 25 Nov 2016 13:21:33 +0000 Subject: [PATCH 2/2] Added simd real divide test with QPX divide fixes --- lib/simd/Grid_qpx.h | 14 +++++++------- tests/Test_simd.cc | 8 ++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/simd/Grid_qpx.h b/lib/simd/Grid_qpx.h index 1cd6edae..bc86291d 100644 --- a/lib/simd/Grid_qpx.h +++ b/lib/simd/Grid_qpx.h @@ -244,22 +244,22 @@ namespace Optimization { return a*b; } }; - + struct Div{ // Real double inline vector4double operator()(vector4double a, vector4double b){ - return vec_swdivs(a, b); + return vec_swdiv(a, b); } - + // Real float FLOAT_WRAP_2(operator(), inline) - + // Integer inline int operator()(int a, int b){ return a/b; } - } - + }; + struct Conj{ // Complex double inline vector4double operator()(vector4double v){ @@ -427,8 +427,8 @@ template using ReduceSIMD = Optimization::Reduce; // Arithmetic operations typedef Optimization::Sum SumSIMD; typedef Optimization::Sub SubSIMD; -typedef Optimization::Div DivSIMD; typedef Optimization::Mult MultSIMD; +typedef Optimization::Div DivSIMD; typedef Optimization::MultComplex MultComplexSIMD; typedef Optimization::Conj ConjSIMD; typedef Optimization::TimesMinusI TimesMinusISIMD; diff --git a/tests/Test_simd.cc b/tests/Test_simd.cc index 189f0559..92f9bcd8 100644 --- a/tests/Test_simd.cc +++ b/tests/Test_simd.cc @@ -50,6 +50,12 @@ public: template void operator()(vec &rr,vec &i1,vec &i2) const { rr = i1*i2;} std::string name(void) const { return std::string("Times"); } }; +class funcDivide { +public: + funcDivide() {}; + template void operator()(vec &rr,vec &i1,vec &i2) const { rr = i1/i2;} + std::string name(void) const { return std::string("Divide"); } +}; class funcConj { public: funcConj() {}; @@ -341,6 +347,7 @@ int main (int argc, char ** argv) Tester(funcPlus()); Tester(funcMinus()); Tester(funcTimes()); + Tester(funcDivide()); Tester(funcAdj()); Tester(funcConj()); Tester(funcInnerProduct()); @@ -371,6 +378,7 @@ int main (int argc, char ** argv) Tester(funcPlus()); Tester(funcMinus()); Tester(funcTimes()); + Tester(funcDivide()); Tester(funcAdj()); Tester(funcConj()); Tester(funcInnerProduct());