summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryiming ju <yiming@multicorewareinc.com>2013-12-20 13:28:22 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-12-23 16:51:31 -0600
commitbc7c98cf20c1b39edf6d832e3fb09e550df2e485 (patch)
tree90f72ed3923ab71daa28056077486883a061a9cb
parent7eafa6f237005310da6ade542373e1e77e492c1f (diff)
GPU Calc: Fix Bug of TBILLYIELD&TBILLEQ
AMLOEXT-376 Change-Id: I067819191f5926cef31ab50f1ad46d64a1e58a5c Signed-off-by: haochen <haochen@multicorewareinc.com> Signed-off-by: Wei Wei <weiwei@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
-rw-r--r--sc/source/core/opencl/op_financial.cxx24
-rw-r--r--sc/source/core/opencl/opinlinefun_finacial.cxx46
2 files changed, 58 insertions, 12 deletions
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 13c3e11ee8ac..49a383d49f7e 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -1685,11 +1685,11 @@ void OpEffective::GenSlidingWindowFunction(std::stringstream& ss,
std::set<std::string>& funs)
{
decls.insert(GetDiffDate360_Decl);decls.insert(GetDiffDate360Decl);
- decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl);
+ decls.insert(DateToDaysDecl);decls.insert(DaysToDate_LocalBarrierDecl);
decls.insert(DaysInMonthDecl);decls.insert(GetNullDateDecl);
decls.insert(IsLeapYearDecl);
funs.insert(GetDiffDate360_);funs.insert(GetDiffDate360);
- funs.insert(DateToDays);funs.insert(DaysToDate);
+ funs.insert(DateToDays);funs.insert(DaysToDate_LocalBarrier);
funs.insert(DaysInMonth);funs.insert(GetNullDate);
funs.insert(IsLeapYear);
}
@@ -4845,11 +4845,11 @@ void RATE::GenSlidingWindowFunction(
std::set<std::string>& funs)
{
decls.insert(GetDiffDate360Decl);decls.insert(IsLeapYearDecl);
- decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl);
+ decls.insert(DateToDaysDecl);decls.insert(DaysToDate_LocalBarrierDecl);
decls.insert(DaysInMonthDecl);decls.insert(GetNullDateDecl);
decls.insert(GetDiffDate360_Decl);
funs.insert(GetDiffDate360);funs.insert(DateToDays);
- funs.insert(DaysToDate);funs.insert(IsLeapYear);
+ funs.insert(DaysToDate_LocalBarrier);funs.insert(IsLeapYear);
funs.insert(DaysInMonth);funs.insert(GetNullDate);
funs.insert(GetDiffDate360_);
@@ -4930,14 +4930,14 @@ void OpTbillyield::GenSlidingWindowFunction(
ss<<"tmp002 = ";
ss << vSubArguments[2]->GenSlidingWindowDeclRef();
ss<<";\n\t";
- ss <<"int nDiff=GetDiffDate360(GetNullDate(),tmp000,tmp001,true);\n";
- ss <<"nDiff++;\n";
- ss <<"tmp=100.0;\n";
- ss <<"tmp /= tmp002;\n";
- ss <<"tmp-=1.0;\n";
- ss <<"tmp= tmp/( nDiff );\n";
- ss <<"tmp *= 360.0;\n";
- ss <<"return tmp;\n";
+ ss <<" int nDiff=GetDiffDate360(GetNullDate(),tmp000,tmp001,true);\n";
+ ss <<" nDiff++;\n";
+ ss <<" tmp=100.0;\n";
+ ss <<" tmp = tmp *pow( tmp002,-1);\n";
+ ss <<" tmp = tmp - 1.0;\n";
+ ss <<" tmp = tmp * pow( nDiff,-1.0 );\n";
+ ss <<" tmp = tmp * 360.0;\n";
+ ss <<" return tmp;\n";
ss << "}\n";
}
void OpDDB::GenSlidingWindowFunction(std::stringstream& ss,
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index 2b81df230ee2..1cb2697ccce8 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -1654,6 +1654,52 @@ std::string DaysToDate_new =
" }\n"
"}\n";
+std::string DaysToDate_LocalBarrierDecl =
+"void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear );\n";
+
+std::string DaysToDate_LocalBarrier =
+"void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear )\n"
+"{\n"
+" int nTempDays;\n"
+" int i = 0;\n"
+" bool bCalc;\n"
+" do\n"
+" {\n"
+" nTempDays = nDays;\n"
+" *rYear = (int)((nTempDays / 365) - i);\n"
+" nTempDays -= ((int) *rYear -1) * 365;\n"
+" nTempDays -= ((*rYear -1) / 4) - ((*rYear -1) / 100) + ((*rYear -1)"
+" / 400);\n"
+" bCalc = false;\n"
+" if ( nTempDays < 1 )\n"
+" {\n"
+" i++;\n"
+" bCalc = true;\n"
+" }\n"
+" else\n"
+" {\n"
+" if ( nTempDays > 365 )\n"
+" {\n"
+" if ( (nTempDays != 366) || !IsLeapYear( *rYear ) )\n"
+" {\n"
+" i--;\n"
+" bCalc = true;\n"
+" }\n"
+" }\n"
+" }\n"
+" }\n"
+" while ( bCalc );\n"
+" barrier(CLK_LOCAL_MEM_FENCE);\n"
+" if(nTempDays != 0){\n"
+" for (*rMonth = 1; (int)nTempDays > DaysInMonth( *rMonth, *rYear );"
+" *rMonth += 1)\n"
+" {\n"
+" nTempDays -= DaysInMonth( *rMonth, *rYear ); \n"
+" }\n"
+" *rDay = (int)nTempDays;\n"
+" }\n"
+"}\n";
+
std::string GetYearDiff_newDecl=
"double GetYearDiff_new( int nNullDate, int nStartDate, int nEndDate,"
"int nMode);\n";