summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminwang <min@multicorewareinc.com>2013-11-09 13:30:15 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-14 14:09:50 -0600
commitdb9432fbcf497e4961184ade7ca81784f1501dff (patch)
treeb1db39ab823c3fa592173c0ddf261cb9e6f846a0
parentb825d6fd83e6eadd732b930c0aae01f9c50abed8 (diff)
GPU Calc: implemented EXPONDIST
AMLOEXT-151 FIX Change-Id: I0a9e743071ad767714c6664e48f2b37d6475d27e 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.cxx10
-rw-r--r--sc/source/core/opencl/op_statistical.cxx86
-rw-r--r--sc/source/core/opencl/op_statistical.hxx7
3 files changed, 101 insertions, 2 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 13f90500f567..f1eee2a2b2b6 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1262,10 +1262,16 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
ft->Children[i], new OpCscH));
break;
case ocExp:
- mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpExp));
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpExp));
break;
case ocLog10:
- mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpLog10));
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpLog10));
+ break;
+ case ocExpDist:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpExponDist));
break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index e30b4d943a5c..ec948c91d694 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -254,6 +254,92 @@ void OpVar::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return vSum / (fCount - 1.0);\n";
ss << "}\n";
}
+void OpExponDist::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 rx,rlambda,rkum;\n";
+#ifdef ISNAN
+ FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
+#endif
+ ss <<" rx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+ ss <<" rlambda = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+ ss <<" rkum = "<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+#ifdef ISNAN
+ if(tmpCur0->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ ss<< " int buffer_x_len = "<<tmpCurDVR0->GetArrayLength();
+ ss<< ";\n";
+ ss <<" if(gid0 >= buffer_x_len || isNan(";
+ ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" rx = 0;\n";
+ }
+#endif
+#ifdef ISNAN
+ if(tmpCur1->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ ss<< " int buffer_lambda_len = "<< tmpCurDVR1->GetArrayLength();
+ ss<< ";\n";
+ ss <<" if(gid0 >= buffer_lambda_len || isNan(";
+ ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" rlambda = 0;\n";
+ }
+#endif
+#ifdef ISNAN
+ if(tmpCur2->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss<< " int buffer_kum_len = "<< tmpCurDVR2->GetArrayLength();
+ ss<< ";\n";
+ ss <<" if(gid0 >= buffer_kum_len || isNan(";
+ ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" rkum = 0;\n";
+ }
+#endif
+ ss <<" if(rlambda <= 0.0)\n";
+ ss <<" {\n";
+ ss <<" tmp = -DBL_MAX;\n";
+ ss <<" }\n";
+ ss <<" else if(rkum == 0)\n";
+ ss <<" {\n";
+ ss <<" if(rx >= 0)\n";
+ ss <<" tmp = rlambda*exp(-rlambda*rx);\n";
+ ss <<" else\n";
+ ss <<" tmp = 0.0;\n";
+ ss <<" }\n";
+ ss <<" else\n";
+ ss <<" {\n";
+ ss <<" if(rx > 0)\n";
+ ss <<" tmp = 1.0 - exp(-rlambda*rx);\n";
+ ss <<" else\n";
+ ss <<" tmp = 0.0;\n";
+ ss <<" }\n";
+ ss <<" return tmp;\n";
+ ss <<"}";
+}
void OpFdist::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 743a4ece5562..9566d30b4de4 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -21,6 +21,13 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Standard"; }
};
+class OpExponDist: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "ExponDist"; }
+};
class OpVar: public Normal
{
public: