diff options
author | minwang <min@multicorewareinc.com> | 2013-11-04 11:32:43 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-03 23:49:14 -0600 |
commit | 457b349edbaf6d9dc747f3a631fee70e0c035bae (patch) | |
tree | 6f30b6096e6ed7d0db7d4708206e3e575848c871 | |
parent | 5c744383ebdb053a534dc7ab3aabab4e071cc2b1 (diff) |
GPU Calc: implemented COUPNUM
AMLOEXT-74 FIX
Change-Id: Ic7f274f089f7f6cc6b767c4a07844014eeded61d
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 | 6 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.cxx | 97 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.hxx | 9 |
3 files changed, 111 insertions, 1 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 24647bf5982a..1cc0b9f48a95 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1137,6 +1137,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpPrice)); } + else if ( !(pChild->GetExternal().compareTo(OUString( + "com.sun.star.sheet.addin.Analysis.getCoupnum")))) + { + mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], + new OpCoupnum)); + } break; default: throw UnhandledToken(pChild, "unhandled opcode"); diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx index a40a113ecf09..b5b9a5c6b616 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -2740,7 +2740,102 @@ void OpCoupdaysnc::GenSlidingWindowFunction( ss << "}"; } - void OpReceived::BinInlineFun(std::set<std::string>& decls, +void OpCoupnum::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl); + decls.insert(DaysToDateDecl);decls.insert(DateToDaysDecl); + decls.insert(GetNullDateDecl);decls.insert(lcl_GetcoupnumDecl); + decls.insert(coupnumDecl); + funs.insert(IsLeapYear);funs.insert(DaysInMonth); + funs.insert(DaysToDate);funs.insert(DateToDays); + funs.insert(GetNullDate); + funs.insert(lcl_Getcoupnum); + funs.insert(coupnum); +} +void OpCoupnum::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 = " << GetBottom() <<";\n "; + ss << "int gid0 = get_global_id(0);\n "; + ss << "int nSettle,nMat,nFreq,nBase;\n "; +#ifdef ISNAN + FormulaToken* tmpCur0 = vSubArguments[0]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur0); + FormulaToken* tmpCur1 = vSubArguments[1]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur1); + FormulaToken* tmpCur2 = vSubArguments[2]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur2); + FormulaToken* tmpCur3 = vSubArguments[3]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur3); + ss<< "int buffer_nSettle_len = "; + ss<< tmpCurDVR0->GetArrayLength(); + ss << ";\n "; + ss<< "int buffer_nMat_len = "; + ss<< tmpCurDVR1->GetArrayLength(); + ss << ";\n "; + ss<< "int buffer_nFreq_len = "; + ss<< tmpCurDVR2->GetArrayLength(); + ss << ";\n "; + ss<< "int buffer_nBase_len = "; + ss<< tmpCurDVR3->GetArrayLength(); + ss << ";\n "; +#endif +#ifdef ISNAN + ss <<"if(gid0 >= buffer_nSettle_len || isNan("; + ss <<vSubArguments[0]->GenSlidingWindowDeclRef(); + ss <<"))\n "; + ss <<"nSettle = 0;\n else\n "; +#endif + ss << "nSettle=(int)"; + ss << vSubArguments[0]->GenSlidingWindowDeclRef(); + ss <<";\n "; +#ifdef ISNAN + ss <<"if(gid0 >= buffer_nMat_len || isNan("; + ss <<vSubArguments[1]->GenSlidingWindowDeclRef(); + ss <<"))\n "; + ss <<"nMat = 0;\n else\n "; +#endif + ss << "nMat=(int)"; + ss << vSubArguments[1]->GenSlidingWindowDeclRef(); + ss << ";\n "; +#ifdef ISNAN + ss <<"if(gid0 >= buffer_nFreq_len || isNan("; + ss <<vSubArguments[2]->GenSlidingWindowDeclRef(); + ss <<"))\n "; + ss <<"nFreq = 0;\n else\n "; +#endif + ss << "nFreq=(int)"; + ss << vSubArguments[2]->GenSlidingWindowDeclRef(); + ss <<";\n "; +#ifdef ISNAN + ss <<"if(gid0 >= buffer_nBase_len || isNan("; + ss <<vSubArguments[3]->GenSlidingWindowDeclRef(); + ss <<"))\n "; + ss <<"nBase = 0;\n else\n "; +#endif + ss << "nBase=(int)"; + ss << vSubArguments[3]->GenSlidingWindowDeclRef(); + ss << ";\n "; + ss <<"tmp = coupnum(nSettle,nMat,nFreq,nBase);\n "; + ss << "return tmp;\n"; + ss << "}"; +} + +void OpReceived::BinInlineFun(std::set<std::string>& decls, std::set<std::string>& funs) { decls.insert(GetYearDiffDecl);decls.insert(GetDiffDateDecl); diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx index fc730767e554..6bc3c19927e4 100644 --- a/sc/source/core/opencl/op_financial.hxx +++ b/sc/source/core/opencl/op_financial.hxx @@ -315,7 +315,16 @@ public: virtual std::string BinFuncName(void) const { return "Coupdaysnc"; } }; +class OpCoupnum:public Normal +{ +public: + virtual std::string GetBottom(void) { return "0";} + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&); + virtual std::string BinFuncName(void) const { return "Coupnum"; } +}; class OpReceived:public Normal { public: |