summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminwang <min@multicorewareinc.com>2013-11-07 16:17:18 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-14 14:09:41 -0600
commit8f278eabf05e6911989ea6bacfe5b785123b3ac4 (patch)
treef0c77e2bad3c55fecfe5921a2457625eafa6dc66
parentbc135e35aa0c28f2365770f6d027df73cb07f67b (diff)
GPU Calc: implemented FDIST
AMLOEXT-141 FIX Change-Id: Ic3684661d100bc1c6e0323fb08f1237c9bc816e1 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.cxx84
-rw-r--r--sc/source/core/opencl/op_statistical.hxx8
3 files changed, 96 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index ddd7ca8bdc04..8337e58fe5c8 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1208,6 +1208,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpCoth));
break;
+ case ocFDist:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpFdist));
+ 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 8e39c363b5f7..3ab6ea93f65b 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -22,6 +22,90 @@
using namespace formula;
namespace sc { namespace opencl {
+void OpFdist::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(GetFDistDecl);decls.insert(GetBetaDistDecl);
+ decls.insert(GetBetaDecl);decls.insert(fMaxGammaArgumentDecl);
+ decls.insert(lcl_GetBetaHelperContFracDecl);
+ decls.insert(GetBetaDistPDFDecl);
+ decls.insert(GetLogBetaDecl);decls.insert(lcl_getLanczosSumDecl);
+ decls.insert(fMachEpsDecl);
+ funs.insert(GetFDist);funs.insert(GetBetaDist);
+ funs.insert(GetBeta);
+ funs.insert(lcl_GetBetaHelperContFrac);funs.insert(GetBetaDistPDF);
+ funs.insert(GetLogBeta);
+ funs.insert(lcl_getLanczosSum);
+}
+void OpFdist::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 << " double tmp = 0;\n";
+ ss << " int gid0 = get_global_id(0);\n";
+ ss << " double rF1,rF2,rX;\n";
+#ifdef ISNAN
+ FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss<< " int buffer_x_len = ";
+ ss<< tmpCurDVR0->GetArrayLength();
+ ss<< ";\n";
+ ss<< " int buffer_fF1_len = ";
+ ss<< tmpCurDVR1->GetArrayLength();
+ ss<< ";\n";
+ ss<< " int buffer_fF2_len = ";
+ ss<< tmpCurDVR2->GetArrayLength();
+ ss<< ";\n";
+#endif
+#ifdef ISNAN
+ ss <<" if(gid0 >= buffer_x_len || isNan(";
+ ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" rX = 0;\n else\n";
+#endif
+ ss <<" rX = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+#ifdef ISNAN
+ ss <<" if(gid0 >= buffer_fF1_len || isNan(";
+ ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" rF1 = 0;\n else\n";
+#endif
+ ss <<" rF1 = floor(";
+ ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<");\n";
+#ifdef ISNAN
+ ss <<" if(gid0 >= buffer_fF2_len || isNan(";
+ ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" rF2 = 0;\n else\n";
+#endif
+ ss <<" rF2 = floor("<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<");\n";
+ ss <<" if (rX < 0.0 || rF1 < 1.0 || rF2 < 1.0 || rF1 >= 1.0E10 ||";
+ ss <<"rF2 >= 1.0E10)\n";
+ ss <<" {\n";
+ ss <<" tmp = -DBL_MAX;\n";
+ ss <<" }\n";
+ ss <<" tmp = GetFDist(rX, rF1, rF2);\n";
+ ss <<" return tmp;\n";
+ ss <<"}";
+}
void OpStandard::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 7d8fa5ebb931..cbd276a62ed8 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -29,6 +29,14 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Weibull"; }
};
+class OpFdist: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
+ virtual std::string BinFuncName(void) const { return "Fdist"; }
+};
class OpFisher: public Normal
{