summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorshiming zhang <shiming@multicorewareinc.com>2013-11-16 18:54:42 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-16 23:20:13 -0600
commita81e6fb33b3dca4cc50155a3d6fa7db3207e4579 (patch)
tree1c214d7cb887adc0dfa50bb93c6acc910022747a /sc/source
parent48e2405de783b61882b0a103df80c5f6b3be6dd9 (diff)
GPU Calc: implemented TDIST
AMLOEXT-190 FIX Change-Id: I9745d4e2b3b25640abfa5ee8165d1335fb52c6b6 Signed-off-by: haochen <haochen@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx4
-rw-r--r--sc/source/core/opencl/op_statistical.cxx152
-rw-r--r--sc/source/core/opencl/op_statistical.hxx8
3 files changed, 164 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index df156748e6e9..42a3408634a1 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1770,6 +1770,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpTTest));
break;
+ case ocTDist:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpTDist));
+ 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 89679911beef..a26af8b55d50 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1217,7 +1217,159 @@ void OpVarP::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return vSum / fCount;\n";
ss << "}\n";
}
+void OpTDist::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fMachEpsDecl);
+ funs.insert("");
+ decls.insert(fMaxGammaArgumentDecl);
+ funs.insert("");
+ decls.insert(lcl_getLanczosSumDecl);
+ funs.insert(lcl_getLanczosSum);
+ decls.insert(GetBetaDecl);
+ funs.insert(GetBeta);
+ decls.insert(GetLogBetaDecl);
+ funs.insert(GetLogBeta);
+ decls.insert(GetBetaDistPDFDecl);
+ funs.insert(GetBetaDistPDF);
+ decls.insert(lcl_GetBetaHelperContFracDecl);
+ funs.insert(lcl_GetBetaHelperContFrac);
+ decls.insert(GetBetaDistDecl);
+ funs.insert(GetBetaDist);
+ decls.insert(GetTDistDecl);
+ funs.insert(GetTDist);
+}
+void OpTDist::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 x,fDF,fFlag;\n";
+ if(vSubArguments.size() != 3)
+ {
+ ss << " return DBL_MAX;\n" << "}\n";
+ return ;
+ }
+ FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ assert(tmpCur0);
+ if(ocPush==vSubArguments[0]->GetFormulaToken()->GetOpCode())
+ {
+ if(tmpCur0->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR0 =
+ dynamic_cast<const formula::SingleVectorRefToken *>(tmpCur0);
+#ifdef ISNAN
+ ss << " int buffer_x_len = ";
+ ss << tmpCurDVR0->GetArrayLength() << ";\n";
+ ss << " if(gid0 >= buffer_x_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " x = 0.0;\n";
+ ss << " else\n";
+#endif
+ ss << " x = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ }
+ else if(tmpCur0->GetType() == formula::svDouble)
+ {
+ ss << " x = " << tmpCur0->GetDouble() << ";\n";
+ }
+ else
+ {
+ ss << " return DBL_MAX;\n" << "}\n";
+ return ;
+ }
+ }
+ else
+ {
+ ss << " x = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ }
+ FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ assert(tmpCur1);
+ if(ocPush==vSubArguments[1]->GetFormulaToken()->GetOpCode())
+ {
+ if(tmpCur1->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR1 =
+ dynamic_cast<const formula::SingleVectorRefToken *>(tmpCur1);
+#ifdef ISNAN
+ ss << " int buffer_fDF_len = ";
+ ss << tmpCurDVR1->GetArrayLength() << ";\n";
+ ss << " if(gid0 >= buffer_fDF_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " fDF = 0.0;\n";
+ ss << " else\n";
+#endif
+ ss << " fDF = floor(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ");\n";
+ }
+ else if(tmpCur1->GetType() == formula::svDouble)
+ {
+ ss << " fDF = floor(" << tmpCur1->GetDouble() << ");\n";
+ }
+ else
+ {
+ ss << " return DBL_MAX;\n" << "}\n";
+ return ;
+ }
+ }
+ else
+ {
+ ss << " fDF = floor(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ");\n";
+ }
+ FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
+ assert(tmpCur2);
+ if(ocPush==vSubArguments[2]->GetFormulaToken()->GetOpCode())
+ {
+ if(tmpCur2->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR2 =
+ dynamic_cast<const formula::SingleVectorRefToken *>(tmpCur2);
+#ifdef ISNAN
+ ss << " int buffer_fFlag_len = ";
+ ss << tmpCurDVR2->GetArrayLength() << ";\n";
+ ss << " if(gid0>=buffer_fFlag_len || isNan(";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " fFlag = 0.0;\n";
+ ss << " else\n";
+#endif
+ ss << " fFlag = floor(";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef() << ");\n";
+ }
+ else if(tmpCur2->GetType() == formula::svDouble)
+ {
+ ss << " fFlag = floor(" << tmpCur2->GetDouble() << ");\n";
+ }
+ else
+ {
+ ss << " return DBL_MAX;\n" << "}\n";
+ return ;
+ }
+ }
+ else
+ {
+ ss << " fFlag = floor(";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef() << ");\n";
+ }
+ ss << " if(fDF < 1.0 || x < 0.0 || (fFlag != 1.0 && fFlag != 2.0))\n";
+ ss << " return DBL_MAX;\n";
+ ss << " double R = GetTDist(x, fDF);\n";
+ ss << " if (fFlag == 1.0)\n";
+ ss << " return R;\n";
+ ss << " else\n";
+ ss << " return 2.0 * R;\n";
+ ss << "}\n";
+}
void OpExponDist::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 6b31ccc78f43..7f6b017d6d7d 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -92,6 +92,14 @@ public:
virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
virtual std::string BinFuncName(void) const { return "Fdist"; }
};
+class OpTDist: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "TDist"; }
+ virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
+};
class OpTTest: public Normal
{
public: