diff options
author | mulei <mulei@multicorewareinc.com> | 2013-11-05 15:53:28 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-13 00:45:04 -0600 |
commit | e7ad31bf7acd92cac6ee4fead76dee2bdee45029 (patch) | |
tree | 24f1518adc93c169e1387638c39de28dd40a0459 | |
parent | GPU Calc: unit test cases for KURT (diff) | |
download | core-e7ad31bf7acd92cac6ee4fead76dee2bdee45029.tar.gz core-e7ad31bf7acd92cac6ee4fead76dee2bdee45029.zip |
GPU Calc: implemented for NPER
AMLOEXT-108 FIX
Change-Id: I3abd1f270c7fe257f59d0080a8fc5a4fd5c7b33e
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_financial.cxx | 68 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.hxx | 7 |
3 files changed, 79 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 34cf5737a78c..c5e967a7d433 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1076,6 +1076,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpKurt)); break; + case ocZZR: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i], new OpNPER)); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx index ccebf0366dd4..0e619332ebb2 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -2458,6 +2458,74 @@ void OpPrice::GenSlidingWindowFunction(std::stringstream &ss, ss << "return tmp;\n"; ss << "}"; } +void OpNPER::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 << " double tmp = 0;\n"; + ss << " int gid0 = get_global_id(0);\n"; + for (unsigned n = 0; n < vSubArguments.size(); n++) + { + ss<<" double tmp"<<n<<"="; + ss<<vSubArguments[n]->GenSlidingWindowDeclRef(); + ss<<";\n"; + } +#ifdef ISNAN + FormulaToken *tmpCur0 = vSubArguments[0] + ->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur0); + ss<<" if("<<tmpCurDVR0->GetArrayLength()<<"<=gid0||"; + ss <<"isNan(tmp0))\n"; + ss<<" tmp0= 0;\n"; + FormulaToken *tmpCur1 = vSubArguments[1] + ->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur1); + ss<<" if("<<tmpCurDVR1->GetArrayLength()<<"<=gid0||"; + ss <<"isNan(tmp1))\n"; + ss<<" tmp1= 0;\n"; + FormulaToken *tmpCur2 = vSubArguments[2] + ->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur2); + ss<<" if("<<tmpCurDVR2->GetArrayLength()<<"<=gid0||"; + ss <<"isNan(tmp2))\n"; + ss<<" tmp2= 0;\n"; + FormulaToken *tmpCur3 = vSubArguments[3] + ->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur3); + ss<<" if("<<tmpCurDVR3->GetArrayLength()<<"<=gid0||"; + ss <<"isNan(tmp3))\n"; + ss<<" tmp3= 0;\n"; + FormulaToken *tmpCur4 = vSubArguments[4] + ->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR4= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur4); + ss<<" if("<<tmpCurDVR4->GetArrayLength()<<"<=gid0||"; + ss <<"isNan(tmp4))\n"; + ss<<" tmp4= 0;\n"; +#endif + ss <<" if (tmp0 == 0.0)\n"; + ss <<" tmp=(-(tmp2 + tmp3)/tmp1);\n"; + ss <<" else if (tmp4 > 0.0)\n"; + ss <<" tmp=log(-(tmp0*tmp3-tmp1*(1.0+tmp0))/"; + ss <<"(tmp0*tmp2+tmp1*(1.0+tmp0)))/log(1.0+tmp0);\n"; + ss <<" else\n"; + ss <<" tmp=log(-(tmp0*tmp3-tmp1)/(tmp0*tmp2+tmp1))"; + ss <<"/log(1.0+tmp0);\n"; + ss <<" return tmp;\n"; + ss <<"}"; +} void OpPPMT::BinInlineFun(std::set<std::string>& decls, std::set<std::string>& funs) { diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx index a24db10769c1..c7450bd84aee 100644 --- a/sc/source/core/opencl/op_financial.hxx +++ b/sc/source/core/opencl/op_financial.hxx @@ -313,6 +313,13 @@ public: virtual std::string BinFuncName(void) const { return "Price"; } }; +class OpNPER: public Normal +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string BinFuncName(void) const { return "NPER"; } +}; class OpPPMT: public Normal { public: |