Kaydet (Commit) 483fb8b3 authored tarafından minwang's avatar minwang Kaydeden (comit) I-Jui (Ray) Sung

GPU Calc: implemented for COUPNCD

AMLOEXT-136 FIX

Change-Id: I53be7030bc1e0386e21fb71837677f7dadfc302f
Signed-off-by: 's avatarhaochen <haochen@multicorewareinc.com>
Signed-off-by: 's avatarI-Jui (Ray) Sung <ray@multicorewareinc.com>
üst 6b160fa3
...@@ -1317,6 +1317,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( ...@@ -1317,6 +1317,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
new OpCouppcd)); new OpCouppcd));
} }
else if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getCoupncd"))))
{
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
new OpCoupncd));
}
break; break;
default: default:
throw UnhandledToken(pChild, "unhandled opcode"); throw UnhandledToken(pChild, "unhandled opcode");
......
...@@ -3565,7 +3565,105 @@ void OpCouppcd::GenSlidingWindowFunction( ...@@ -3565,7 +3565,105 @@ void OpCouppcd::GenSlidingWindowFunction(
ss <<" return tmp;\n"; ss <<" return tmp;\n";
ss <<"}"; ss <<"}";
} }
void OpCoupncd::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(ScaDate2Decl);
decls.insert(lcl_GetCoupncdDecl);
funs.insert(IsLeapYear);funs.insert(DaysInMonth);
funs.insert(DaysToDate);funs.insert(DateToDays);
funs.insert(GetNullDate);funs.insert(ScaDate2);
funs.insert(lcl_GetCoupncd);
}
void OpCoupncd::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 << " 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";
#endif
#ifdef ISNAN
ss <<" if(gid0 >= buffer_nSettle_len || isNan(";
ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
ss <<"))\n";
ss <<" nSettle = 0;\n else\n";
#endif
ss << " nSettle=(int)";
ss << vSubArguments[0]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
ss <<" if(gid0 >= buffer_nMat_len || isNan(";
ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
ss <<"))\n";
ss <<" nMat = 0;\n else\n";
#endif
ss <<" nMat=(int)";
ss << vSubArguments[1]->GenSlidingWindowDeclRef();
ss << ";\n";
#ifdef ISNAN
ss <<" if(gid0 >= buffer_nFreq_len || isNan(";
ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
ss <<"))\n";
ss <<" nFreq = 0;\n else\n";
#endif
ss <<" nFreq=(int)";
ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
ss <<";\n";
#ifdef ISNAN
ss <<" if(gid0 >= buffer_nBase_len || isNan(";
ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
ss <<"))\n";
ss <<" nBase = 0;\n else\n";
#endif
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 <<" return tmp;\n";
ss <<"}";
}
void OpCoupdaysnc::BinInlineFun(std::set<std::string>& decls, void OpCoupdaysnc::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs) std::set<std::string>& funs)
{ {
......
...@@ -421,6 +421,16 @@ public: ...@@ -421,6 +421,16 @@ public:
}; };
class OpCoupncd:public Normal
{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments);
virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
virtual std::string BinFuncName(void) const { return "Coupncd"; }
};
class OpCoupnum:public Normal class OpCoupnum:public Normal
{ {
public: public:
......
...@@ -286,6 +286,52 @@ std::string lcl_GetCouppcd= ...@@ -286,6 +286,52 @@ std::string lcl_GetCouppcd=
" return DateToDays( nRealDay, rMonth, rYear ) - nNullDate;\n" " return DateToDays( nRealDay, rMonth, rYear ) - nNullDate;\n"
"}\n"; "}\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";
std::string lcl_GetCoupncd=
"int lcl_GetCoupncd(int nNullDate,int nSettle, int nMat,int nFreq,"
"int *bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode)\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"
" {\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"
" }\n"
" int nLastDay = DaysInMonth( rMonth, rYear );\n"
" int nRealDay = ((*bLastDayMode) && (*bLastDay)) ? nLastDay :"
"min( nLastDay, rDay );\n"
" return DateToDays( nRealDay, rMonth, rYear ) - nNullDate;\n"
"}\n";
std::string addMonthsDecl= std::string addMonthsDecl=
"void addMonths(int b30Days,int bLastDay,int *nDay,int nOrigDay," "void addMonths(int b30Days,int bLastDay,int *nDay,int nOrigDay,"
"int *nMonth,int nMonthCount,int *year);\n"; "int *nMonth,int nMonthCount,int *year);\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment