summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormingli <mingli@multicorewareinc.com>2013-12-16 10:08:02 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-12-19 17:53:58 -0600
commitbcb633c42396c01480bb7a34de45b5ee5ee86d81 (patch)
tree336b595862edae2dff99400986f63b579d4c01e0
parentfd4b93627a329db84bb7a350769a9844f0478356 (diff)
GPU Calc: implemented COUNTA
AMLOEXT-208 FIX Change-Id: I0b66d4c9acedeeed4ffe90da7518e0c853d14ce1 Signed-off-by: haochen <haochen@multicorewareinc.com> Signed-off-by: Wei Wei <weiwei@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.cxx172
-rw-r--r--sc/source/core/opencl/op_statistical.hxx9
3 files changed, 185 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 428196ee3ef7..4bc5a7562623 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2549,6 +2549,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpMinA));
break;
+ case ocCount2:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpCountA));
+ 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 11b9eea9ef68..48ee80619d6a 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -9017,6 +9017,178 @@ void OpMinA::GenSlidingWindowFunction(
ss << " return tmp0 == 1.79769e+308 ? 0.0 : tmp0;\n";
ss << "}\n";
}
+void OpCountA::GenSlidingWindowFunction(
+ std::stringstream &ss, const std::string sSymName, SubArguments &
+vSubArguments)
+{
+ int isMixed = 0;
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
+ }
+ ss << ")\n";
+ ss << "{\n";
+ ss << " int gid0=get_global_id(0);\n";
+ ss << " double nCount = 0.0;\n";
+ size_t i = vSubArguments.size();
+ size_t nItems = 0;
+ ss <<"\n";
+ for (i = 0; i < vSubArguments.size(); i++)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ if(pDVR->GetArrays()[0].mpNumericArray
+ && pDVR->GetArrays()[0].mpStringArray)
+ isMixed = svDoubleVectorRefDoubleString;
+ else if(pDVR->GetArrays()[0].mpNumericArray)
+ isMixed = svDoubleVectorRefDouble;
+ else if(pDVR->GetArrays()[0].mpStringArray)
+ isMixed = svDoubleVectorRefString;
+ else
+ isMixed = svDoubleVectorRefNULL;
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++){\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+#endif
+ } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ else {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ nItems += nCurWindowSize;
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+#ifdef ISNAN
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+
+ if(pSVR->GetArray().mpNumericArray
+ && pSVR->GetArray().mpStringArray)
+ isMixed = svSingleVectorRefDoubleString;
+ else if(pSVR->GetArray().mpNumericArray)
+ isMixed = svSingleVectorRefDouble;
+ else if(pSVR->GetArray().mpStringArray)
+ isMixed = svSingleVectorRefString;
+ else
+ isMixed = svSingleVectorRefNULL;
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#else
+ nItems += 1;
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+#ifdef ISNAN
+ ss << " {\n";
+ isMixed = svDoubleDouble;
+#endif
+ nItems += 1;
+ }
+ else
+ {
+#ifdef ISNAN
+#endif
+ nItems += 1;
+ }
+
+#ifdef ISNAN
+ if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+ {
+ if(isMixed == svDoubleVectorRefDoubleString
+ || isMixed == svSingleVectorRefDoubleString)
+ {
+ ss << " if (!isNan(";
+ ss << vSubArguments[i]->GenDoubleSlidingWindowDeclRef();
+ ss << ")){\n";
+ ss << " nCount+=1.0;\n";
+ ss << " }\n";
+ ss << " else if(isNan(";
+ ss << vSubArguments[i]->GenDoubleSlidingWindowDeclRef();
+ ss << ") && ";
+ ss<< vSubArguments[i]->GenStringSlidingWindowDeclRef();
+ ss << " != 0)\n";
+ ss << " nCount+=1.0;\n";
+ ss << " }\n";
+ }
+ else if(isMixed == svDoubleVectorRefDouble
+ || isMixed == svSingleVectorRefDouble)
+ {
+ ss << " if (!isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ")){\n";
+ ss << " nCount+=1.0;\n";
+ ss <<"}\n }\n";
+ }
+ else if(isMixed == svDoubleVectorRefString)
+ {
+ ss << " if (!isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " nCount+=1.0;\n";
+ ss <<"\n }\n";
+ }
+ else if(isMixed == svSingleVectorRefString)
+ {
+ ss << " if(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << " != 0)\n";
+ ss << " nCount+=1.0;\n";
+ ss << " }\n";
+ }
+ else if(isMixed == svDoubleDouble)
+ {
+ ss << " nCount+=1.0;\n";
+ ss << " }\n";
+ }
+ else
+ {
+ ss << " }\n";
+ }
+ }
+ else
+ {
+ ss << " nCount+=1.0;\n";
+ ss << " }\n";
+ }
+#else
+ ss << " nCount+=1.0;\n";
+ ss << " }\n";
+#endif
+ }
+ ss << " return nCount;\n";
+ ss << "}\n";
+}
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 362c1a4b3c48..2478f295fe22 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -469,6 +469,15 @@ public:
virtual bool takeString() const { return true; }
virtual bool takeNumeric() const { return true; }
};
+class OpCountA: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "OpCountA"; }
+ virtual bool takeString() const { return true; }
+ virtual bool takeNumeric() const { return true; }
+};
}}
#endif