summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormingli <mingli@multicorewareinc.com>2013-11-09 11:25:07 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-14 14:09:47 -0600
commitc07c6bde40da1c7817b7bfcb1e888e8b561a184c (patch)
treef69e8339b9f619a54dbeff049381259eee6d1375
parentGPU Calc: unit test cases for FINV (diff)
downloadcore-c07c6bde40da1c7817b7bfcb1e888e8b561a184c.tar.gz
core-c07c6bde40da1c7817b7bfcb1e888e8b561a184c.zip
GPU Calc: implemented FTEST
AMLOEXT-160 FIX Change-Id: Id97578b33b14a3d2ade021a8bb311c59fe99722f 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.cxx107
-rw-r--r--sc/source/core/opencl/op_statistical.hxx9
3 files changed, 120 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 00b9124db047..6fd4f22fff8e 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1245,6 +1245,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpFInv));
break;
+ case ocFTest:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpFTest));
+ 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 3d8aa2e600bf..e0af4c64c5c7 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3466,6 +3466,113 @@ void OpFInv::GenSlidingWindowFunction(std::stringstream &ss,
" return tmp;"
"}";
}
+void OpFTest::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fMachEpsDecl);decls.insert(fMaxGammaArgumentDecl);
+ decls.insert(lcl_getLanczosSumDecl);decls.insert(GetBetaDecl);
+ decls.insert(GetLogBetaDecl);decls.insert(GetBetaDistPDFDecl);
+ decls.insert(lcl_GetBetaHelperContFracDecl);decls.insert(GetBetaDistDecl);
+ decls.insert(GetFDistDecl);
+ funs.insert(lcl_getLanczosSum);funs.insert(GetBeta);
+ funs.insert(GetLogBeta);funs.insert(GetBetaDistPDF);
+ funs.insert(lcl_GetBetaHelperContFrac);funs.insert(GetBetaDist);
+ funs.insert(GetFDist);
+}
+void OpFTest::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();
+ FormulaToken *pCur1 = vSubArguments[1]->GetFormulaToken();
+ assert(pCur1);
+ const formula::DoubleVectorRefToken* pCurDVR1 =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur1);
+ size_t nCurWindowSize1 = pCurDVR1->GetRefRowSize();
+ 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 fSum1 = 0.0;\n";
+ ss << " double fSumSqr1 = 0.0;\n";
+ ss << " double fSum2 = 0.0;\n";
+ ss << " double fSumSqr2 = 0.0;\n";
+ ss << " int length0="<<nCurWindowSize;
+ ss << ";\n";
+ ss << " int length1= "<<nCurWindowSize1;
+ ss << ";\n";
+ ss << " double tmp = 0;\n";
+ for (unsigned 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);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+ ss << " double arg"<<i<<" = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(isNan(arg"<<i<<")||((gid0+i)>=";
+ ss << pDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " {\n";
+ ss << " length"<<i<<"--;\n";
+ ss << " continue;\n";
+ ss << " }\n";
+#endif
+ ss << " fSum"<<i+1<<" += arg"<<i<<";\n";
+ ss << " fSumSqr"<<i+1<<" += arg"<<i;
+ ss << " * arg"<<i<<";\n";
+ ss << " }\n";
+#endif
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+#ifdef ISNAN
+ ss << "return HUGE_VAL";
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+#ifdef ISNAN
+ ss << "return HUGE_VAL";
+#endif
+ }
+ }
+ ss << " double fS1 = (fSumSqr1-fSum1*fSum1/length0)/(length0-1.0);\n"
+ " double fS2 = (fSumSqr2-fSum2*fSum2/length1)/(length1-1.0);\n"
+ " double fF, fF1, fF2;\n"
+ " if (fS1 > fS2)\n"
+ " {\n"
+ " fF = fS1/fS2;\n"
+ " fF1 = length0-1.0;\n"
+ " fF2 = length1-1.0;\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " fF = fS2/fS1;\n"
+ " fF1 = length1-1.0;\n"
+ " fF2 = length0-1.0;\n"
+ " }\n"
+ " tmp = 2.0*GetFDist(fF, fF1, fF2);\n";
+ ss << " return tmp;\n";
+ ss << "}";
+}
}}
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index ca8e343fbfbb..63c6a7989fcf 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -288,6 +288,15 @@ public:
);
virtual std::string BinFuncName(void) const { return "FInv"; }
};
+class OpFTest: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ void BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs
+);
+ virtual std::string BinFuncName(void) const { return "FTest"; }
+};
}}