diff options
author | mingli <mingli@multicorewareinc.com> | 2013-12-20 12:24:57 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-12-23 16:51:30 -0600 |
commit | 905c02ffee26587db76e0067458740ecc4b9e39d (patch) | |
tree | bcff94e14aa2f7ccb8f29cb3e5703c3c8beca9f1 /sc/source | |
parent | 31aafc3fff19c80ca0b41a8f9cb914a1b9a5c959 (diff) |
GPU Calc: Optimized GAMMADIST
AMLOEXT-278 FIX
Change-Id: I59bf06c1e8ef138e08a7699fa167034442780322
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei@multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/opencl/op_statistical.cxx | 150 |
1 files changed, 90 insertions, 60 deletions
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx index df92b8bc770a..8275aaac70dc 100644 --- a/sc/source/core/opencl/op_statistical.cxx +++ b/sc/source/core/opencl/op_statistical.cxx @@ -6562,71 +6562,101 @@ void OpGammaDist::BinInlineFun(std::set<std::string>& decls, void OpGammaDist::GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { - 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 << "\ndouble " << sSymName; - ss << "_"<< BinFuncName() <<"("; - for (unsigned i = 0; i < vSubArguments.size(); i++) + ss << "\ndouble " << sSymName; + ss << "_"<< BinFuncName() <<"("; + for (unsigned i = 0; i < vSubArguments.size(); i++) + { + if (i) + ss << ","; + vSubArguments[i]->GenSlidingWindowDecl(ss); + } + ss << ") {\n"; + ss << " int gid0=get_global_id(0);\n"; + ss << " double tmp;\n"; + ss << " double arg0,arg1,arg2,arg3;\n"; + size_t i = vSubArguments.size(); + size_t nItems = 0; + for (i = 0; i < vSubArguments.size(); i++) + { + FormulaToken *pCur = vSubArguments[i]->GetFormulaToken(); + assert(pCur); + if (pCur->GetType() == formula::svDoubleVectorRef) { - if (i) - ss << ","; - vSubArguments[i]->GenSlidingWindowDecl(ss); - } - ss << ") {\n"; - ss << " int gid0=get_global_id(0);\n"; - ss << " double arg0 = "; - ss << vSubArguments[0]->GenSlidingWindowDeclRef(); - ss << ";\n"; - ss << " double arg1 = "; - ss << vSubArguments[1]->GenSlidingWindowDeclRef(); - ss << ";\n"; - ss << " double arg2 = "; - ss << vSubArguments[2]->GenSlidingWindowDeclRef(); - ss << ";\n"; - ss << " double arg3 = "; - ss << vSubArguments[3]->GenSlidingWindowDeclRef(); - ss << ";\n"; - ss << " double tmp;\n"; -#ifdef ISNAN - ss << " if(isNan(arg0)||(gid0>="; - ss << tmpCurDVR0->GetArrayLength(); - ss << "))\n"; - ss << " arg0 = 0;\n"; + 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 -#ifdef ISNAN - ss << " if(isNan(arg1)||(gid0>="; - ss << tmpCurDVR1->GetArrayLength(); - ss << "))\n"; - ss << " arg1 = 0;\n"; + } 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 -#ifdef ISNAN - ss << " if(isNan(arg2)||(gid0>="; - ss << tmpCurDVR2->GetArrayLength(); - ss << "))\n"; - ss << " arg2 = 0;\n"; + } 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 -#ifdef ISNAN - ss << " if(isNan(arg3)||(gid0>="; - ss << tmpCurDVR3->GetArrayLength(); - ss << "))\n"; - ss << " arg3 = 0;\n"; + } + else { +#ifdef ISNAN + ss << "0; i < "<< nCurWindowSize << "; i++){\n"; +#else + ss << "0; i < "<< nCurWindowSize << "; i++)\n"; #endif - ss << " if (arg3)\n"; - ss << " tmp=GetGammaDist( arg0, arg1, arg2);\n"; - ss << " else\n"; - ss << " tmp=GetGammaDistPDF( arg0, arg1, arg2);\n"; - ss << " return tmp;\n"; - ss << "}\n"; + } + 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"; + ss << " {\n"; + ss << " if (isNan("; + ss << vSubArguments[i]->GenSlidingWindowDeclRef(); + ss << "))\n"; + ss << " arg"<<i<<"= 0;\n"; + ss << " else\n"; + ss << " arg"<<i<<"="; + ss<<vSubArguments[i]->GenSlidingWindowDeclRef(); + ss << ";\n"; + ss << " }\n"; + ss << " else\n"; + ss << " arg"<<i<<"= 0;\n"; +#endif + } + else if (pCur->GetType() == formula::svDouble) + { +#ifdef ISNAN + ss << " if (isNan("; + ss << vSubArguments[i]->GenSlidingWindowDeclRef(); + ss << "))\n"; + ss << " arg"<<i<<"= 0;\n"; + ss << " else\n"; + ss << " arg"<<i<<"="; + ss <<vSubArguments[i]->GenSlidingWindowDeclRef(); + ss << ";\n"; +#endif + } + } + ss << " if (arg3)\n"; + ss << " tmp=GetGammaDist( arg0, arg1, arg2);\n"; + ss << " else\n"; + ss << " tmp=GetGammaDistPDF( arg0, arg1, arg2);\n"; + ss << " return tmp;\n"; + ss << "}\n"; } void OpChiDist::BinInlineFun(std::set<std::string>& decls, std::set<std::string>& funs) |