diff options
author | yangzhang <yangzhang@multicorewareinc.com> | 2013-11-10 10:11:40 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-14 20:30:46 -0600 |
commit | a9d49e21bf0d8ca9d516a2897067ad2185576f5d (patch) | |
tree | 589088fe3f15e7982e913f4aa15755f5ece3689e | |
parent | 0f08b857c9dd01809286f78375d6195f8da85323 (diff) |
GPU Calc: implemented BITRSHFIT
AMLOEXT-168 FIX
Change-Id: I5596ea32861eeb7eb36d9800d410ebada0721745
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.cxx | 45 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.hxx | 7 |
3 files changed, 56 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index a761cc32ea93..729e5e9da8bd 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1317,6 +1317,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpBitLshift)); break; + case ocBitRshift: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i], new OpBitRshift)); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx index c6e1f7e88d6a..6f34d61ee0dc 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -1466,7 +1466,52 @@ void OpBitLshift::GenSlidingWindowFunction(std::stringstream &ss, ss << "num / pow(2.0, fabs(shift_amount)));\n"; ss << "}"; } +void OpBitRshift::GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments) +{ + ss << "\ndouble " << sSymName; + ss << "_"<< BinFuncName() <<"("; + for (unsigned i = 0; i < vSubArguments.size(); i++) + { + if (i) ss << ","; + vSubArguments[i]->GenSlidingWindowDecl(ss); + } + ss << ") {\n"; + ss << " int gid0 = get_global_id(0);\n"; + ss << " double num = " << GetBottom() << ";\n"; + ss << " double shift_amount = " << GetBottom() << ";\n"; +#ifdef ISNAN + FormulaToken *iNum = vSubArguments[0]->GetFormulaToken(); + const formula::SingleVectorRefToken* tmpCurDVRNum= + dynamic_cast<const formula::SingleVectorRefToken*>(iNum); + FormulaToken *iShiftAmount = vSubArguments[1]->GetFormulaToken(); + const formula::SingleVectorRefToken* tmpCurDVRShiftAmount= + dynamic_cast<const formula::SingleVectorRefToken*>(iShiftAmount); + ss << " int buffer_num_len = "; + ss << tmpCurDVRNum->GetArrayLength() << ";\n"; + ss << " int buffer_shift_amount_len = "; + ss << tmpCurDVRShiftAmount->GetArrayLength() << ";\n"; + ss << " if((gid0)>=buffer_num_len || isNan("; + ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n"; + ss << " num = " << GetBottom() << ";\n"; + ss << " else\n "; +#endif + ss << " num = floor("; + ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ");\n"; +#ifdef ISNAN + ss << " if((gid0)>=buffer_shift_amount_len || isNan("; + ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n"; + ss << " shift_amount = " <<GetBottom()<< ";\n"; + ss << " else\n "; +#endif + ss << " shift_amount = floor("; + ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ");\n"; + ss << " return floor("; + ss << "shift_amount >= 0 ? num / pow(2.0, shift_amount) : "; + ss << "num * pow(2.0, fabs(shift_amount)));\n"; + ss << "}"; +} }} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx index 33cc6a2d9e2d..c794e4ad38c7 100644 --- a/sc/source/core/opencl/op_math.hxx +++ b/sc/source/core/opencl/op_math.hxx @@ -182,6 +182,13 @@ public: virtual std::string GetBottom(void) { return "0.0"; } virtual std::string BinFuncName(void) const { return "ScBitLshift"; } }; +class OpBitRshift:public Normal{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string GetBottom(void) { return "0.0"; } + virtual std::string BinFuncName(void) const { return "ScBitRshift"; } +}; class OpLn: public CheckVariables { public: |