diff options
author | xinjiang <xinjiang@multicorewareinc.com> | 2013-11-05 10:58:41 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-12 22:38:27 -0600 |
commit | 26cba28d731c1e515058ea69f39528aa7a900c72 (patch) | |
tree | df0a24a23bc36e21e436ec09de5c2734de94d536 | |
parent | b723d47dee7cd1e31364a74daa10764aa531f04f (diff) |
GPU Calc: implemented for FV
AMLOEXT-131 FIX
Change-Id: I45aa49037b991958187a6287d0b7a4283791e186
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 | 50 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.hxx | 14 |
3 files changed, 68 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 069321fafafa..c5b9d75ff84b 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1060,6 +1060,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],new OpDDB)); break; + case ocZW: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i],new OpFV)); + 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 b449a9df8e36..ab4099f9c086 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -486,7 +486,57 @@ void OpINTRATE::GenSlidingWindowFunction( ss << "return tmp;\n"; ss << "}"; } +void OpFV::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetZwDecl); + funs.insert(GetZw); +} +void OpFV::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"; + ss << " double arg4 = " << GetBottom() << ";\n"; + unsigned j = vSubArguments.size(); + while (j--) + { + FormulaToken* pCur = vSubArguments[j]->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[j]->GenSlidingWindowDeclRef(); + ss << "))\n"; + ss << " arg" << j << " = " <<GetBottom() << ";\n"; + ss << " else\n"; +#endif + ss << " arg" << j << " = "; + ss << vSubArguments[j]->GenSlidingWindowDeclRef(); + ss << ";\n"; + } + } + ss << " tmp = GetZw(arg0, arg1, arg2, arg3, arg4);\n"; + ss << " return tmp;\n"; + ss << "}"; +} void OpISPMT::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 de1ffc72dd5a..35da5f3d810a 100644 --- a/sc/source/core/opencl/op_financial.hxx +++ b/sc/source/core/opencl/op_financial.hxx @@ -86,6 +86,20 @@ public: virtual std::string BinFuncName(void) const { return "INTRATE"; } }; +class OpFV: 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 "FV"; } +}; + class OpISPMT: public Normal { public: |