From 9a4bc2541d92bf935408a08e19547bfc00e59223 Mon Sep 17 00:00:00 2001 From: mulei Date: Wed, 4 Dec 2013 16:28:30 +0800 Subject: GPU Calc: Optimized NOMINAL AMLOEXT-265 Change-Id: I497b5cd9c89fc1c1afc4091023335b7db9fc8f4b Signed-off-by: haochen Signed-off-by: Wei Wei Signed-off-by: I-Jui (Ray) Sung --- sc/source/core/opencl/op_financial.cxx | 73 ++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 22 deletions(-) (limited to 'sc/source') diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx index 016214eacd52..ccf2bf4d1b4d 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -102,7 +102,8 @@ void RRI::GenSlidingWindowFunction( } void OpNominal::GenSlidingWindowFunction( - std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) + std::stringstream &ss, const std::string sSymName, SubArguments & +vSubArguments) { ss << "\ndouble " << sSymName; ss << "_"<< BinFuncName() <<"("; @@ -114,31 +115,59 @@ void OpNominal::GenSlidingWindowFunction( } ss << ") {\n\t"; ss << "double tmp = 0;\n\t"; + ss << "double temp = 0;\n\t"; ss << "int gid0 = get_global_id(0);\n\t"; - ss <<"double tmp0 = "; - ss <GenSlidingWindowDeclRef()<<";\n\t"; - ss <<"double tmp1 = "; - ss <GenSlidingWindowDeclRef()<<";\n\t"; -#ifdef ISNAN - - FormulaToken *tmpCur0 = vSubArguments[0] - ->GetFormulaToken(); - const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast(tmpCur0); - ss<<"if("<GetArrayLength()<<"<=gid0||"; - ss <<"isNan(tmp0))\n\t\t"; - ss<<" tmp0= 0;\n\t"; - FormulaToken *tmpCur1 = vSubArguments[1] - ->GetFormulaToken(); - const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast(tmpCur1); - ss<<"if("<GetArrayLength()<<"<=gid0||"; - ss <<"isNan(tmp1))\n\t\t"; - ss<<" tmp1= 0;\n\t"; + ss << "double tmp0=0,tmp1=0;\n"; + for (unsigned i = 0; i < vSubArguments.size(); i++) + { + FormulaToken *pCur = vSubArguments[i]->GetFormulaToken(); + assert(pCur); + if (pCur->GetType() == formula::svSingleVectorRef) + { +#ifdef ISNAN + const formula::SingleVectorRefToken* pSVR = + dynamic_cast< const formula::SingleVectorRefToken* >(pCur); + ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n"; +#else +#endif + } + else if (pCur->GetType() == formula::svDouble) + { +#ifdef ISNAN + ss << "{\n"; +#endif + } + else + { +#ifdef ISNAN #endif + } +#ifdef ISNAN + if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode()) + { + ss <<" temp="<GenSlidingWindowDeclRef(); + ss <<";\n"; + ss <<" if (isNan(temp))\n"; + ss <<" tmp"<