diff options
author | xinjiang <xinjiang@multicorewareinc.com> | 2013-12-13 15:12:04 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-12-19 17:53:57 -0600 |
commit | 7090efc4ba25e3e485a594d9d88360738d4133cc (patch) | |
tree | d88e0bf4947c7009531588ab7b1b2ea6351d0348 | |
parent | 8bdde72ce452222468278f7c7f8532dca2335284 (diff) |
GPU Calc: implemented FACT
AMLOEXT-362 FIX
Change-Id: I68f84297dbc8bc75fd65d6e30c0bdc1152cfdc29
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei@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_math.cxx | 72 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.hxx | 7 |
3 files changed, 82 insertions, 1 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index f649939cfa75..124ae90829e7 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -2452,6 +2452,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],new OpIsOdd)); break; + case ocFact: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i], new OpFact)); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx index f6796218addb..1db438c0e8ed 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -2665,7 +2665,77 @@ void OpDeg::GenSlidingWindowFunction(std::stringstream &ss, ss << "}"; } - +void OpFact::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"; + FormulaToken* pCur = vSubArguments[0]->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() << "){\n"; +#endif + } + else if (pCur->GetType() == formula::svDouble) + { +#ifdef ISNAN + ss << " {\n"; +#endif + } +#ifdef ISNAN + if(ocPush==vSubArguments[0]->GetFormulaToken()->GetOpCode()) + { + ss << " if (isNan("; + ss << vSubArguments[0]->GenSlidingWindowDeclRef(); + ss << "))\n"; + ss << " arg0 = 0;\n"; + ss << " else\n"; + ss << " arg0 = "; + ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n"; + ss << " arg0 = floor(arg0);\n"; + ss << " if (arg0 < 0.0)\n"; + ss << " return 0.0;\n"; + ss << " else if (arg0 == 0.0)\n"; + ss << " return 1.0;\n"; + ss << " else if (arg0 <= 170.0)\n"; + ss << " {\n"; + ss << " double fTemp = arg0;\n"; + ss << " while (fTemp > 2.0)\n"; + ss << " {\n"; + ss << " fTemp = fTemp - 1;\n"; + ss << " arg0 = arg0 * fTemp;\n"; + ss << " }\n"; + ss << " }\n"; + ss << " else\n"; + ss << " return -DBL_MAX;\n"; + ss << " }\n"; + } + else + { + ss << " arg0 = "; + ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n"; + } +#else + ss << " arg0 = "; + ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n"; +#endif + ss << " return arg0;\n"; + ss << "}"; +} }} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx index 37e649169be8..ffdb74c3d9fb 100644 --- a/sc/source/core/opencl/op_math.hxx +++ b/sc/source/core/opencl/op_math.hxx @@ -429,6 +429,13 @@ public: const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "Countif"; } }; +class OpFact: public Normal{ +public: + virtual void GenSlidingWindowFunction(std::stringstream& ss, + const std::string sSymName, SubArguments& vSubArguments); + virtual std::string GetBottom(void) { return "0.0"; } + virtual std::string BinFuncName(void) const { return "Fact"; } +}; }} #endif |