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

GPU Calc: implemented COUNTA

AMLOEXT-208 FIX

Change-Id: I0b66d4c9acedeeed4ffe90da7518e0c853d14ce1
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 fd4b9362
...@@ -2549,6 +2549,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( ...@@ -2549,6 +2549,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts, mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpMinA)); ft->Children[i], new OpMinA));
break; break;
case ocCount2:
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpCountA));
break;
case ocExternal: case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString( if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect")))) "com.sun.star.sheet.addin.Analysis.getEffect"))))
......
...@@ -9017,6 +9017,178 @@ void OpMinA::GenSlidingWindowFunction( ...@@ -9017,6 +9017,178 @@ void OpMinA::GenSlidingWindowFunction(
ss << " return tmp0 == 1.79769e+308 ? 0.0 : tmp0;\n"; ss << " return tmp0 == 1.79769e+308 ? 0.0 : tmp0;\n";
ss << "}\n"; ss << "}\n";
} }
void OpCountA::GenSlidingWindowFunction(
std::stringstream &ss, const std::string sSymName, SubArguments &
vSubArguments)
{
int isMixed = 0;
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 nCount = 0.0;\n";
size_t i = vSubArguments.size();
size_t nItems = 0;
ss <<"\n";
for (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);
if(pDVR->GetArrays()[0].mpNumericArray
&& pDVR->GetArrays()[0].mpStringArray)
isMixed = svDoubleVectorRefDoubleString;
else if(pDVR->GetArrays()[0].mpNumericArray)
isMixed = svDoubleVectorRefDouble;
else if(pDVR->GetArrays()[0].mpStringArray)
isMixed = svDoubleVectorRefString;
else
isMixed = svDoubleVectorRefNULL;
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);
if(pSVR->GetArray().mpNumericArray
&& pSVR->GetArray().mpStringArray)
isMixed = svSingleVectorRefDoubleString;
else if(pSVR->GetArray().mpNumericArray)
isMixed = svSingleVectorRefDouble;
else if(pSVR->GetArray().mpStringArray)
isMixed = svSingleVectorRefString;
else
isMixed = svSingleVectorRefNULL;
ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
{
#ifdef ISNAN
ss << " {\n";
isMixed = svDoubleDouble;
#endif
nItems += 1;
}
else
{
#ifdef ISNAN
#endif
nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
{
if(isMixed == svDoubleVectorRefDoubleString
|| isMixed == svSingleVectorRefDoubleString)
{
ss << " if (!isNan(";
ss << vSubArguments[i]->GenDoubleSlidingWindowDeclRef();
ss << ")){\n";
ss << " nCount+=1.0;\n";
ss << " }\n";
ss << " else if(isNan(";
ss << vSubArguments[i]->GenDoubleSlidingWindowDeclRef();
ss << ") && ";
ss<< vSubArguments[i]->GenStringSlidingWindowDeclRef();
ss << " != 0)\n";
ss << " nCount+=1.0;\n";
ss << " }\n";
}
else if(isMixed == svDoubleVectorRefDouble
|| isMixed == svSingleVectorRefDouble)
{
ss << " if (!isNan(";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << ")){\n";
ss << " nCount+=1.0;\n";
ss <<"}\n }\n";
}
else if(isMixed == svDoubleVectorRefString)
{
ss << " if (!isNan(";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << "))\n";
ss << " nCount+=1.0;\n";
ss <<"\n }\n";
}
else if(isMixed == svSingleVectorRefString)
{
ss << " if(";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << " != 0)\n";
ss << " nCount+=1.0;\n";
ss << " }\n";
}
else if(isMixed == svDoubleDouble)
{
ss << " nCount+=1.0;\n";
ss << " }\n";
}
else
{
ss << " }\n";
}
}
else
{
ss << " nCount+=1.0;\n";
ss << " }\n";
}
#else
ss << " nCount+=1.0;\n";
ss << " }\n";
#endif
}
ss << " return nCount;\n";
ss << "}\n";
}
}} }}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -469,6 +469,15 @@ public: ...@@ -469,6 +469,15 @@ public:
virtual bool takeString() const { return true; } virtual bool takeString() const { return true; }
virtual bool takeNumeric() const { return true; } virtual bool takeNumeric() const { return true; }
}; };
class OpCountA: public Normal
{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "OpCountA"; }
virtual bool takeString() const { return true; }
virtual bool takeNumeric() const { return true; }
};
}} }}
#endif #endif
......
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