summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhongyu zhong <hongyu@multicorewareinc.com>2013-11-06 11:44:46 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-13 14:39:17 -0600
commit03cc4ca5c448c2600828020e9ef2313468f6e0b2 (patch)
tree9c9d6b793831c422172e5b504e676f9584cfa1a4
parent00d4959f96a2c1cf49a2b674ea02712a2252c2dd (diff)
GPU Calc: implemented for PERMUT
AMLOEXT-103 FIX Change-Id: Id96ce91b8d7cb5c2949e52e5ace48c66dc5b8639 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.cxx4
-rw-r--r--sc/source/core/opencl/op_statistical.cxx62
-rw-r--r--sc/source/core/opencl/op_statistical.hxx6
3 files changed, 72 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index e3df0986035c..40fe93014c9b 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1112,6 +1112,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpNormsinv));
break;
+ case ocVariationen:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpVariationen));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 878e01c96978..cdd892bfeae5 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1057,6 +1057,68 @@ void OpNormsdist::GenSlidingWindowFunction(
ss << " return tmp;\n";
ss << "}\n";
}
+void OpVariationen::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 <<" int gid0=get_global_id(0);\n";
+ ss <<" double inA;\n";
+ ss <<" double inB;\n";
+ ss <<" double tmp;\n";
+#ifdef ISNAN
+ FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ ss << " int buffer_fIna_len = ";
+ ss << tmpCurDVR0->GetArrayLength();
+ ss << ";\n";
+ ss << " int buffer_fInb_len = ";
+ ss << tmpCurDVR1->GetArrayLength();
+ ss << ";\n";
+#endif
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_fIna_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " inA = 0;\nelse \n";
+#endif
+ ss << " inA = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << "if((gid0)>=buffer_fInb_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " inB = 0;\nelse \n";
+#endif
+ ss << " inB = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " if(inB == 0.0)\n";
+ ss << " tmp = 1.0;\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " double nVal = 1;\n";
+ ss << " for( int i =0; i<inB; i++)\n";
+ ss << " {\n";
+ ss << " nVal *= inA ;\n";
+ ss << " inA = inA - 1;\n";
+ ss << " }\n";
+ ss << " tmp = nVal;\n";
+ ss << " }\n";
+ ss << " return tmp;\n";
+ ss << "}\n";
+}
void OpNorminv::GenSlidingWindowFunction(
std::stringstream &ss,const std::string sSymName,
SubArguments &vSubArguments)
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 817e41369fa7..2491c6ddfa80 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -154,6 +154,12 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Kurt"; }
};
+class OpVariationen:public Normal{
+ public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "OpVariationen"; }
+};
}}
#endif