summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhaochen <haochen@multicorewareinc.com>2013-10-24 14:45:46 +0800
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-29 17:00:09 -0400
commitdc8b548a4777af12681b02b7ead6a9a861c1e05b (patch)
tree3bef5f48e603560b9547cd21b92913db737b1671
parente1afa24b6b0c043d8b74e7ee9bbda5e97c4bee65 (diff)
Implement GAMMALN in GPU Calc
Change-Id: Ib61c5d345de9804308a2552266b61dd66c020b78 Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
-rw-r--r--sc/source/core/opencl/OP_Statistical.cxx34
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx4
2 files changed, 38 insertions, 0 deletions
diff --git a/sc/source/core/opencl/OP_Statistical.cxx b/sc/source/core/opencl/OP_Statistical.cxx
index 2638c80c4358..7a23250b0294 100644
--- a/sc/source/core/opencl/OP_Statistical.cxx
+++ b/sc/source/core/opencl/OP_Statistical.cxx
@@ -111,6 +111,40 @@ class OpGamma:public Normal{
virtual std::string BinFuncName(void) const { return "Gamma"; }
};
+class OpGammaLn:public Normal{
+ public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments)
+ {
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
+formula::SingleVectorRefToken *>(tmpCur);
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
+ }
+ ss << ") {\n\t";
+ ss <<"int gid0=get_global_id(0);\n\t";
+ ss << "double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n\t";
+#ifdef ISNAN
+ ss<< "if(isNan(arg0)||(gid0>=";
+ ss<<tmpCurDVR->GetArrayLength();
+ ss<<"))\n\t\t";
+ ss<<"arg0 = 0;\n\t";
+#endif
+ ss << "double tmp=lgamma(arg0);\n\t";
+ ss << "return tmp;\n";
+ ss << "}\n";
+ }
+ virtual std::string BinFuncName(void) const { return "GammaLn"; }
+};
+
+
}}
#endif
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 60957a6d8513..335435290b48 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -557,6 +557,10 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
case ocLIA:
mvSubArguments.push_back(SoPHelper<OpSLN>(ts,
ft->Children[i]));
+ case ocGammaLn:
+ mvSubArguments.push_back(SoPHelper<OpGammaLn>(ts,
+ ft->Children[i]));
+ break;
break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(