summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhaochen <haochen@multicorewareinc.com>2013-10-24 15:35:37 +0800
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-29 17:00:11 -0400
commit189f2bda097be7a50d5c2d97bfd35c5deaae4e94 (patch)
tree40868e6912b882fb71851a9684a77cf0fef287bf
parent572280bd7c94d286310b4471c44dea9ddd723026 (diff)
Implement COUPDAYBS in GPU Calc
Change-Id: I3a0944009e6e8a0d7e19c437be1af2f2febcc2c2 Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
-rw-r--r--sc/source/core/opencl/OP_finacial.cxx90
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx6
2 files changed, 96 insertions, 0 deletions
diff --git a/sc/source/core/opencl/OP_finacial.cxx b/sc/source/core/opencl/OP_finacial.cxx
index 4cbbed966057..8d4765e1bf48 100644
--- a/sc/source/core/opencl/OP_finacial.cxx
+++ b/sc/source/core/opencl/OP_finacial.cxx
@@ -952,6 +952,96 @@ public:
virtual std::string BinFuncName(void) const { return "PPMT"; }
};
+class OpCoupdaybs:public Normal
+{
+public:
+ virtual std::string GetBottom(void) { return "0";}
+ 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 = " << GetBottom() <<";\n\t";
+ ss << "int gid0 = get_global_id(0);\n\t";
+ ss << "int nSettle,nMat,nFreq,nBase;\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);
+ FormulaToken *tmpCur3 = vSubArguments[3]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur3);
+ ss<< "int buffer_nSettle_len = ";
+ ss<< tmpCurDVR0->GetArrayLength();
+ ss << ";\n\t";
+ ss<< "int buffer_nMat_len = ";
+ ss<< tmpCurDVR1->GetArrayLength();
+ ss << ";\n\t";
+ ss<< "int buffer_nFreq_len = ";
+ ss<< tmpCurDVR2->GetArrayLength();
+ ss << ";\n\t";
+ ss<< "int buffer_nBase_len = ";
+ ss<< tmpCurDVR3->GetArrayLength();
+ ss << ";\n\t";
+#endif
+#ifdef ISNAN
+ ss <<"if(gid0 >= buffer_nSettle_len || isNan(";
+ ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<"))\n\t\t";
+ ss <<"nSettle = 0;\n\telse\n\t\t";
+#endif
+ ss << "nSettle=(int)";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<";\n\t";
+#ifdef ISNAN
+ ss <<"if(gid0 >= buffer_nMat_len || isNan(";
+ ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<"))\n\t\t";
+ ss <<"nMat = 0;\n\telse\n\t\t";
+#endif
+ ss << "nMat=(int)";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ";\n\t";
+#ifdef ISNAN
+ ss <<"if(gid0 >= buffer_nFreq_len || isNan(";
+ ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<"))\n\t\t";
+ ss <<"nFreq = 0;\n\telse\n\t\t";
+#endif
+ ss << "nFreq=(int)";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<";\n\t";
+#ifdef ISNAN
+ ss <<"if(gid0 >= buffer_nBase_len || isNan(";
+ ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss <<"))\n\t\t";
+ ss <<"nBase = 0;\n\telse\n\t\t";
+#endif
+ ss << "nBase=(int)";
+ ss << vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss << ";\n\t";
+ ss <<"int nNullDate=GetNullDate();\n\t";
+ ss <<"tmp = lcl_Getcoupdaybs(nNullDate,";
+ ss <<"nSettle, nMat,nFreq,nBase);\n\t";
+ ss << "return tmp;\n";
+ ss << "}";
+ }
+virtual std::string BinFuncName(void) const { return "Coupdaybs";}
+
+};
class OpReceived:public Normal
{
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index f3df5bcae77c..a41641972a92 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -666,6 +666,12 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
mvSubArguments.push_back(SoPHelper<OpAccrintm>(ts,
ft->Children[i]));
}
+ else if ( !(pChild->GetExternal().compareTo(OUString(
+ "com.sun.star.sheet.addin.Analysis.getCoupdaybs"))))
+ {
+ mvSubArguments.push_back(SoPHelper<OpCoupdaybs>(ts,
+ ft->Children[i]));
+ }
break;
default:
assert(0 && "Unsupported");