summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhaochen <haochen@multicorewareinc.com>2013-10-24 15:22:05 +0800
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-29 17:00:11 -0400
commitfa4ea8733c4c99b788ce10e6bacb48e9b8307245 (patch)
tree791933d41a5862294465ea3a34b8b9a49a6f5313
parenteb4e0aded2ddb3d609d15e9c31811f1d9e3fc2e0 (diff)
Implement GEOMEAN in GPU Calc
Change-Id: I059b4e632fd02a865f110692a67e926e581016e0 Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
-rw-r--r--sc/source/core/opencl/OP_Statistical.cxx43
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx4
2 files changed, 46 insertions, 1 deletions
diff --git a/sc/source/core/opencl/OP_Statistical.cxx b/sc/source/core/opencl/OP_Statistical.cxx
index 16f9f8677a70..976b55f4a740 100644
--- a/sc/source/core/opencl/OP_Statistical.cxx
+++ b/sc/source/core/opencl/OP_Statistical.cxx
@@ -176,7 +176,48 @@ class OpGauss:public Normal{
}
virtual std::string BinFuncName(void) const { return "Gauss"; }
};
-
+class OpGeoMean:public Normal{
+ public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments)
+ {
+ FormulaToken *pCur = vSubArguments[0]->GetFormulaToken();
+ assert(pCur);
+ const formula::DoubleVectorRefToken* pCurDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pCurDVR->GetRefRowSize();
+ 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 nVal=0.0;\n\t";
+ ss << "int length="<<nCurWindowSize;
+ ss << ";\n\tdouble tmp = 0;\n\t";
+ ss << "for (int i = 0; i <" << nCurWindowSize << "; i++)\n\t";
+ ss << "{\n\t";
+ ss << "double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n\t";
+#ifdef ISNAN
+ ss<< "if(isNan(arg0)||((gid0+i)>=";
+ ss<<pCurDVR->GetArrayLength();
+ ss<<"))\n\t{";
+ ss<<"length--;\n\t";
+ ss<<"continue;\n\t}\n\t";
+#endif
+ ss << "nVal += log(arg0);\n\t";
+ ss <<"}\n\t";
+ ss<<"tmp = exp(nVal/length);\n\t";
+ ss << "return tmp;\n";
+ ss << "}";
+ }
+ virtual std::string BinFuncName(void) const { return "GeoMean"; }
+};
class OpHarMean:public Normal{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 7d6ef2c4e403..f3df5bcae77c 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -565,6 +565,10 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
mvSubArguments.push_back(SoPHelper<OpGauss>(ts,
ft->Children[i]));
break;
+ case ocGeoMean:
+ mvSubArguments.push_back(SoPHelper<OpGeoMean>(ts,
+ ft->Children[i]));
+ break;
case ocHarMean:
mvSubArguments.push_back(SoPHelper<OpHarMean>(ts,
ft->Children[i]));