[Libreoffice-commits] core.git: 14 commits - sc/qa sc/source
minwang
min at multicorewareinc.com
Mon Dec 30 13:05:45 PST 2013
sc/qa/unit/data/xls/opencl/math/NegSub.xls |binary
sc/qa/unit/data/xls/opencl/statistical/Avedev.xls |binary
sc/qa/unit/opencl-test.cxx | 55 +
sc/source/core/opencl/formulagroupcl.cxx | 36
sc/source/core/opencl/op_financial.cxx | 878 ++++++++++------------
sc/source/core/opencl/op_math.cxx | 248 ++++--
sc/source/core/opencl/op_math.hxx | 8
sc/source/core/opencl/op_statistical.cxx | 123 +++
sc/source/core/opencl/op_statistical.hxx | 8
sc/source/core/opencl/opinlinefun_finacial.cxx | 267 ++++--
sc/source/core/tool/token.cxx | 2
11 files changed, 1027 insertions(+), 598 deletions(-)
New commits:
commit 2e5abd41b86e970885e03795bc874cfc31ea54a9
Author: minwang <min at multicorewareinc.com>
Date: Tue Dec 24 14:44:39 2013 +0800
GPU Calc: Optimized COUPPCD
AMLOEXT-382
Change-Id: I49ed9bdd88a0f00da4475798362750d5a0253c09
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 62fedd3..5931ab5 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3622,11 +3622,17 @@ void OpCouppcd::BinInlineFun(std::set<std::string>& decls,
{
decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
- decls.insert(GetNullDateDecl); decls.insert(ScaDate2Decl);
+ decls.insert(GetNullDateDecl);
+ decls.insert(ScaDateDecl);
+ decls.insert(addMonthsDecl);
+ decls.insert(setDayDecl);decls.insert(checklessthanDecl);
decls.insert(lcl_GetCouppcdDecl);
funs.insert(IsLeapYear);funs.insert(DaysInMonth);
funs.insert(DaysToDate);funs.insert(DateToDays);
- funs.insert(GetNullDate);funs.insert(ScaDate2);
+ funs.insert(GetNullDate);
+ funs.insert(ScaDate);
+ funs.insert(addMonths);
+ funs.insert(setDay);funs.insert(checklessthan);
funs.insert(lcl_GetCouppcd);
}
void OpCouppcd::GenSlidingWindowFunction(
@@ -3637,82 +3643,74 @@ void OpCouppcd::GenSlidingWindowFunction(
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
- if (i)
- ss << ",";
- vSubArguments[i]->GenSlidingWindowDecl(ss);
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
}
ss << ") {\n";
ss << " double tmp = 0;\n";
ss << " int gid0 = get_global_id(0);\n";
- ss << " int bLastDayMode =1,bLastDay =0,b30Days= 0,bUSMode = 0;\n";
ss << " int nSettle,nMat,nFreq,nBase;\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);
- ss<< " int buffer_nSettle_len = ";
- ss<< tmpCurDVR0->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_nMat_len = ";
- ss<< tmpCurDVR1->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_nFreq_len = ";
- ss<< tmpCurDVR2->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_nBase_len = ";
- ss<< tmpCurDVR3->GetArrayLength();
- ss << ";\n";
+ FormulaToken* tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ FormulaToken* tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ FormulaToken* tmpCur2 = vSubArguments[2]->GetFormulaToken();
+ FormulaToken* tmpCur3 = vSubArguments[3]->GetFormulaToken();
#endif
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_nSettle_len || isNan(";
- ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur0->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ ss <<" if(isNan("<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR0->GetArrayLength()<<"))\n";
ss <<" nSettle = 0;\n else\n";
+ }
#endif
- ss << " nSettle=(int)";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<";\n";
+ ss <<" nSettle=(int)";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_nMat_len || isNan(";
- ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur1->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ ss <<" if(isNan("<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR1->GetArrayLength()<<"))\n";
ss <<" nMat = 0;\n else\n";
+ }
#endif
ss <<" nMat=(int)";
ss << vSubArguments[1]->GenSlidingWindowDeclRef();
- ss << ";\n";
+ ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_nFreq_len || isNan(";
- ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur2->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss <<" if(isNan("<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR2->GetArrayLength()<<"))\n";
ss <<" nFreq = 0;\n else\n";
+ }
#endif
- ss <<" nFreq=(int)";
- ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss << " nFreq=(int)";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_nBase_len || isNan(";
- ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur3->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur3);
+ ss <<" if(isNan(" <<vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR3->GetArrayLength()<<"))\n";
ss <<" nBase = 0;\n else\n";
+ }
#endif
- ss <<" nBase=(int)";
+ ss << " nBase=(int)";
ss << vSubArguments[3]->GenSlidingWindowDeclRef();
- ss <<";\n";
- ss <<" int nNullDate=GetNullDate();\n";
- ss <<" ScaDate2(nNullDate, nMat, nBase,&bLastDayMode,&bLastDay,";
- ss <<"&b30Days,&bUSMode);\n";
- ss <<" tmp = lcl_GetCouppcd(nNullDate,nSettle,nMat,nFreq,";
- ss <<"&bLastDayMode,&bLastDay,&b30Days,&bUSMode);\n";
+ ss << ";\n";
+ ss <<" int nNullDate=693594;\n";
+ ss <<" tmp = lcl_GetCouppcd(nNullDate,nSettle,nMat,nFreq,nBase);\n";
ss <<" return tmp;\n";
ss <<"}";
}
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index 052c364..91d04d2 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -334,46 +334,36 @@ std::string ScaDate2=
"}\n";
std::string lcl_GetCouppcdDecl=
-"int lcl_GetCouppcd(int nNullDate,int nSettle, int nMat,int nFreq,int *"
-"bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode);\n";
+"int lcl_GetCouppcd(int nNullDate,int nSettle,int nMat,int nFreq,int nBase);\n";
std::string lcl_GetCouppcd=
-"int lcl_GetCouppcd(int nNullDate,int nSettle, int nMat,int nFreq,int *"
-"bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode)\n"
+"int lcl_GetCouppcd(int nNullDate,int nSettle, int nMat,int nFreq,int nBase)\n"
"{\n"
-" int aDate = nMat;int rDay=0,rMonth=0,rYear=0;int mDay=0,mMonth=0,"
-"mYear=0;\n"
-" int sDay=0,sMonth=0, sYear=0;\n"
-" DaysToDate(aDate+nNullDate,&rDay, &rMonth, &rYear );\n"
-" DaysToDate(nMat+nNullDate,&mDay, &mMonth, &mYear );\n"
-" DaysToDate(nSettle+nNullDate,&sDay, &sMonth, &sYear );\n"
-" rYear= sYear;\n"
-" nSettle=nSettle+nNullDate;\n"
-" aDate=DateToDays( rDay,rMonth,rYear );\n"
-" if( aDate < nSettle )\n"
-" rYear+= 1;\n"
-" int d=DateToDays( rDay,rMonth,rYear );\n"
-" int nMonthCount=-1*(12 / nFreq);\n"
-" while(d > nSettle )\n"
+" int aDate = nMat;\n"
+" int rDay=0,rMonth=0, rYear=0,rbLastDayMode=0, rbLastDay=0,rb30Days=0,"
+"rbUSMode=0,rnDay=0;\n"
+" int sDay=0,sMonth=0, sYear=0,sbLastDayMode=0, sbLastDay=0,sb30Days=0,"
+"sbUSMode=0,snDay=0;\n"
+" ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear,&sbLastDayMode,"
+"&sbLastDay,&sb30Days,&sbUSMode,&snDay);\n"
+" ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear,&rbLastDayMode,"
+"&rbLastDay,&rb30Days,&rbUSMode,&rnDay);\n"
+" rYear=sYear;\n"
+" setDay(rDay,rMonth,rYear,rbLastDay,rb30Days,&rnDay);\n"
+" if(checklessthan(rYear,sYear,rMonth,sMonth,rnDay,snDay,rbLastDay,"
+"sbLastDay,rDay,sDay))\n"
" {\n"
-" int nNewMonth = nMonthCount + rMonth;\n"
-" if( nNewMonth > 12 )\n"
-" {\n"
-" --nNewMonth;\n"
-" rYear+=nNewMonth / 12;\n"
-" rMonth = nNewMonth % 12 + 1;\n"
-" }\n"
-" else if( nNewMonth < 1 )\n"
-" {\n"
-" rYear+= nNewMonth / 12 - 1;\n"
-" rMonth = nNewMonth % 12 + 12;\n"
-" }\n"
-" else\n"
-" rMonth = nNewMonth;\n"
-" d=DateToDays( rDay,rMonth,rYear );\n"
+" rYear+=1;\n"
+" setDay(rDay,rMonth,rYear,rbLastDay,rb30Days,&rnDay);\n"
+" }\n"
+" while(checklessthan(sYear,rYear,sMonth,rMonth,snDay,rnDay,sbLastDay,"
+"rbLastDay,sDay,rDay))\n"
+" {\n"
+" double d = -1*(12/nFreq);\n"
+" addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,d,&rYear);\n"
" }\n"
" int nLastDay = DaysInMonth( rMonth, rYear );\n"
-" int nRealDay = ((*bLastDayMode) && (*bLastDay)) ? nLastDay :"
+" int nRealDay = (rbLastDayMode && rbLastDay) ? nLastDay :"
"min( nLastDay, rDay );\n"
" return DateToDays( nRealDay, rMonth, rYear ) - nNullDate;\n"
"}\n";
commit fdbf86457707ffd105fc5e1bae594f0e974f6a5e
Author: minwang <min at multicorewareinc.com>
Date: Tue Dec 24 14:41:41 2013 +0800
GPU Calc: Optimized COUPNCD
AMLOEXT-381
Change-Id: Iccae2ddd0bbfc598016ca331402003625251d99b
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 17f37bf..62fedd3 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3721,100 +3721,99 @@ void OpCoupncd::BinInlineFun(std::set<std::string>& decls,
{
decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
- decls.insert(GetNullDateDecl); decls.insert(ScaDate2Decl);
+ decls.insert(GetNullDateDecl);
+ decls.insert(ScaDateDecl);
+ decls.insert(addMonthsDecl);
+ decls.insert(setDayDecl);decls.insert(checklessthanDecl);
decls.insert(lcl_GetCoupncdDecl);
funs.insert(IsLeapYear);funs.insert(DaysInMonth);
funs.insert(DaysToDate);funs.insert(DateToDays);
- funs.insert(GetNullDate);funs.insert(ScaDate2);
+ funs.insert(GetNullDate);
+ funs.insert(ScaDate);
+ funs.insert(addMonths);
+ funs.insert(setDay);funs.insert(checklessthan);
funs.insert(lcl_GetCoupncd);
}
void OpCoupncd::GenSlidingWindowFunction(
- std::stringstream &ss, const std::string sSymName,
- SubArguments &vSubArguments)
+ 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);
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
}
ss << ") {\n";
ss << " double tmp = 0;\n";
ss << " int gid0 = get_global_id(0);\n";
- ss << " int bLastDayMode =1,bLastDay =0,b30Days= 0,bUSMode = 0;\n";
ss << " int nSettle,nMat,nFreq,nBase;\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);
- ss<< " int buffer_nSettle_len = ";
- ss<< tmpCurDVR0->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_nMat_len = ";
- ss<< tmpCurDVR1->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_nFreq_len = ";
- ss<< tmpCurDVR2->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_nBase_len = ";
- ss<< tmpCurDVR3->GetArrayLength();
- ss << ";\n";
+ FormulaToken* tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ FormulaToken* tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ FormulaToken* tmpCur2 = vSubArguments[2]->GetFormulaToken();
+ FormulaToken* tmpCur3 = vSubArguments[3]->GetFormulaToken();
#endif
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_nSettle_len || isNan(";
- ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur0->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ ss <<" if(isNan("<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR0->GetArrayLength()<<"))\n";
ss <<" nSettle = 0;\n else\n";
+ }
#endif
- ss << " nSettle=(int)";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<";\n";
+ ss <<" nSettle=(int)";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_nMat_len || isNan(";
- ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur1->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ ss <<" if(isNan("<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR1->GetArrayLength()<<"))\n";
ss <<" nMat = 0;\n else\n";
+ }
#endif
ss <<" nMat=(int)";
ss << vSubArguments[1]->GenSlidingWindowDeclRef();
- ss << ";\n";
+ ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_nFreq_len || isNan(";
- ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur2->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss <<" if(isNan("<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR2->GetArrayLength()<<"))\n";
ss <<" nFreq = 0;\n else\n";
+ }
#endif
- ss <<" nFreq=(int)";
- ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss << " nFreq=(int)";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_nBase_len || isNan(";
- ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur3->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur3);
+ ss <<" if(isNan(" <<vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR3->GetArrayLength()<<"))\n";
ss <<" nBase = 0;\n else\n";
+ }
#endif
- ss <<" nBase=(int)";
+ ss << " nBase=(int)";
ss << vSubArguments[3]->GenSlidingWindowDeclRef();
- ss <<";\n";
- ss <<" int nNullDate=GetNullDate();\n";
- ss <<" ScaDate2(nNullDate, nMat, nBase,&bLastDayMode,&bLastDay,";
- ss <<"&b30Days,&bUSMode);\n";
- ss <<" tmp = lcl_GetCoupncd(nNullDate,nSettle,nMat,nFreq,";
- ss <<"&bLastDayMode,&bLastDay,&b30Days,&bUSMode);\n";
+ ss << ";\n";
+ ss <<" int nNullDate=693594;\n";
+ ss <<" tmp = lcl_GetCoupncd(nNullDate,nSettle,nMat,nFreq,nBase);\n";
ss <<" return tmp;\n";
ss <<"}";
}
+
void OpCoupdaysnc::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index 6cce4af..052c364 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -379,47 +379,35 @@ std::string lcl_GetCouppcd=
"}\n";
std::string lcl_GetCoupncdDecl=
-"int lcl_GetCoupncd(int nNullDate,int nSettle, int nMat,int nFreq,"
-"int *bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode);\n";
+"int lcl_GetCoupncd(int nNullDate,int nSettle,int nMat,int nFreq,int nBase);\n";
std::string lcl_GetCoupncd=
-"int lcl_GetCoupncd(int nNullDate,int nSettle, int nMat,int nFreq,"
-"int *bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode)\n"
+"int lcl_GetCoupncd(int nNullDate,int nSettle, int nMat,int nFreq,int nBase)\n"
"{\n"
-" int aDate = nMat;int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0,\n"
-" mYear=0;\n"
-" int sDay=0,sMonth=0, sYear=0;\n"
-" DaysToDate(aDate+nNullDate,&rDay, &rMonth, &rYear );\n"
-" DaysToDate(nMat+nNullDate,&mDay, &mMonth, &mYear );\n"
-" DaysToDate(nSettle+nNullDate,&sDay, &sMonth, &sYear );\n"
-" rYear= sYear;\n"
-" nSettle=nSettle+nNullDate;\n"
-" aDate=DateToDays( rDay,rMonth,rYear );\n"
-" if( aDate > nSettle )\n"
-" rYear+= -1;\n"
-" int d=DateToDays( rDay,rMonth,rYear );\n"
-" int nMonthCount=12 / nFreq;\n"
-" while(d <= nSettle )\n"
+" int aDate = nMat;\n"
+" int rDay=0,rMonth=0, rYear=0,rbLastDayMode=0, rbLastDay=0,rb30Days=0,"
+"rbUSMode=0,rnDay=0;\n"
+" int sDay=0,sMonth=0, sYear=0,sbLastDayMode=0, sbLastDay=0,sb30Days=0,"
+"sbUSMode=0,snDay=0;\n"
+" ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear,&sbLastDayMode,"
+"&sbLastDay,&sb30Days,&sbUSMode,&snDay);\n"
+" ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear,&rbLastDayMode,"
+"&rbLastDay,&rb30Days,&rbUSMode,&rnDay);\n"
+" rYear=sYear;\n"
+" setDay(rDay,rMonth,rYear,rbLastDay,rb30Days,&rnDay);\n"
+" if(checklessthan(sYear,rYear,sMonth,rMonth,snDay,rnDay,sbLastDay,rbLastDay"
+",sDay,rDay))\n"
" {\n"
-" int nNewMonth = nMonthCount + rMonth;\n"
-" rMonth=rMonth+ 12 / nFreq ;\n"
-" if( nNewMonth > 12 )\n"
-" {\n"
-" --nNewMonth;\n"
-" rYear+=nNewMonth / 12;\n"
-" rMonth = nNewMonth % 12 + 1;\n"
-" }\n"
-" else if( nNewMonth < 1 )\n"
-" {\n"
-" rYear+= nNewMonth / 12 - 1;\n"
-" rMonth = nNewMonth % 12 + 12;\n"
-" }\n"
-" else\n"
-" rMonth = nNewMonth;\n"
-" d=DateToDays( rDay,rMonth,rYear );\n"
+" rYear-=1;\n"
+" setDay(rDay,rMonth,rYear,rbLastDay,rb30Days,&rnDay);\n"
+" }\n"
+" while(!checklessthan(sYear,rYear,sMonth,rMonth,snDay,rnDay,sbLastDay,"
+"rbLastDay,sDay,rDay))\n"
+" {\n"
+" addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,12/nFreq,&rYear);\n"
" }\n"
" int nLastDay = DaysInMonth( rMonth, rYear );\n"
-" int nRealDay = ((*bLastDayMode) && (*bLastDay)) ? nLastDay :"
+" int nRealDay = (rbLastDayMode && rbLastDay) ? nLastDay :"
"min( nLastDay, rDay );\n"
" return DateToDays( nRealDay, rMonth, rYear ) - nNullDate;\n"
"}\n";
commit e600adae34fe99373eb9695864aadabc06682773
Author: minwang <min at multicorewareinc.com>
Date: Tue Dec 24 14:35:55 2013 +0800
GPU Calc: Optimized AMORLINC
AMLOEXT-228
Change-Id: Ie48898fd7b783bb94e3dcf0121ae40d9aa32916e
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index f7b7ed0..17f37bf 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -4189,11 +4189,11 @@ void OpAmorlinc::BinInlineFun(std::set<std::string>& decls,
decls.insert(nKorrValDecl); decls.insert(RoundDecl);
decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
- decls.insert(GetNullDateDecl); decls.insert(GetYearFracDecl);
+ decls.insert(GetYearFracDecl);
funs.insert(Round);
funs.insert(IsLeapYear);funs.insert(DaysInMonth);
funs.insert(DaysToDate);funs.insert(DateToDays);
- funs.insert(GetNullDate);funs.insert(GetYearFrac);
+ funs.insert(GetYearFrac);
}
void OpAmorlinc::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
@@ -4208,112 +4208,105 @@ void OpAmorlinc::GenSlidingWindowFunction(std::stringstream &ss,
}
ss << ") {\n";
ss << " int gid0 = get_global_id(0);\n";
- ss << " double tmp = " << GetBottom() <<";\n";
+ ss << " double tmp = 0;\n";
ss << " double fCost,fRestVal,fPer,fRate;\n";
ss << " int nDate,nFirstPer,nBase;\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);
FormulaToken *tmpCur5 = vSubArguments[5]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR5= dynamic_cast<const
- formula::SingleVectorRefToken *>(tmpCur5);
FormulaToken *tmpCur6 = vSubArguments[6]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR6= dynamic_cast<const
- formula::SingleVectorRefToken *>(tmpCur6);
- ss<< " int buffer_Cost_len = ";
- ss<< tmpCurDVR0->GetArrayLength();
- ss<< ";\n";
- ss<< " int buffer_Date_len = ";
- ss<< tmpCurDVR1->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_FirstPer_len = ";
- ss<< tmpCurDVR2->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_RestVal_len = ";
- ss<< tmpCurDVR3->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_Per_len = ";
- ss<< tmpCurDVR4->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_Rate_len = ";
- ss<< tmpCurDVR5->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_Base_len = ";
- ss<< tmpCurDVR6->GetArrayLength();
- ss << ";\n";
#endif
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Cost_len || isNan(";
- ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur0->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ ss <<" if(isNan("<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR0->GetArrayLength()<<"))\n";
ss <<" fCost = 0;\n else\n";
+ }
#endif
ss << " fCost=";
ss << vSubArguments[0]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Date_len || isNan(";
- ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur1->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ ss <<" if(isNan("<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR1->GetArrayLength()<<"))\n";
ss <<" nDate = 0;\n else\n";
+ }
#endif
ss << " nDate=(int)";
ss << vSubArguments[1]->GenSlidingWindowDeclRef();
ss << ";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_FirstPer_len || isNan(";
- ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur2->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss <<" if(isNan("<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR2->GetArrayLength()<<"))\n";
ss <<" nFirstPer = 0;\n else\n";
+ }
#endif
ss << " nFirstPer=(int)";
ss << vSubArguments[2]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_RestVal_len || isNan(";
- ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur3->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur3);
+ ss <<" if(isNan(" <<vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR3->GetArrayLength()<<"))\n";
ss <<" fRestVal = 0;\n else\n";
+ }
#endif
ss << " fRestVal=";
ss << vSubArguments[3]->GenSlidingWindowDeclRef();
ss << ";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Per_len || isNan(";
- ss <<vSubArguments[4]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur4->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR4= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur4);
+ ss <<" if(isNan(" <<vSubArguments[4]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR4->GetArrayLength()<<"))\n";
ss <<" fPer = 0;\n else\n";
+ }
#endif
ss << " fPer = ";
ss << vSubArguments[4]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Rate_len || isNan(";
- ss <<vSubArguments[5]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur5->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR5= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur5);
+ ss <<" if(isNan(" <<vSubArguments[5]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR5->GetArrayLength()<<"))\n";
ss <<" fRate = 0;\n else\n";
+ }
#endif
ss << " fRate=";
ss << vSubArguments[5]->GenSlidingWindowDeclRef();
ss << ";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Base_len || isNan(";
- ss <<vSubArguments[6]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur6->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR6= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur6);
+ ss <<" if(isNan(" <<vSubArguments[6]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR6->GetArrayLength()<<"))\n";
ss <<" nBase = 0;\n else\n";
+ }
#endif
ss << " nBase = (int)";
ss << vSubArguments[6]->GenSlidingWindowDeclRef();
@@ -4321,10 +4314,10 @@ void OpAmorlinc::GenSlidingWindowFunction(std::stringstream &ss,
ss <<" int nPer = convert_int( fPer );\n";
ss <<" double fOneRate = fCost * fRate;\n";
ss <<" double fCostDelta = fCost - fRestVal;\n";
- ss <<" double f0Rate = GetYearFrac( GetNullDate(),";
+ ss <<" double f0Rate = GetYearFrac( 693594,";
ss <<"nDate, nFirstPer, nBase )* fRate * fCost;\n";
ss <<" int nNumOfFullPeriods = (int)";
- ss <<"( ( fCost - fRestVal - f0Rate) /fOneRate );\n";
+ ss <<"( ( fCost - fRestVal - f0Rate) *pow(fOneRate,-1) );\n";
ss <<" if( nPer == 0 )\n";
ss <<" tmp = f0Rate;\n";
ss <<" else if( nPer <= nNumOfFullPeriods )\n";
commit 9d5b5dfeb2d4d913900de86a97387e6d997c5e38
Author: minwang <min at multicorewareinc.com>
Date: Tue Dec 24 14:28:32 2013 +0800
GPU Calc: Optimized AMORDEGRC
AMLOEXT-227
Change-Id: Ifa085f04d362dd17aa28ce203ef05fbc62940aa9
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 176c0a1..f7b7ed0 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -4049,113 +4049,106 @@ void OpAmordegrc::GenSlidingWindowFunction(std::stringstream &ss,
ss << " int nDate,nFirstPer,nBase;\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);
FormulaToken *tmpCur5 = vSubArguments[5]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR5= dynamic_cast<const
- formula::SingleVectorRefToken *>(tmpCur5);
FormulaToken *tmpCur6 = vSubArguments[6]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR6= dynamic_cast<const
- formula::SingleVectorRefToken *>(tmpCur6);
- ss<< " int buffer_Cost_len = ";
- ss<< tmpCurDVR0->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_Date_len = ";
- ss<< tmpCurDVR1->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_FirstPer_len = ";
- ss<< tmpCurDVR2->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_RestVal_len = ";
- ss<< tmpCurDVR3->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_Per_len = ";
- ss<< tmpCurDVR4->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_Rate_len = ";
- ss<< tmpCurDVR5->GetArrayLength();
- ss << ";\n";
- ss<< " int buffer_Base_len = ";
- ss<< tmpCurDVR6->GetArrayLength();
- ss << ";\n";
#endif
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Cost_len || isNan(";
- ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur0->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ ss <<" if(isNan("<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR0->GetArrayLength()<<"))\n";
ss <<" fCost = 0;\n else\n";
- #endif
+ }
+#endif
ss << " fCost=";
ss << vSubArguments[0]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Date_len || isNan(";
- ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur1->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ ss <<" if(isNan("<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR1->GetArrayLength()<<"))\n";
ss <<" nDate = 0;\n else\n";
+ }
#endif
ss << " nDate=(int)";
ss << vSubArguments[1]->GenSlidingWindowDeclRef();
ss << ";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_FirstPer_len || isNan(";
- ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur2->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss <<" if(isNan("<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR2->GetArrayLength()<<"))\n";
ss <<" nFirstPer = 0;\n else\n";
+ }
#endif
ss << " nFirstPer=(int)";
ss << vSubArguments[2]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_RestVal_len || isNan(";
- ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur3->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur3);
+ ss <<" if(isNan(" <<vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR3->GetArrayLength()<<"))\n";
ss <<" fRestVal = 0;\n else\n";
+ }
#endif
ss << " fRestVal=";
ss << vSubArguments[3]->GenSlidingWindowDeclRef();
ss << ";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Per_len || isNan(";
- ss <<vSubArguments[4]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur4->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR4= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur4);
+ ss <<" if(isNan(" <<vSubArguments[4]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR4->GetArrayLength()<<"))\n";
ss <<" fPer = 0;\n else\n";
+ }
#endif
ss << " fPer = ";
ss << vSubArguments[4]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Rate_len || isNan(";
- ss <<vSubArguments[5]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur5->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR5= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur5);
+ ss <<" if(isNan(" <<vSubArguments[5]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR5->GetArrayLength()<<"))\n";
ss <<" fRate = 0;\n else\n";
+ }
#endif
ss << " fRate=";
ss << vSubArguments[5]->GenSlidingWindowDeclRef();
ss << ";\n";
#ifdef ISNAN
- ss <<" if(gid0 >= buffer_Base_len || isNan(";
- ss <<vSubArguments[6]->GenSlidingWindowDeclRef();
- ss <<"))\n";
+ if(tmpCur6->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR6= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur6);
+ ss <<" if(isNan(" <<vSubArguments[6]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR6->GetArrayLength()<<"))\n";
ss <<" nBase = 0;\n else\n";
+ }
#endif
ss << " nBase = (int)";
ss << vSubArguments[6]->GenSlidingWindowDeclRef();
ss << ";\n";
ss <<" uint nPer = convert_int( fPer );\n";
- ss <<" double fUsePer = 1.0 / fRate;\n";
+ ss <<" double fUsePer = 1.0 *pow( fRate,-1);\n";
ss <<" double fAmorCoeff;\n";
ss <<" if( fUsePer < 3.0 )\n";
ss <<" fAmorCoeff = 1.0;\n";
@@ -4166,7 +4159,7 @@ void OpAmordegrc::GenSlidingWindowFunction(std::stringstream &ss,
ss <<" else\n";
ss <<" fAmorCoeff = 2.5;\n";
ss <<" fRate *= fAmorCoeff;\n";
- ss <<" tmp = Round( GetYearFrac( GetNullDate(),";
+ ss <<" tmp = Round( GetYearFrac( 693594,";
ss <<"nDate, nFirstPer, nBase ) * fRate * fCost);\n";
ss <<" fCost = fCost-tmp;\n";
ss <<" double fRest = fCost - fRestVal;\n";
commit 5aeeba0efa4b21d185603671675bf36d204940e5
Author: minwang <min at multicorewareinc.com>
Date: Tue Dec 24 14:20:15 2013 +0800
GPU Calc: Optimized COUPNUM
AMLOEXT-222
Change-Id: I630a4e1d648158e66efe4efb5d671a9b1df06f6a
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index acd90ea..176c0a1 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3928,14 +3928,19 @@ void OpCoupnum::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
- decls.insert(DaysToDateDecl);decls.insert(DateToDaysDecl);
- decls.insert(GetNullDateDecl);decls.insert(lcl_GetcoupnumDecl);
- decls.insert(coupnumDecl);
- funs.insert(IsLeapYear);funs.insert(DaysInMonth);
- funs.insert(DaysToDate);funs.insert(DateToDays);
- funs.insert(GetNullDate);
- funs.insert(lcl_Getcoupnum);
- funs.insert(coupnum);
+ decls.insert(DaysToDateDecl);
+ decls.insert(DateToDaysDecl);
+ decls.insert(ScaDateDecl);
+ decls.insert(setDayDecl);decls.insert(checklessthanDecl);
+ decls.insert(addMonthsDecl);decls.insert(lcl_Getcoupnum_newDecl);
+ decls.insert(coupnum_newDecl);
+ funs.insert(IsLeapYear);funs.insert(DaysInMonth_new);
+ funs.insert(DaysToDate);
+ funs.insert(DateToDays);
+ funs.insert(ScaDate);
+ funs.insert(setDay);funs.insert(checklessthan);
+ funs.insert(addMonths);funs.insert(lcl_Getcoupnum_new);
+ funs.insert(coupnum_new);
}
void OpCoupnum::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
@@ -3945,77 +3950,73 @@ void OpCoupnum::GenSlidingWindowFunction(std::stringstream &ss,
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
if (i)
- ss << ",";
+ ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
- ss << ") {\n ";
- ss << "double tmp = " << GetBottom() <<";\n ";
- ss << "int gid0 = get_global_id(0);\n ";
- ss << "int nSettle,nMat,nFreq,nBase;\n ";
+ ss << ") {\n";
+ ss << " double tmp = 0;\n";
+ ss << " int gid0 = get_global_id(0);\n";
+ ss << " int nSettle,nMat,nFreq,nBase;\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);
- ss<< "int buffer_nSettle_len = ";
- ss<< tmpCurDVR0->GetArrayLength();
- ss << ";\n ";
- ss<< "int buffer_nMat_len = ";
- ss<< tmpCurDVR1->GetArrayLength();
- ss << ";\n ";
- ss<< "int buffer_nFreq_len = ";
- ss<< tmpCurDVR2->GetArrayLength();
- ss << ";\n ";
- ss<< "int buffer_nBase_len = ";
- ss<< tmpCurDVR3->GetArrayLength();
- ss << ";\n ";
#endif
#ifdef ISNAN
- ss <<"if(gid0 >= buffer_nSettle_len || isNan(";
- ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<"))\n ";
- ss <<"nSettle = 0;\n else\n ";
+ if(tmpCur0->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ ss <<" if(isNan("<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR0->GetArrayLength()<<"))\n";
+ ss <<" nSettle = 0;\n else\n";
+ }
#endif
- ss << "nSettle=(int)";
+ ss <<" nSettle=(int)";
ss << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<";\n ";
+ ss <<";\n";
#ifdef ISNAN
- ss <<"if(gid0 >= buffer_nMat_len || isNan(";
- ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
- ss <<"))\n ";
- ss <<"nMat = 0;\n else\n ";
+ if(tmpCur1->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ ss <<" if(isNan("<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR1->GetArrayLength()<<"))\n";
+ ss <<" nMat = 0;\n else\n";
+ }
#endif
- ss << "nMat=(int)";
+ ss <<" nMat=(int)";
ss << vSubArguments[1]->GenSlidingWindowDeclRef();
- ss << ";\n ";
+ ss <<";\n";
#ifdef ISNAN
- ss <<"if(gid0 >= buffer_nFreq_len || isNan(";
- ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
- ss <<"))\n ";
- ss <<"nFreq = 0;\n else\n ";
+ if(tmpCur2->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss <<" if(isNan("<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR2->GetArrayLength()<<"))\n";
+ ss <<" nFreq = 0;\n else\n";
+ }
#endif
- ss << "nFreq=(int)";
+ ss << " nFreq=(int)";
ss << vSubArguments[2]->GenSlidingWindowDeclRef();
- ss <<";\n ";
+ ss <<";\n";
#ifdef ISNAN
- ss <<"if(gid0 >= buffer_nBase_len || isNan(";
- ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
- ss <<"))\n ";
- ss <<"nBase = 0;\n else\n ";
+ if(tmpCur3->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur3);
+ ss <<" if(isNan(" <<vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR3->GetArrayLength()<<"))\n";
+ ss <<" nBase = 0;\n else\n";
+ }
#endif
- ss << "nBase=(int)";
+ ss << " nBase=(int)";
ss << vSubArguments[3]->GenSlidingWindowDeclRef();
- ss << ";\n ";
- ss <<"tmp = coupnum(nSettle,nMat,nFreq,nBase);\n ";
- ss << "return tmp;\n";
+ ss << ";\n";
+ ss <<" tmp = coupnum_new(nSettle,nMat,nFreq,nBase);\n";
+ ss <<" return tmp;\n";
ss << "}";
}
void OpAmordegrc::BinInlineFun(std::set<std::string>& decls,
commit 0389e9e112f62fae0715979290d7dc084801cba0
Author: minwang <min at multicorewareinc.com>
Date: Tue Dec 24 14:16:14 2013 +0800
GPU Calc: Optimized COUPDAYSNC
AMLOEXT-363
Change-Id: Id0681aaa788e8b96780c29e7441415cc7b7cef68
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index d0a00eb..acd90ea 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3818,104 +3818,109 @@ void OpCoupncd::GenSlidingWindowFunction(
void OpCoupdaysnc::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
- decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
+ decls.insert(IsLeapYearDecl); decls.insert(DaysInMonth_newDecl);
decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
- decls.insert(GetNullDateDecl); decls.insert(ScaDateDecl);
+ decls.insert(DateToDays_newDecl);
+ decls.insert(ScaDateDecl);
decls.insert(addMonthsDecl); decls.insert(getDaysInMonthRangeDecl);
decls.insert(GetDaysInYearsDecl); decls.insert(GetDaysInYearDecl);
decls.insert(getDaysInYearRangeDecl); decls.insert(getDiffDecl);
- decls.insert(lcl_GetcoupdaysDecl);decls.insert(lcl_GetcoupdaybsDecl);
- decls.insert(coupdaysDecl);decls.insert(coupdaybsDecl);
- decls.insert(coupdaysncDecl);
- funs.insert(IsLeapYear);funs.insert(DaysInMonth);
- funs.insert(DaysToDate);funs.insert(DateToDays);
- funs.insert(GetNullDate);funs.insert(ScaDate);
+ decls.insert(setDayDecl);decls.insert(checklessthanDecl);
+ decls.insert(coupdaybs_newDecl);
+ decls.insert(lcl_Getcoupdays_newDecl);
+ decls.insert(lcl_Getcoupdaybs_newDecl);
+ decls.insert(coupdays_newDecl);
+ decls.insert(coupdaysnc_newDecl);
+ funs.insert(IsLeapYear);funs.insert(DaysInMonth_new);
+ funs.insert(DaysToDate);funs.insert(DateToDays_new);
+ funs.insert(DateToDays);
+ funs.insert(ScaDate);
funs.insert(addMonths);funs.insert(getDaysInMonthRange);
funs.insert(GetDaysInYears);funs.insert(GetDaysInYear);
funs.insert(getDaysInYearRange);funs.insert(getDiff);
- funs.insert(lcl_Getcoupdays);funs.insert(lcl_Getcoupdaybs);
- funs.insert(coupdaysnc);funs.insert(coupdaybs);
- funs.insert(coupdays);
+ funs.insert(setDay);funs.insert(checklessthan);
+ funs.insert(lcl_Getcoupdaybs_new);
+ funs.insert(coupdaybs_new);
+ funs.insert(lcl_Getcoupdays_new);
+ funs.insert(coupdaysnc_new);
+ funs.insert(coupdays_new);
}
void OpCoupdaysnc::GenSlidingWindowFunction(
- std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments)
+ 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);
+ 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";
+ ss << ") {\n";
+ ss << " double tmp = 0;\n";
+ ss << " int gid0 = get_global_id(0);\n";
+ ss << " int nSettle,nMat,nFreq,nBase;\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);
- 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";
+ FormulaToken* tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ FormulaToken* tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ FormulaToken* tmpCur2 = vSubArguments[2]->GetFormulaToken();
+ FormulaToken* tmpCur3 = vSubArguments[3]->GetFormulaToken();
#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";
+ if(tmpCur0->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ ss <<" if(isNan("<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR0->GetArrayLength()<<"))\n";
+ ss <<" nSettle = 0;\n else\n";
+ }
#endif
- ss << "nSettle=(int)";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<";\n\t";
+ ss <<" nSettle=(int)";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<";\n";
#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";
+ if(tmpCur1->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ ss <<" if(isNan("<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR1->GetArrayLength()<<"))\n";
+ ss <<" nMat = 0;\n else\n";
+ }
#endif
- ss << "nMat=(int)";
+ ss <<" nMat=(int)";
ss << vSubArguments[1]->GenSlidingWindowDeclRef();
- ss << ";\n\t";
+ ss <<";\n";
#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";
+ if(tmpCur2->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss <<" if(isNan("<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR2->GetArrayLength()<<"))\n";
+ ss <<" nFreq = 0;\n else\n";
+ }
#endif
- ss << "nFreq=(int)";
+ ss << " nFreq=(int)";
ss << vSubArguments[2]->GenSlidingWindowDeclRef();
- ss <<";\n\t";
+ ss <<";\n";
#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";
+ if(tmpCur3->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur3);
+ ss <<" if(isNan(" <<vSubArguments[3]->GenSlidingWindowDeclRef();
+ ss <<")||(gid0 >="<<tmpCurDVR3->GetArrayLength()<<"))\n";
+ ss <<" nBase = 0;\n else\n";
+ }
#endif
- ss << "nBase=(int)";
+ ss << " nBase=(int)";
ss << vSubArguments[3]->GenSlidingWindowDeclRef();
- ss << ";\n\t";
- ss <<"tmp = coupdaysnc(nSettle,nMat,nFreq,nBase);\n\t";
- ss << "return tmp;\n";
+ ss << ";\n";
+ ss <<" tmp = coupdaysnc_new(nSettle,nMat,nFreq,nBase);\n";
+ ss <<" return tmp;\n";
ss << "}";
}
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index ab1dc60..6cce4af 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -159,6 +159,8 @@ std::string DaysInMonth =
" return aDaysInMonth[nMonth-1];\n"
" }\n"
"}\n";
+std::string DaysInMonth_newDecl=
+"int DaysInMonth( int nMonth, int nYear );\n";
std::string DaysInMonth_new =
"int DaysInMonth( int nMonth, int nYear )\n"
commit cab9524aa2074a031d0ddf63eefd8ee679685dbc
Author: mulei <mulei at multicorewareinc.com>
Date: Tue Dec 24 14:10:18 2013 +0800
GPU Calc: Optimized PRICE
AMLOEXT-235
Change-Id: Ie58de89d7512a2661bb6fb3908850f71f1806eac
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 7237497..d0a00eb 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -2767,29 +2767,39 @@ void OpNPV::GenSlidingWindowFunction(std::stringstream &ss,
void OpPrice::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
- decls.insert(getPrice_Decl);
- decls.insert(coupnumDecl);decls.insert(coupdaysncDecl);
- decls.insert(coupdaybsDecl);decls.insert(coupdaysDecl);
- decls.insert(lcl_GetcoupnumDecl);decls.insert(lcl_GetcoupdaysDecl);
- decls.insert(lcl_GetcoupdaybsDecl);decls.insert(getDiffDecl);
- decls.insert(getDaysInYearRangeDecl);decls.insert(GetDaysInYearDecl);
- decls.insert(GetDaysInYearsDecl);decls.insert(getDaysInMonthRangeDecl);
- decls.insert(addMonthsDecl);decls.insert(ScaDateDecl);
- decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
- decls.insert(DaysToDateDecl);decls.insert(DaysInMonthDecl);
- decls.insert(IsLeapYearDecl);
-
- funs.insert(getPrice_);
- funs.insert(coupnum);funs.insert(coupdaysnc);
- funs.insert(coupdaybs);funs.insert(coupdays);
- funs.insert(lcl_Getcoupnum);funs.insert(lcl_Getcoupdays);
- funs.insert(lcl_Getcoupdaybs);funs.insert(getDiff);
- funs.insert(getDaysInYearRange);funs.insert(GetDaysInYear);
- funs.insert(GetDaysInYears);funs.insert(getDaysInMonthRange);
- funs.insert(addMonths);funs.insert(ScaDate);
- funs.insert(GetNullDate);funs.insert(DateToDays);
- funs.insert(DaysToDate);funs.insert(DaysInMonth);
- funs.insert(IsLeapYear);
+ decls.insert(getPrice_new_Decl);
+ decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
+ decls.insert(DaysToDateDecl);
+ decls.insert(DateToDaysDecl);
+ decls.insert(ScaDateDecl);
+ decls.insert(setDayDecl);decls.insert(checklessthanDecl);
+ decls.insert(addMonthsDecl);decls.insert(lcl_Getcoupnum_newDecl);
+ decls.insert(coupnum_newDecl);
+ decls.insert(DateToDays_newDecl);
+ decls.insert(getDaysInMonthRangeDecl);
+ decls.insert(GetDaysInYearsDecl); decls.insert(GetDaysInYearDecl);
+ decls.insert(getDaysInYearRangeDecl); decls.insert(getDiffDecl);
+ decls.insert(coupdaybs_newDecl);
+ decls.insert(lcl_Getcoupdays_newDecl);
+ decls.insert(lcl_Getcoupdaybs_newDecl);
+ decls.insert(coupdays_newDecl);
+ decls.insert(coupdaysnc_newDecl);
+ funs.insert(IsLeapYear);funs.insert(DaysInMonth_new);
+ funs.insert(DaysToDate);funs.insert(DateToDays_new);
+ funs.insert(DateToDays);
+ funs.insert(ScaDate);
+ funs.insert(addMonths);funs.insert(getDaysInMonthRange);
+ funs.insert(GetDaysInYears);funs.insert(GetDaysInYear);
+ funs.insert(getDaysInYearRange);funs.insert(getDiff);
+ funs.insert(setDay);funs.insert(checklessthan);
+ funs.insert(lcl_Getcoupdaybs_new);
+ funs.insert(coupdaybs_new);
+ funs.insert(lcl_Getcoupdays_new);
+ funs.insert(coupdaysnc_new);
+ funs.insert(coupdays_new);
+ funs.insert(setDay);funs.insert(checklessthan);
+ funs.insert(lcl_Getcoupnum_new);
+ funs.insert(coupnum_new);funs.insert(getPrice_new);
}
void OpPrice::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
@@ -2802,106 +2812,69 @@ void OpPrice::GenSlidingWindowFunction(std::stringstream &ss,
ss << ", ";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
- ss << ") {\n ";
- ss << "double tmp = 0;\n ";
- ss << "int gid0 = get_global_id(0);\n ";
- ss<<"double tmp0=0;\n ";
- ss<<"double tmp1=0;\n ";
- ss<<"double tmp2=0;\n ";
- ss<<"double tmp3=0;\n ";
- ss<<"double tmp4=0,tmp5=0;\n ";
- ss<<"double tmp6=0;\n ";
- size_t nItems = 0;
- ss <<"\n ";
+ ss<<") {\n";
+ ss<<" double tmp = 0;\n";
+ ss<<" int gid0 = get_global_id(0);\n";
+ ss<<" double tmp0=0;\n";
+ ss<<" double tmp1=0;\n";
+ ss<<" double tmp2=0;\n";
+ ss<<" double tmp3=0;\n";
+ ss<<" double tmp4=0,tmp5=0;\n";
+ ss<<" double tmp6=0;\n";
+ ss<<"\n";
for (size_t i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
assert(pCur);
- if (pCur->GetType() == formula::svDoubleVectorRef)
- {
- const formula::DoubleVectorRefToken* pDVR =
- dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
- size_t nCurWindowSize = pDVR->GetRefRowSize();
- ss << "for (int i = ";
- if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
-#ifdef ISNAN
- ss << "gid0; i < " << pDVR->GetArrayLength();
- ss << " && i < " << nCurWindowSize << "; i++){\n ";
-#else
- ss << "gid0; i < "<< nCurWindowSize << "; i++)\n ";
-#endif
- } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
-#ifdef ISNAN
- ss << "0; i < " << pDVR->GetArrayLength();
- ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n ";
-#else
- ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n ";
-#endif
- } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
-#ifdef ISNAN
- ss << "0; i + gid0 < " << pDVR->GetArrayLength();
- ss << " && i < "<< nCurWindowSize << "; i++){\n ";
-#else
- ss << "0; i < "<< nCurWindowSize << "; i++)\n ";
-#endif
- }
- else {
-#ifdef ISNAN
- ss << "0; i < "<< nCurWindowSize << "; i++){\n ";
-#else
- ss << "0; i < "<< nCurWindowSize << "; i++)\n ";
-#endif
- }
- nItems += nCurWindowSize;
- }
- else if (pCur->GetType() == formula::svSingleVectorRef)
+ if (pCur->GetType() == formula::svSingleVectorRef)
{
#ifdef ISNAN
const formula::SingleVectorRefToken* pSVR =
dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
- ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n ";
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
{
#ifdef ISNAN
- ss << "{\n ";
+ ss << "{\n";
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
{
- ss << "if (isNan(";
+ ss << " if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " tmp"<<i<<"= 0;\n";
+ ss << " else\n";
+ ss << " tmp"<<i<<"=";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
- ss << "))\n ";
- ss << "tmp"<<i<<"= 0;\n ";
- ss << "else\n ";
- ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
- ss << ";\n }\n ";
+ ss << ";\n }\n";
}
else
{
- ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
- ss <<";\n ";
+ ss << " tmp"<<i<<"=";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss <<";\n";
}
#else
- ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
- ss <<";\n ";
+ ss << " tmp"<<i<<"=";
+ ss<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss <<";\n";
#endif
}
- ss << "tmp = getPrice_(tmp0,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6);\n\t";
- ss << "return tmp;\n";
+ ss << " tmp = getPrice_(tmp0,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6);\n";
+ ss << " return tmp;\n";
ss << "}";
}
+
void OpOddlprice::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index 1cb2697..ab1dc60 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -160,6 +160,37 @@ std::string DaysInMonth =
" }\n"
"}\n";
+std::string DaysInMonth_new =
+"int DaysInMonth( int nMonth, int nYear )\n"
+"{\n"
+" int tmp = 0;\n"
+" switch(nMonth)\n"
+" {\n"
+" case 1:\n"
+" case 3:\n"
+" case 5:\n"
+" case 7:\n"
+" case 8:\n"
+" case 10:\n"
+" case 12:\n"
+" tmp = 31;\n"
+" break;\n"
+" case 4:\n"
+" case 6:\n"
+" case 9:\n"
+" case 11:\n"
+" tmp =30;\n"
+" break;\n"
+" case 2:\n"
+" if ( IsLeapYear(nYear)==1)\n"
+" tmp = 29;\n"
+" else\n"
+" tmp = 28;\n"
+" break;\n"
+" }\n"
+" return tmp;\n"
+"}\n";
+
std::string DaysToDateDecl =
"void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear );\n";
@@ -768,6 +799,45 @@ std::string lcl_Getcoupnum=
" n=n*nFreq/12;\n"
" return n;\n"
"}\n";
+std::string lcl_Getcoupnum_newDecl=
+"double lcl_Getcoupnum_new(int nNullDate,int nSettle,int nMat,int nFreq,int"
+" nBase);\n";
+std::string lcl_Getcoupnum_new=
+"double lcl_Getcoupnum_new(int nNullDate,int nSettle, int nMat,int nFreq,int"
+" nBase)\n"
+"{\n"
+" int aDate = nMat;\n"
+" int mDay=0,mMonth=0, mYear=0;\n"
+" int rDay=0,rMonth=0, rYear=0,rbLastDayMode=0, rbLastDay=0,rb30Days=0,"
+"rbUSMode=0,rnDay=0;\n"
+" int sDay=0,sMonth=0, sYear=0,sbLastDayMode=0, sbLastDay=0,sb30Days=0,"
+"sbUSMode=0,snDay=0;\n"
+" ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear,&sbLastDayMode,"
+"&sbLastDay,&sb30Days,&sbUSMode,&snDay);\n"
+" ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear,&rbLastDayMode,"
+"&rbLastDay,&rb30Days,&rbUSMode,&rnDay);\n"
+" mMonth = rMonth, mYear = rYear;\n"
+" rYear=sYear;\n"
+" setDay(rDay,rMonth,rYear,rbLastDay,rb30Days,&rnDay);\n"
+" if(checklessthan(rYear,sYear,rMonth,sMonth,rnDay,snDay,rbLastDay,"
+"sbLastDay,rDay,sDay))\n"
+" {\n"
+" rYear+=1;\n"
+" setDay(rDay,rMonth,rYear,rbLastDay,rb30Days,&rnDay);\n"
+" }\n"
+" int m= checklessthan(sYear,rYear,sMonth,rMonth,snDay,rnDay,sbLastDay,"
+"rbLastDay,sDay,rDay);\n"
+" while(m)\n"
+" {\n"
+" double d = -1*(12/nFreq);\n"
+" addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,d,&rYear);\n"
+" m = checklessthan(sYear,rYear,sMonth,rMonth,snDay,rnDay,sbLastDay,"
+"rbLastDay,sDay,rDay);\n"
+" }\n"
+" int n=(mYear-rYear)*12+mMonth-rMonth;\n"
+" double tmp = (double)(n*nFreq)/12.0;\n"
+" return tmp;\n"
+"}\n";
std::string setDayDecl=
"void setDay(int nOrigDay, int nMonth,int nYear,int bLastDay,int b30Days,"
@@ -809,7 +879,7 @@ std::string coupdays_newDecl=
std::string coupdays_new=
"double coupdays_new(int nSettle,int nMat,int nFreq,int nBase)\n"
"{\n"
-" int nNullDate=GetNullDate_new();\n"
+" int nNullDate=693594;\n"
" if( nBase == 1 )\n"
" return lcl_Getcoupdays_new(nNullDate, nSettle, nMat,nFreq, nBase);\n"
" else\n"
@@ -832,7 +902,7 @@ std::string coupdaybs_newDecl=
std::string coupdaybs_new=
"double coupdaybs_new( int nSettle,int nMat,int nFreq,int nBase)\n"
"{\n"
-" int nNullDate=GetNullDate_new();\n"
+" int nNullDate=693594;\n"
" return lcl_Getcoupdaybs_new(nNullDate, nSettle, nMat,nFreq, nBase);\n"
"}\n";
@@ -877,6 +947,49 @@ std::string coupdaysnc=
" return coupdays(nSettle,nMat,nFreq,nBase)- coupdaybs( nSettle,nMat,"
"nFreq,nBase);\n"
"}\n";
+std::string coupdaysnc_newDecl=
+"double coupdaysnc_new( int nSettle,int nMat,int nFreq,int nBase);\n";
+
+std::string coupdaysnc_new=
+"double coupdaysnc_new( int nSettle,int nMat,int nFreq,int nBase)\n"
+"{\n"
+" int nNullDate=693594;\n"
+" if((nBase != 0) && (nBase != 4))\n"
+" {\n"
+" int aDate = nMat;\n"
+" int rDay=0,rMonth=0, rYear=0,rbLastDayMode=0, rbLastDay=0,rb30Days=0,"
+"rbUSMode=0,rnDay=0;\n"
+" int sDay=0,sMonth=0, sYear=0,sbLastDayMode=0, sbLastDay=0,sb30Days=0,"
+"sbUSMode=0,snDay=0;\n"
+" ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear,&rbLastDayMode,"
+"&rbLastDay,&rb30Days,&rbUSMode,&rnDay);\n"
+" ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear,&sbLastDayMode,"
+"&sbLastDay,&sb30Days,&sbUSMode,&snDay);\n"
+" rYear=sYear;\n"
+" setDay(rDay,rMonth,rYear,rbLastDay,rb30Days,&rnDay);\n"
+" aDate=DateToDays( rnDay,rMonth,rYear);\n"
+" if(checklessthan(sYear,rYear,sMonth,rMonth,snDay,rnDay,sbLastDay,rbLastDay"
+",sDay,rDay))\n"
+" {\n"
+" rYear-=1;\n"
+" setDay(rDay,rMonth,rYear,rbLastDay,rb30Days,&rnDay);\n"
+" aDate=DateToDays( rnDay,rMonth,rYear );\n"
+" }\n"
+" while(!checklessthan(sYear,rYear,sMonth,rMonth,snDay,rnDay,sbLastDay,"
+"rbLastDay,sDay,rDay))\n"
+" {\n"
+" addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,12/nFreq,&rYear);\n"
+" aDate=DateToDays( rnDay,rMonth,rYear );\n"
+" }\n"
+" return getDiff( nSettle+nNullDate,aDate,sDay,sMonth,sYear,sbLastDayMode, "
+"sbLastDay, sb30Days, sbUSMode, snDay, rDay, rMonth, rYear, rbLastDayMode, "
+"rbLastDay, rb30Days, rbUSMode, rnDay);\n"
+" }\n"
+" else\n"
+" return coupdays_new(nSettle,nMat,nFreq,nBase)- coupdaybs_new( nSettle,"
+"nMat,nFreq,nBase);\n"
+"}\n";
+
std::string checklessthanDecl=
"int checklessthan(int aYear,int bYear,int aMonth,int bMonth,int anDay,int "
"bnDay,int abLastDay,int bbLastDay,int anOrigDay,int bnOrigDay);\n";
@@ -904,6 +1017,15 @@ std::string coupnum=
" int nNullDate=GetNullDate();\n"
" return lcl_Getcoupnum(nNullDate,nSettle,nMat,nFreq);\n"
"}\n";
+std::string coupnum_newDecl=
+"double coupnum_new( int nSettle,int nMat,int nFreq,int nBase);\n";
+
+std::string coupnum_new=
+"double coupnum_new( int nSettle,int nMat,int nFreq,int nBase)\n"
+"{\n"
+" int nNullDate=693594;\n"
+" return lcl_Getcoupnum_new(nNullDate,nSettle,nMat,nFreq,nBase);\n"
+"}\n";
std::string getPrice_Decl=
"double getPrice_(int nSettle, int nMat, double fRate, double fYield,\n"
@@ -928,6 +1050,29 @@ std::string getPrice_=
" fRet += fT1 / pow( fT2, fK + fDSC_E );\n"
" return fRet;\n"
"}\n";
+std::string getPrice_new_Decl=
+"double getPrice_(int nSettle, int nMat, double fRate, double fYield,\n"
+ "double fRedemp, int nFreq, int nBase );\n";
+
+
+std::string getPrice_new=
+"double getPrice_(int nSettle, int nMat, double fRate, double fYield,\n"
+ "double fRedemp, int nFreq, int nBase )\n"
+"{\n"
+" double fFreq = nFreq;\n"
+" double fE = coupdays_new( nSettle, nMat, nFreq, nBase );\n"
+" double fDSC_E = coupdaysnc_new( nSettle, nMat, nFreq, nBase ) / fE;\n"
+" double fN = coupnum_new( nSettle, nMat, nFreq, nBase );\n"
+" double fA = coupdaybs_new( nSettle, nMat, nFreq, nBase );\n"
+" double fRet = fRedemp / ( pow( 1.0 + fYield / fFreq, fN - 1.0 + "
+"fDSC_E ) );\n"
+" fRet -= 100.0 * fRate / fFreq * fA / fE;\n"
+" double fT1 = 100.0 * fRate / fFreq;\n"
+" double fT2 = 1.0 + fYield / fFreq;\n"
+" for( double fK = 0.0 ; fK < fN ; fK+=1.0 )\n"
+" fRet += fT1 / pow( fT2, fK + fDSC_E );\n"
+" return fRet;\n"
+"}\n";
std::string getYield_Decl=
"double getYield_( int nNullDate, int nSettle, int nMat, double fCoup,"
commit e38a0b01ca1a94078e6745c544a2e2a029fce5b0
Author: xinjiang <xinjiang at multicorewareinc.com>
Date: Tue Dec 24 13:48:07 2013 +0800
GPU Calc: Fix the precision of the Financial formula DISC
AMLOEXT-384
Change-Id: I01c6944d8cf84aba5870d80ff74ca38da0915487
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 49a383d..7237497 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -291,10 +291,8 @@ void OpDISC::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
decls.insert(GetYearFrac_newDecl);decls.insert(DaysToDate_newDecl);
- decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
funs.insert(GetYearFrac_new);funs.insert(DaysToDate_new);
- funs.insert(GetNullDate);funs.insert(DateToDays);
funs.insert(DaysInMonth);funs.insert(IsLeapYear);
}
@@ -357,10 +355,10 @@ void OpDISC::GenSlidingWindowFunction(std::stringstream& ss,
ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
#endif
}
- ss << " int nNullDate = GetNullDate();\n";
+ ss << " int nNullDate = 693594;\n";
ss << " tmp = 1.0 - arg2 / arg3;\n";
- ss << " tmp /= ";
- ss << "GetYearFrac_new(nNullDate, (int)arg0, (int)arg1, (int)arg4);\n";
+ ss << " tmp /=";
+ ss << " GetYearFrac_new(nNullDate, (int)arg0, (int)arg1, (int)arg4);\n";
ss << " return tmp;\n";
ss << "}";
}
commit c6a035a2a5259bea7da3867300471182b3e38ed2
Author: mingli <mingli at multicorewareinc.com>
Date: Tue Dec 24 13:39:24 2013 +0800
GPU Calc: unit test cases for AVEDEV
Turn NO_FALLBACK_TO_SWINTERP on in formulagroupcl.cxx for test
AMLOEXT-379 BUG
Change-Id: I575c5f1c2f4648232cdf4982514f0d2571fa139d
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/xls/opencl/statistical/Avedev.xls b/sc/qa/unit/data/xls/opencl/statistical/Avedev.xls
new file mode 100644
index 0000000..d085313
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Avedev.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 225e297..4103dad 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -285,6 +285,7 @@ public:
void testMathFormulaSumIf();
void testAddInFormulaBesseLJ();
void testNegSub();
+ void testStatisticalFormulaAvedev();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -501,6 +502,7 @@ public:
CPPUNIT_TEST(testMathFormulaSumIf);
CPPUNIT_TEST(testAddInFormulaBesseLJ);
CPPUNIT_TEST(testNegSub);
+ CPPUNIT_TEST(testStatisticalFormulaAvedev);
CPPUNIT_TEST_SUITE_END();
private:
@@ -5893,7 +5895,32 @@ void ScOpenclTest::testAddInFormulaBesseLJ()
xDocSh->DoClose();
xDocShRes->DoClose();
}
-//[AMLOEXT-381]
+//AMLOEXT-379
+void ScOpenclTest::testStatisticalFormulaAvedev()
+{
+ if (!detectOpenCLDevice())
+ return;
+
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/Avedev.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Avedev.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 19; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(3,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(3,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
+
+//[AMLOEXT-383]
void ScOpenclTest::testNegSub()
{
if (!detectOpenCLDevice())
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 62e4b57..8d6ff63c 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1506,6 +1506,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocSecantHyp:
case ocSumIf:
case ocNegSub:
+ case ocAveDev:
// Don't change the state.
break;
default:
commit fb68fb3c64ae1b1a9811b7fed434dfc31015940d
Author: mingli <mingli at multicorewareinc.com>
Date: Tue Dec 24 13:41:55 2013 +0800
GPU Calc: implemented AVEDEV
AMLOEXT-379 FIX
Change-Id: I31fadbc5e96759d988d096c93429cdc22923a0a7
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 6045b25..4ae6fef 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2612,6 +2612,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpNegSub));
break;
+ case ocAveDev:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpAveDev));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index a98a08e..858de87 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -11326,7 +11326,128 @@ void OpStDevPA::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return sqrt(vSum * pow(fCount,-1.0));\n";
ss << "}\n";
}
-
+void OpAveDev:: 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 <<"{\n";
+ ss << " int gid0 = get_global_id(0);\n";
+ ss << " double sum=0.0;\n";
+ ss << " double length;\n";
+ ss << " double totallength=0;\n";
+ ss << " double tmp = 0;\n";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " length="<<nCurWindowSize;
+ ss << ";\n";
+ ss << " for (int i = ";
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+ ss << " double arg"<<i<<" = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(isNan(arg"<<i<<")||((gid0+i)>=";
+ ss << pDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " {\n";
+ ss << " length-=1.0;\n";
+ ss << " continue;\n";
+ ss << " }\n";
+#endif
+ ss << " sum += arg"<<i<<";\n";
+ ss << " }\n";
+ ss << " totallength +=length;\n";
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+ ss << " tmp = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(!isNan(tmp))\n";
+ ss << " {\n";
+ ss << " sum += tmp;\n";
+ ss << " totallength +=1;\n";
+ ss << " }\n";
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+ ss << " tmp = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " sum += tmp;\n";
+ ss << " totallength +=1;\n";
+ }
+ }
+ ss << " double mean = sum * pow(totallength,-1);\n";
+ ss << " sum = 0.0;\n";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+ ss << " double arg"<<i<<" = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(isNan(arg"<<i<<")||((gid0+i)>=";
+ ss << pDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " {\n";
+ ss << " continue;\n";
+ ss << " }\n";
+#endif
+ ss << " sum += fabs(arg"<<i<<"-mean);\n";
+ ss << " }\n";
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+ ss << " tmp = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(!isNan(tmp))\n";
+ ss << " {\n";
+ ss << " sum += fabs(tmp-mean);\n";
+ ss << " }\n";
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+ ss << " tmp = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " sum += fabs(tmp-mean);\n";
+ }
+ }
+ ss << " tmp=sum*pow(totallength,-1);\n";
+ ss << " return tmp;\n";
+ ss << "}";
+}
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index cdbc866..19b33eb 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -533,6 +533,14 @@ public:
virtual bool takeString() const { return true; }
virtual bool takeNumeric() const { return true; }
};
+class OpAveDev: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "AveDev"; }
+};
+
}}
#endif
commit 60ae598d537c14283109e1c6de22ec43a0147bcf
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Tue Dec 24 13:14:56 2013 +0800
GPU Calc: Optimized RANDOM
AMLOEXT-260
Change-Id: I3fd0a857a476a34401cfa522f828bed3bb79c9e2
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 9c16ab7..6045b25 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -291,10 +291,7 @@ public:
}
virtual void GenDeclRef(std::stringstream &ss) const
{
- double d;
- srand((unsigned)time(NULL));
- d=((double)rand())/RAND_MAX;
- ss << d;
+ ss << mSymName;
}
virtual void GenSlidingWindowDecl(std::stringstream &ss) const
{
@@ -302,7 +299,27 @@ public:
}
virtual std::string GenSlidingWindowDeclRef(bool=false) const
{
- return mSymName;
+ return mSymName + "_Random()";
+ }
+ void GenSlidingWindowFunction(std::stringstream &ss)
+ {
+ ss << "\ndouble " << mSymName;
+ ss << "_Random ()\n{\n";
+ ss << " int i, gid0=get_global_id(0);;\n";
+ ss << " double tmp = 0;\n";
+ ss << " double M = 2147483647;\n";
+ ss << " double Lamda = 32719;\n";
+ ss << " double f;\n";
+ ss << " f = gid0 + 1;\n";
+ ss << " int k;\n";
+ ss << " for(i = 1;i <= 100; ++i){\n";
+ ss << " f = Lamda * f;\n";
+ ss << " k = (int)(f * pow(M,-1.0));\n";
+ ss << " f = f - M * k;\n";
+ ss << " }\n";
+ ss << " tmp = f * pow(M,-1.0);\n";
+ ss << " return tmp;\n";
+ ss << "}";
}
virtual size_t GetWindowSize(void) const
{
commit b8bbde02a51a952ee268ed818d6201d6b5c57ec6
Author: haochen <haochen at multicorewareinc.com>
Date: Tue Dec 24 12:05:27 2013 +0800
GPU Calc: unit test cases for NEGSUB
turn NO_FALLBACK_TO_SWINTERP on in formulagroupcl.cxx for test
AMLOEXT-383 BUG
Change-Id: I6d800f22a452de063fefd02adf8da82c8920fe36
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/xls/opencl/math/NegSub.xls b/sc/qa/unit/data/xls/opencl/math/NegSub.xls
new file mode 100644
index 0000000..3379510
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/NegSub.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 2be46ca..225e297 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -284,6 +284,7 @@ public:
void testMathFormulaQuotient();
void testMathFormulaSumIf();
void testAddInFormulaBesseLJ();
+ void testNegSub();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -499,6 +500,7 @@ public:
CPPUNIT_TEST(testMathFormulaSeriesSum);
CPPUNIT_TEST(testMathFormulaSumIf);
CPPUNIT_TEST(testAddInFormulaBesseLJ);
+ CPPUNIT_TEST(testNegSub);
CPPUNIT_TEST_SUITE_END();
private:
@@ -5891,6 +5893,32 @@ void ScOpenclTest::testAddInFormulaBesseLJ()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-381]
+void ScOpenclTest::testNegSub()
+{
+ if (!detectOpenCLDevice())
+ return;
+
+ ScDocShellRef xDocSh = loadDoc("opencl/math/NegSub.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/NegSub.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 0; i <= 9; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(1,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(1,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
+
ScOpenclTest::ScOpenclTest()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index af4f142..62e4b57 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1505,6 +1505,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocSecant:
case ocSecantHyp:
case ocSumIf:
+ case ocNegSub:
// Don't change the state.
break;
default:
commit 97553c98546a62fc4068169db792eaf941d93fb1
Author: haochen <haochen at multicorewareinc.com>
Date: Tue Dec 24 12:06:35 2013 +0800
GPU Calc: implemented NEGSUB
AMLOEXT-383 FIX
Change-Id: Id1d28b5a7935bf70cba191c95cc314b6f0dea9ca
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 3264cf4..9c16ab7 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2591,6 +2591,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpSumIf));
break;
+ case ocNegSub:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpNegSub));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 4e1e5f1..7db5462 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1793,6 +1793,26 @@ void OpInt::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return tmp;\n";
ss << "}";
}
+void OpNegSub::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{\n";
+ ss << " int gid0=get_global_id(0);\n";
+ ss << " int singleIndex = gid0;\n";
+ GenTmpVariables(ss,vSubArguments);
+ CheckAllSubArgumentIsNan(ss,vSubArguments);
+ ss << " return -tmp0;\n";
+ ss << "}";
+}
+
void OpRadians::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 5864161..80b3a8e 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -485,6 +485,14 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Quotient"; }
};
+class OpNegSub: public CheckVariables
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "NegSub"; }
+};
+
}}
#endif
commit 850f079075b31c9aecd2d6b296c0c5bef6738724
Author: fengzeng <fengzeng at multicorewareinc.com>
Date: Tue Dec 24 11:20:51 2013 +0800
GPU Calc: Fix bug of SIN,POWER,EXP,SQRT
AMLOEXT-380
Change-Id: I52833dea851f24797fe23e76e1b403716672b091
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index c5159f0..3264cf4 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2228,6 +2228,7 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpChiDist));
break;
+ case ocPow:
case ocPower:
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpPower));
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 3f742f8..4e1e5f1 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -826,33 +826,55 @@ void OpCscH::GenSlidingWindowFunction(
ss << "}";
}
void OpExp::GenSlidingWindowFunction(std::stringstream &ss,
- const std::string sSymName, SubArguments &vSubArguments)
+ const std::string sSymName, SubArguments &vSubArguments)
{
- FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
- formula::SingleVectorRefToken *>(tmpCur);
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
- if (i)
- ss << ",";
+ if (i) ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
- ss << ")\n{\n\t";
- ss <<"int gid0=get_global_id(0);\n\t";
- ss << "double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << ";\n\t";
+ ss << ")\n";
+ ss << "{\n";
+ ss << " int gid0=get_global_id(0);\n";
+ ss << " double arg0 = 0.0f;\n";
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ assert(tmpCur);
+ if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode())
+ {
+ if(tmpCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR=
+ dynamic_cast
+ <const formula::SingleVectorRefToken *>(tmpCur);
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
#ifdef ISNAN
- ss<< "if(isNan(arg0)||(gid0>=";
- ss<<tmpCurDVR->GetArrayLength();
- ss<<"))\n\t\t";
- ss<<"arg0 = 0;\n\t";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ")||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " { arg0 = 0.0f; }\n";
#endif
- ss << "double tmp = pow(M_E, arg0);\n\t";
- ss << "return tmp;\n";
+ }
+ else if(tmpCur->GetType() == formula::svDouble)
+ {
+ ss << " arg0=" << tmpCur->GetDouble() << ";\n";
+ }
+ }
+ else
+ {
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ }
+ ss << " return pow(M_E, arg0);\n";
ss << "}";
}
+
void OpAverageIfs::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
@@ -974,32 +996,54 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream &ss,
void OpSin::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
- FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
- formula::SingleVectorRefToken *>(tmpCur);
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
- if (i)
- ss << ",";
+ if (i) ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
ss << ")\n";
ss << "{\n";
ss << " int gid0=get_global_id(0);\n";
- ss << " double arg0 = "<< vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << ";\n";
+ ss << " double arg0 = 0.0f;\n";
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ assert(tmpCur);
+ if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode())
+ {
+ if(tmpCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR=
+ dynamic_cast
+ <const formula::SingleVectorRefToken *>(tmpCur);
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
#ifdef ISNAN
- ss << " if(isNan(arg0)||(gid0>=";
- ss << tmpCurDVR->GetArrayLength();
- ss << "))\n";
- ss << " arg0 = 0;\n";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ")||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " { arg0 = 0.0f; }\n";
#endif
- ss << " double x = arg0 * M_1_PI;\n";
- ss << " return sinpi(x);\n";
+ }
+ else if(tmpCur->GetType() == formula::svDouble)
+ {
+ ss << " arg0=" << tmpCur->GetDouble() << ";\n";
+ }
+ }
+ else
+ {
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ }
+ ss << " arg0 = arg0 * M_1_PI;\n";
+ ss << " return sinpi(arg0);\n";
ss << "}";
}
+
void OpAbs::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
@@ -1190,13 +1234,9 @@ void OpTanH::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return tmp;\n";
ss << "}";
}
-void OpPower::GenSlidingWindowFunction(
- std::stringstream &ss, const std::string sSymName,
- SubArguments &vSubArguments)
+void OpPower::GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments)
{
- FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
- formula::SingleVectorRefToken *>(tmpCur);
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
@@ -1205,32 +1245,70 @@ void OpPower::GenSlidingWindowFunction(
ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
- ss << ")\n{\n";
- ss <<" int gid0=get_global_id(0);\n";
- ss << " double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << ";\n";
- ss << " double arg1 = " << vSubArguments[1]->GenSlidingWindowDeclRef();
- ss << ";\n";
+ ss << ")\n";
+ ss << "{\n";
+ ss << " int gid0=get_global_id(0);\n";
+ ss << " double arg[2];\n";
+ for( unsigned i=0; i < vSubArguments.size(); ++i)
+ {
+ FormulaToken *tmpCur = vSubArguments[i]->GetFormulaToken();
+ assert(tmpCur);
+ if(ocPush == vSubArguments[i]->GetFormulaToken()->GetOpCode())
+ {
+ if(tmpCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* tmpCurDVR =
+ dynamic_cast<
+ const formula::DoubleVectorRefToken *>(tmpCur);
+ ss << " int i = 0;\n";
+ ss << " arg["<<i<<"] = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
#ifdef ISNAN
- ss<< " if(isNan(arg0)||(gid0>=";
- ss<<tmpCurDVR->GetArrayLength();
- ss<<"))\n";
- ss<<" arg0 = 0;\n";
- ss<< " if(isNan(arg1)||(gid0>=";
- ss<<tmpCurDVR->GetArrayLength();
- ss<<"))\n";
- ss<<" arg1 = 0;\n";
+ ss << " if(isNan(arg["<<i;
+ ss << "])||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " arg["<<i;
+ ss << "] = 0;\n";
#endif
- ss << " double tmp=pow(arg0,arg1);\n";
- ss << " return tmp;\n";
+ }
+ else if(tmpCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken* tmpCurDVR=
+ dynamic_cast<
+ const formula::SingleVectorRefToken *>(tmpCur);
+ ss << " arg["<<i<<"] = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(isNan(arg["<<i;
+ ss << "])||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " arg["<<i;
+ ss << "] = 0;\n";
+#endif
+ }
+ else if(tmpCur->GetType() == formula::svDouble)
+ {
+ ss << " arg["<<i<<"] = ";
+ ss << tmpCur->GetDouble() << ";\n";
+ }
+ }
+ else
+ {
+ ss << " arg["<<i<<"] = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ }
+ }
+ ss << " return pow(arg[0],arg[1]);\n";
ss << "}";
}
void OpSqrt::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
- FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
- formula::SingleVectorRefToken *>(tmpCur);
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
@@ -1242,16 +1320,42 @@ void OpSqrt::GenSlidingWindowFunction(std::stringstream &ss,
ss << ")\n";
ss << "{\n";
ss << " int gid0=get_global_id(0);\n";
- ss << " double arg0 = "<< vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << ";\n";
+ ss << " double arg0 = 0.0f;\n";
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ assert(tmpCur);
+ if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode())
+ {
+ if(tmpCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR=
+ dynamic_cast
+ <const formula::SingleVectorRefToken *>(tmpCur);
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
#ifdef ISNAN
- ss << " if(isNan(arg0)||(gid0>=";
- ss << tmpCurDVR->GetArrayLength();
- ss << "))\n";
- ss << " arg0 = 0;\n";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ")||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " { arg0 = 0; }\n";
#endif
- ss << " double tmp=sqrt(arg0);\n";
- ss << " return tmp;\n";
+ }
+ else if(tmpCur->GetType() == formula::svDouble)
+ {
+ printf("const\n");
+ ss << " arg0=";
+ ss << tmpCur->GetDouble() << ";\n";
+ }
+ }
+ else
+ {
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ }
+ ss << " return sqrt(arg0);\n";
ss << "}";
}
void OpArcCot::GenSlidingWindowFunction(std::stringstream &ss,
More information about the Libreoffice-commits
mailing list