summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorminwang <min@multicorewareinc.com>2013-11-05 10:47:06 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-12 22:38:25 -0600
commit48caa626012312e2ec13df5008c041b29acab44c (patch)
tree41fb03e50d800e9771bf3fd18c05a0e7a0a1610f
parentGPU Calc: unit test cases for AMORLINC in GPU calc (diff)
downloadcore-48caa626012312e2ec13df5008c041b29acab44c.tar.gz
core-48caa626012312e2ec13df5008c041b29acab44c.zip
GPU Calc: implement fix for DDB
AMLOEXT-124 FIX Change-Id: Id43ae2ec0aba83ab136787bdb6f2862bc77f6366 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_financial.cxx112
-rw-r--r--sc/source/core/opencl/op_financial.hxx9
3 files changed, 124 insertions, 1 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 55d2f250a96b..069321fafafa 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1056,6 +1056,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpMedian));
break;
+ case ocGDA:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpDDB));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 92a7f14c3bf7..b449a9df8e36 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3770,7 +3770,117 @@ void OpTbillyield::GenSlidingWindowFunction(
ss <<"return tmp;\n";
ss << "}\n";
}
-
+void OpDDB::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 tmp = 0;\n";
+ ss << " double fWert,fRest,fDauer,fPeriode,fFaktor;\n";
+ ss << " double fGda, fZins, fAlterWert, fNeuerWert;\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);
+ FormulaToken* tmpCur3 = vSubArguments[3]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur3);
+ FormulaToken* tmpCur4 = vSubArguments[4]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR4= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur4);
+ ss<< " int buffer_wert_len = ";
+ ss<< tmpCurDVR0->GetArrayLength();
+ ss << ";\n";
+ ss<< " int buffer_rest_len = ";
+ ss<< tmpCurDVR1->GetArrayLength();
+ ss << ";\n";
+ ss<< " int buffer_dauer_len = ";
+ ss<< tmpCurDVR2->GetArrayLength();
+ ss << ";\n";
+ ss<< " int buffer_periode_len = ";
+ ss<< tmpCurDVR3->GetArrayLength();
+ ss << ";\n";
+ ss<< " int buffer_factor_len = ";
+ ss<< tmpCurDVR4->GetArrayLength();
+ ss << ";\n";
+#endif
+#ifdef ISNAN
+ ss <<" if(gid0 >= buffer_wert_len || isNan(";
+ ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" fWert = 0;\n else\n";
+#endif
+ ss <<" fWert = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+#ifdef ISNAN
+ ss <<" if(gid0 >= buffer_rest_len || isNan(";
+ ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" fRest = 0;\n else\n";
+#endif
+ ss <<" fRest = ";
+ ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+#ifdef ISNAN
+ ss <<" if(gid0 >= buffer_dauer_len || isNan(";
+ ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" fDauer = 0;\n else\n";
+#endif
+ ss <<" fDauer = "<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+#ifdef ISNAN
+ ss <<" if(gid0 >= buffer_periode_len || isNan(";
+ ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" fPeriode = 0;\n else\n";
+#endif
+ ss <<" fPeriode = "<<vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+#ifdef ISNAN
+ ss <<" if(gid0 >= buffer_factor_len || isNan(";
+ ss <<vSubArguments[4]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" fFaktor = 0;\n else\n";
+#endif
+ ss <<" fFaktor = "<<vSubArguments[4]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+ ss <<" fZins = fFaktor / fDauer;\n";
+ ss <<" if (fZins >= 1.0)\n";
+ ss <<" {\n";
+ ss <<" fZins = 1.0;\n";
+ ss <<" if (fPeriode == 1.0)\n";
+ ss <<" fAlterWert = fWert;\n";
+ ss <<" else\n";
+ ss <<" fAlterWert = 0.0;\n";
+ ss <<" }\n";
+ ss <<" else\n";
+ ss <<" fAlterWert = fWert * pow(1.0 - fZins, fPeriode - 1.0);\n";
+ ss <<" fNeuerWert = fWert * pow(1.0 - fZins, fPeriode);\n";
+ ss <<" if (fNeuerWert < fRest)\n";
+ ss <<" fGda = fAlterWert - fRest;\n";
+ ss <<" else\n";
+ ss <<" fGda = fAlterWert - fNeuerWert;\n";
+ ss <<" if (fGda < 0.0)\n";
+ ss <<" fGda = 0.0;\n";
+ ss <<" tmp = fGda;\n";
+ ss <<" return tmp;\n";
+ ss <<"}";
+}
void OpPV::GenSlidingWindowFunction(
std::stringstream &ss, const std::string sSymName, SubArguments &
vSubArguments)
diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx
index fbf5bee6d250..de1ffc72dd5a 100644
--- a/sc/source/core/opencl/op_financial.hxx
+++ b/sc/source/core/opencl/op_financial.hxx
@@ -339,6 +339,15 @@ public:
virtual std::string BinFuncName(void) const { return "Coupnum"; }
};
+class OpDDB:public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+
+ virtual std::string BinFuncName(void) const { return "DDB"; }
+};
+
class OpAmordegrc:public Normal
{
public: