summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authoryiming ju <yiming@multicorewareinc.com>2013-11-13 09:13:55 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-15 11:54:31 -0600
commit2e348a2e37c702273416816122c49da90ad3bb65 (patch)
tree57c173ac482f2a6e8e09fce8e012de1a8f9216f4 /sc
parent67e2b033b1ba0938f294e853b98ce748e0fb1fa5 (diff)
GPU Calc: implemented SUMX2PY2
AMLOEXT-200 FIX Change-Id: I61ec2c11db0bd9bce4a0b32cf266ab39d5439a08 Signed-off-by: haochen <haochen@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx4
-rw-r--r--sc/source/core/opencl/op_array.cxx56
-rw-r--r--sc/source/core/opencl/op_array.hxx8
3 files changed, 68 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 1f3871bbe2bb..6c27cd15c6af 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1481,6 +1481,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpSumX2MY2));
break;
+ case ocSumX2DY2:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpSumX2PY2));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_array.cxx b/sc/source/core/opencl/op_array.cxx
index ff1f54f61903..e656f7bfefb0 100644
--- a/sc/source/core/opencl/op_array.cxx
+++ b/sc/source/core/opencl/op_array.cxx
@@ -79,6 +79,62 @@ void OpSumX2MY2::GenSlidingWindowFunction(std::stringstream &ss,
ss << "}";
}
+void OpSumX2PY2::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 {\n";
+ ss << " int gid0=get_global_id(0);\n";
+ ss << " double tmp =0;\n";
+ GenTmpVariables(ss,vSubArguments);
+ if(vSubArguments[0]->GetFormulaToken()->GetType() ==
+ formula::svDoubleVectorRef)
+ {
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ const formula::DoubleVectorRefToken*pCurDVR= dynamic_cast<const
+ formula::DoubleVectorRefToken *>(tmpCur);
+ size_t nCurWindowSize = pCurDVR->GetArrayLength() <
+ pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
+ pCurDVR->GetRefRowSize() ;
+ ss << " int i ;\n";
+ ss << " for (i = ";
+ if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
+ ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
+ } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
+ ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
+ } else {
+ ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
+ }
+ ss << " {\n";
+ if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+ {
+ ss << " int doubleIndex =i+gid0;\n";
+ }else
+ {
+ ss << " int doubleIndex =i;\n";
+ }
+
+ CheckSubArgumentIsNan(ss,vSubArguments,0);
+ CheckSubArgumentIsNan(ss,vSubArguments,1);
+ ss << " tmp +=pow(tmp0,2) + pow(tmp1,2);\n";
+ ss <<" }\n";
+ }
+ else
+ {
+ ss << " int singleIndex =gid0;\n";
+ CheckAllSubArgumentIsNan(ss, vSubArguments);
+ ss << " tmp = pow(tmp0,2) + pow(tmp1,2);\n";
+ }
+ ss << " return tmp;\n";
+ ss << "}";
+}
}}
diff --git a/sc/source/core/opencl/op_array.hxx b/sc/source/core/opencl/op_array.hxx
index e1f5bea16fe9..c0eff09ff5f3 100644
--- a/sc/source/core/opencl/op_array.hxx
+++ b/sc/source/core/opencl/op_array.hxx
@@ -22,6 +22,14 @@ public:
virtual std::string BinFuncName(void) const { return "SumX2MY2"; }
};
+class OpSumX2PY2: public CheckVariables
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "SumX2PY2"; }
+};
+
}}
#endif