summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhaochen <haochen@multicorewareinc.com>2013-10-24 13:25:12 +0800
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-29 17:00:08 -0400
commit56e742e9ffdf6e37be972bf90b8a307496860a7c (patch)
treec5427738a1efc25652437953ad3e2d0c0e903590
parente7de7bda4c243538ba0b6915150906d4f7e1600a (diff)
Implement SLN in GPU Calc
Change-Id: I42bb0f790739e05be78536fba9c7875bd8cad290 Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
-rw-r--r--sc/source/core/opencl/OP_finacial.cxx76
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx4
2 files changed, 80 insertions, 0 deletions
diff --git a/sc/source/core/opencl/OP_finacial.cxx b/sc/source/core/opencl/OP_finacial.cxx
index fda658b87a40..18efa4fd2eba 100644
--- a/sc/source/core/opencl/OP_finacial.cxx
+++ b/sc/source/core/opencl/OP_finacial.cxx
@@ -589,6 +589,82 @@ public:
}
virtual std::string BinFuncName(void) const { return "Yield"; }
};
+
+class OpSLN: public Normal{
+public:
+ virtual void 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\t";
+ ss << "double tmp = " <<"0"<<";\n\t";
+ ss << "int gid0 = get_global_id(0);\n\t";
+ ss << "double wert;\n\t";
+ ss << "double rest;\n\t";
+ ss << "double dauer;\n\t";
+
+#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_wert_len = ";
+ ss<< tmpCurDVR0->GetArrayLength();
+ ss << ";\n\t";
+ ss<< "int buffer_rest_len = ";
+ ss<< tmpCurDVR1->GetArrayLength();
+ ss << ";\n\t";
+ ss<< "int buffer_dauer_len = ";
+ ss<< tmpCurDVR2->GetArrayLength();
+ ss << ";\n\t";
+#endif
+#ifdef ISNAN
+ ss<<"if(gid0>=buffer_wert_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss<<"))\n\t\t";
+ ss<<"wert = 0;\n\telse \n\t\t";
+#endif
+ ss<<"wert = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss<<";\n\t";
+#ifdef ISNAN
+ ss<<"if(gid0>=buffer_rest_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss<<"))\n\t\t";
+ ss<<"rest = 0;\n\telse \n\t\t";
+#endif
+ ss<<"rest = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss<<";\n\t";
+#ifdef ISNAN
+ ss<<"if(gid0>=buffer_dauer_len || isNan(";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss<<"))\n\t\t";
+ ss<<"dauer = 0;\n\telse \n\t\t";
+#endif
+ ss<<"dauer = ";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss<<";\n\t";
+ ss << "tmp = (wert-rest)/dauer;\n\t";
+ ss << "return tmp;\n";
+ ss << "}";
+ }
+ virtual std::string BinFuncName(void) const { return "SLN"; }
+};
+
class OpFvschedule: public Fvschedule{
public:
virtual std::string GetBottom(void) { return "0"; }
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 486f83e7edb3..dc7131c35e8f 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -554,6 +554,10 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
mvSubArguments.push_back(SoPHelper<OpGamma>(ts,
ft->Children[i]));
break;
+ case ocLIA:
+ mvSubArguments.push_back(SoPHelper<OpSLN>(ts,
+ ft->Children[i]));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))