diff options
author | dechuang <dechuang@multicorewareinc.com> | 2013-11-09 10:54:40 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-14 14:09:46 -0600 |
commit | c41db78b286fcfba1a03a29045105915f50f48b8 (patch) | |
tree | 3606f24cb64793800210720fdd763019e242fea7 /sc | |
parent | 6bc2c27f983c83745a17fe5c283d53a156053879 (diff) |
GPU Calc: implemented FLOOR
AMLOEXT-169 FIX
Refacting:add NAN processing in max/min formule under the fixed window condition
Signed-off-by: haochen <haochen@multicorewareinc.com>
Change-Id: I619e18b951070d5c8e9d63aef288992f124eceac
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 13 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.cxx | 50 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.hxx | 7 |
3 files changed, 64 insertions, 6 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 2953d6795c23..3f7af7267e7e 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -407,12 +407,9 @@ public: ss << "0; i < "<< nCurWindowSize << "; i++)\n\t\t"; #endif } - else { -#ifdef ISNAN - ss << "0; i < "<< nCurWindowSize << "; i++){\n\t\t"; -#else - ss << "0; i < "<< nCurWindowSize << "; i++)\n\t\t"; -#endif + else + { + ss << "0; i < "<< pDVR->GetArrayLength() << "; i++){\n\t\t"; } nItems += nCurWindowSize; } @@ -1240,6 +1237,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpGammaInv)); break; + case ocFloor: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i], new OpFloor)); + 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 671cb2f59788..ab556d95c510 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -789,6 +789,56 @@ void OpOdd::GenSlidingWindowFunction( ss << "}"; } +void OpFloor::GenSlidingWindowFunction( + std::stringstream &ss, const std::string sSymName, + SubArguments &vSubArguments) +{ + FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur); + ss << "\ndouble " << sSymName; + ss << "_"<< BinFuncName() <<"("; + for (unsigned i = 0; i < vSubArguments.size(); i++) + { + if (i) + ss << ","; + vSubArguments[i]->GenSlidingWindowDecl(ss); + } + ss << ")\n{\n"; + ss <<" int gid0=get_global_id(0);\n"; + ss << " double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef(); + ss << ";\n"; + ss << " double arg1 = " << vSubArguments[1]->GenSlidingWindowDeclRef(); + ss << ";\n"; + ss << " double arg2 = " << vSubArguments[2]->GenSlidingWindowDeclRef(); + ss << ";\n"; +#ifdef ISNAN + ss<< " if(isNan(arg0)||(gid0>="; + ss<<tmpCurDVR->GetArrayLength(); + ss<<"))\n"; + ss<<" arg0 = 0;\n"; + ss<< " if(isNan(arg1)||(gid0>="; + ss<<tmpCurDVR->GetArrayLength(); + ss<<"))\n"; + ss<<" arg1 = 0;\n"; + ss<< " if(isNan(arg2)||(gid0>="; + ss<<tmpCurDVR->GetArrayLength(); + ss<<"))\n"; + ss<<" arg2 = 0;\n"; +#endif + ss <<" if(arg1==0.0)\n"; + ss <<" return 0.0;\n"; + ss <<" else if(arg0*arg1<0.0)\n"; + ss <<" return 0.0000000001;\n"; + ss <<" else if(arg2==0.0&&arg0<0.0)\n"; + ss <<" return (trunc(arg0/arg1)+1)*arg1;\n"; + ss <<" else\n"; + ss <<" return trunc(arg0/arg1)*arg1;\n"; + ss << "}\n"; +} + + + }} /* 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 c1feb0352122..22f70c9352cd 100644 --- a/sc/source/core/opencl/op_math.hxx +++ b/sc/source/core/opencl/op_math.hxx @@ -197,6 +197,13 @@ public: const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "Odd"; } }; +class OpFloor: public Normal +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string BinFuncName(void) const { return "Floor"; } +}; }} #endif |