summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordechuang <dechuang@multicorewareinc.com>2013-11-12 16:47:21 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-15 11:54:30 -0600
commit1de904adc62c7d6cd29ecf248dbe941a51e09646 (patch)
tree3898fb358801fe9c7cc5986932060a050a909327
parent8bf3864069cf67ae97299c4e0e042b922a45a989 (diff)
GPU Calc: implemented PRODUCT
AMLOEXT-193 FIX Change-Id: Iaa1ca2f02e44621c8acbb07f74a059a9280f489d 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_math.cxx78
-rw-r--r--sc/source/core/opencl/op_math.hxx7
3 files changed, 89 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index cf727f4e242b..99693e74b293 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1468,6 +1468,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
SubArgument(new DynamicKernelRandomArgument(ts,
ft->Children[i])));
break;
+ case ocProduct:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpProduct));
+ 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 da9bdfdb1a90..dc5d7d4fb565 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1912,6 +1912,84 @@ void OpConvert::GenSlidingWindowFunction(
}
+void OpProduct::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 << " int i = 0;\n";
+ ss << " double product=0.0;\n\n";
+ char sArgNoI[5];
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ sprintf(sArgNoI,"%d",i);
+ ss << std::string(" double arg")+sArgNoI+";\n";
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << std::string(" arg")+sArgNoI+" = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+#ifdef ISNAN
+ ss << std::string(" if(isNan(arg")+sArgNoI+")||((gid0+i)>=";
+ ss << pDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " {\n";
+ ss << std::string(" arg")+sArgNoI+" = 0;\n";
+ ss << " }\n";
+#endif
+ ss << std::string(" product = arg")+sArgNoI+";\n";
+ ss << " for (i = ";
+ ss << "1; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+ ss << std::string(" arg")+sArgNoI+" = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss <<std::string(" if(isNan(arg")+sArgNoI+")||((gid0+i)>=";
+ ss << pDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " {\n";
+ ss << std::string(" arg")+sArgNoI+" = 0;\n";
+ ss << " }\n";
+#endif
+ ss << std::string(" product*=arg")+sArgNoI+";\n";
+ ss << " }\n";
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+#ifdef ISNAN
+ ss << std::string(" arg")+sArgNoI+" = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << std::string(" product*=arg")+sArgNoI+";\n";
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+#ifdef ISNAN
+ ss << std::string(" arg")+sArgNoI+" = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << std::string(" product*=arg")+sArgNoI+";\n";
+#endif
+ }
+ }
+ ss << " return product;\n";
+ ss << "}";
+}
}}
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index cd9b9f702f3b..01cbc82fee40 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -320,6 +320,13 @@ public:
virtual std::string BinFuncName(void) const { return "Mod"; }
};
+class OpProduct: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "Product"; }
+};
class OpSqrtPi: public Normal
{
public: