diff options
author | xinjiang <xinjiang@multicorewareinc.com> | 2013-11-04 11:18:04 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-03 23:37:20 -0600 |
commit | 0644c59f1e2822c687ef0366f6c02b3b21a3f01a (patch) | |
tree | a0aefa6acc1c07acebed54ece519928cf138f51e | |
parent | d454a57acd6bada1cd6913a7c42f8bf3f0a39a70 (diff) |
GPU Calc: implemented DURATION
AMLOEXT-111 FIX
Change-Id: I114e5b20326657f7fd3e0de7162a8ae190059b2a
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 | 42 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.hxx | 12 |
3 files changed, 58 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index ce3223e85225..24647bf5982a 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1016,6 +1016,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( case ocISPMT: mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpISPMT)); break; + case ocLaufz: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i], new OpDuration)); + 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 f9f1fa610bf1..a40a113ecf09 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -531,6 +531,48 @@ void OpISPMT::GenSlidingWindowFunction(std::stringstream& ss, ss << "}"; } +void OpDuration::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 << " double arg0 = " << GetBottom() << ";\n"; + ss << " double arg1 = " << GetBottom() << ";\n"; + ss << " double arg2 = " << GetBottom() << ";\n"; + unsigned i = vSubArguments.size(); + while (i--) + { + FormulaToken* pCur = vSubArguments[i]->GetFormulaToken(); + assert(pCur); + if(pCur->GetType() == formula::svSingleVectorRef) + { +#ifdef ISNAN + const formula::SingleVectorRefToken* pSVR = + dynamic_cast< const formula::SingleVectorRefToken* >(pCur); + ss << " if(gid0 >= " << pSVR->GetArrayLength() << " || isNan("; + ss << vSubArguments[i]->GenSlidingWindowDeclRef(); + ss << "))\n"; + ss << " arg" << i << " = " <<GetBottom() << ";\n"; + ss << " else\n"; +#endif + ss << " arg" << i << " = "; + ss << vSubArguments[i]->GenSlidingWindowDeclRef(); + ss << ";\n"; + } + } + ss << " tmp = log(arg2 / arg1) / log(arg0 + 1.0);\n"; + ss << " return tmp;\n"; + ss << "}"; +} void Fvschedule::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx index cd62f82614b2..fc730767e554 100644 --- a/sc/source/core/opencl/op_financial.hxx +++ b/sc/source/core/opencl/op_financial.hxx @@ -97,6 +97,18 @@ public: virtual std::string BinFuncName(void) const { return "ISPMT"; } }; +class OpDuration: public Normal +{ +public: + virtual std::string GetBottom(void) { return "0"; } + + virtual void GenSlidingWindowFunction(std::stringstream& ss, + const std::string sSymName, SubArguments& vSubArguments); + + virtual std::string BinFuncName(void) const { return "Duration"; } +}; + + class Fvschedule: public Normal { public: |