Kaydet (Commit) 3e040287 authored tarafından mulei's avatar mulei Kaydeden (comit) I-Jui (Ray) Sung

GPU Calc: implement for PRICE

AMLOEXT-63 FIX

Change-Id: I97271c8cd05347e0c9179d509f8985d5f4c5f276
Signed-off-by: 's avatarhaochen <haochen@multicorewareinc.com>
Signed-off-by: 's avatarI-Jui (Ray) Sung <ray@multicorewareinc.com>
üst b1dbb2d2
...@@ -1127,6 +1127,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( ...@@ -1127,6 +1127,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
{ {
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpINTRATE)); mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpINTRATE));
} }
else if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getPrice"))))
{
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpPrice));
}
break; break;
default: default:
throw UnhandledToken(pChild, "unhandled opcode"); throw UnhandledToken(pChild, "unhandled opcode");
......
...@@ -2106,6 +2106,147 @@ void OpPMT::GenSlidingWindowFunction(std::stringstream &ss, ...@@ -2106,6 +2106,147 @@ void OpPMT::GenSlidingWindowFunction(std::stringstream &ss,
ss<<") / ( (abl-1.0)/tmp0);\n "; ss<<") / ( (abl-1.0)/tmp0);\n ";
ss << "return tmp;\n"; ss << "return tmp;\n";
ss << "}"; 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);
}
void OpPrice::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
ArgVector argVector;
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<<"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 ";
unsigned i = vSubArguments.size();
size_t nItems = 0;
ss <<"\n ";
//while (i-- > 1)
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)
{
#ifdef ISNAN
const formula::SingleVectorRefToken* pSVR =
dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n ";
#else
nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
{
#ifdef ISNAN
ss << "{\n ";
#endif
nItems += 1;
}
else
{
#ifdef ISNAN
#endif
nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
{
ss << "if (isNan(";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << "))\n ";
ss << "tmp"<<i<<"= 0;\n ";
ss << "else\n ";
ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
ss << ";\n }\n ";
}
else
{
ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
ss <<";\n ";
}
#else
ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
ss <<";\n ";
#endif
}
ss << "tmp = getPrice_(tmp0,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6);\n\t";
ss << "return tmp;\n";
ss << "}";
} }
void OpPPMT::BinInlineFun(std::set<std::string>& decls, void OpPPMT::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs) std::set<std::string>& funs)
......
...@@ -253,6 +253,14 @@ public: ...@@ -253,6 +253,14 @@ public:
const std::string sSymName, SubArguments &vSubArguments); const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "PMT"; } virtual std::string BinFuncName(void) const { return "PMT"; }
}; };
class OpPrice: 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 "Price"; }
};
class OpPPMT: public Normal class OpPPMT: public Normal
{ {
......
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