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

GPU Calc: implemented for PRICEDISC

AMLOEXT-65 FIX

Change-Id: Ia4dfefe0cce42f30a89a4e25366be5f8f526c471
Signed-off-by: 's avatarhaochen <haochen@multicorewareinc.com>
Signed-off-by: 's avatarI-Jui (Ray) Sung <ray@multicorewareinc.com>
üst e43592d3
......@@ -1301,6 +1301,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
new OpOddlyield));
}
else if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getPricedisc"))))
{
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpPriceDisc));
}
break;
default:
throw UnhandledToken(pChild, "unhandled opcode");
......
......@@ -2918,6 +2918,139 @@ void OpOddlyield::GenSlidingWindowFunction(std::stringstream &ss,
ss <<" return tmp;\n";
ss <<"}";
}
void OpPriceDisc::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
decls.insert(GetYearDiffDecl);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);decls.insert(GetDiffDateDecl);
funs.insert(GetYearDiff);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);funs.insert(GetDiffDate);
}
void OpPriceDisc::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<<" double tmp0=0;\n";
ss<<" double tmp1=0;\n";
ss<<" double tmp2=0;\n";
ss<<" double tmp3=0;\n";
ss<<" double tmp4=0;\n";
size_t nItems = 0;
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)
{
#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<<"=";
ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
ss << ";\n";
ss <<" }\n";
}
else
{
ss << " tmp"<<i<<"=";
ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
ss <<";\n";
}
#else
ss << " tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
ss <<";\n";
#endif
}
ss <<" int nNullDate = GetNullDate();\n";
ss <<" tmp=tmp3* ( 1.0 -tmp2*GetYearDiff( nNullDate, ";
ss <<"tmp0,tmp1,tmp4));\n";
ss <<" return tmp;\n";
ss <<"}";
}
void OpNPER::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
......
......@@ -360,6 +360,15 @@ public:
std::set<std::string>& );
virtual std::string BinFuncName(void) const { return "Oddlyield"; }
};
class OpPriceDisc: 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 "PriceDisc"; }
};
class OpPPMT: public Normal
{
public:
......
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