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

GPU Calc: Optimized COUPNUM

AMLOEXT-222

Change-Id: I630a4e1d648158e66efe4efb5d671a9b1df06f6a
Signed-off-by: 's avatarhaochen <haochen@multicorewareinc.com>
Signed-off-by: 's avatarWei Wei <weiwei@multicorewareinc.com>
Signed-off-by: 's avatarI-Jui (Ray) Sung <ray@multicorewareinc.com>
üst 0389e9e1
......@@ -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,
......
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