diff options
author | xinjiang <xinjiang@multicorewareinc.com> | 2013-11-04 10:40:51 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-03 22:47:40 -0600 |
commit | 1c239f51064e30713ac87abd3697d73bc5e5bcc1 (patch) | |
tree | f889a893a58f03077f845ea55a45733c93fc324c /sc | |
parent | 12a86d12e9be04b5ce3df946e6c7b5a065533cbd (diff) |
GPU Calc: implemented ISPMT in GPU calc
AMLOEXT-99 FIX
Change-Id: I8cd9f130c190e6925873a00579cb7c334201f418
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.cxx | 45 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.hxx | 11 |
3 files changed, 59 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index d4dada657a4a..9610a4af4fb7 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1013,6 +1013,9 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( case ocCosecant: mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpCsc)); break; + case ocISPMT: + mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpISPMT)); + 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 329dd77b4dd9..503087b3140d 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -487,6 +487,51 @@ void OpINTRATE::GenSlidingWindowFunction( ss << "}"; } +void OpISPMT::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"; + ss << " double arg3 = " << 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 = arg3 * arg0 * ( arg1 / arg2 - 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 7a79dde12393..6add67f31c75 100644 --- a/sc/source/core/opencl/op_financial.hxx +++ b/sc/source/core/opencl/op_financial.hxx @@ -86,6 +86,17 @@ public: virtual std::string BinFuncName(void) const { return "INTRATE"; } }; +class OpISPMT: 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 "ISPMT"; } +}; + class Fvschedule: public Normal { public: |