diff options
author | yiming ju <yiming@multicorewareinc.com> | 2013-11-09 18:36:25 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-14 19:58:33 -0600 |
commit | 25ed52d2671a630b7be22c8019fa1bc333618982 (patch) | |
tree | 03aea519800591c34435fa91927c5eeed88df61e /sc | |
parent | 5b5638007226181fc01aba33ecb2fd198366d26f (diff) |
GPU Calc: implemented COUNTIF
AMLOEXT-176 FIX
Change-Id: Idc66b7cbd3b4c05a8a6c5ad3d7885c7facc0d8f6
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.cxx | 64 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.hxx | 7 |
3 files changed, 75 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 925b4aea1b6c..2ec90e17165b 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1277,6 +1277,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],new OpAverageIfs)); break; + case ocCountIfs: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i],new OpCountIfs)); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx index f806544d4c92..adf5af0bd231 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -167,6 +167,70 @@ void OpCsc::GenSlidingWindowFunction( ss << "return tmp;\n"; ss << "}"; } +void OpCountIfs::GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments) +{ + FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= dynamic_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + size_t nCurWindowSize = pCurDVR->GetArrayLength() < + pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength(): + pCurDVR->GetRefRowSize() ; + ss << "\ndouble " << sSymName; + ss << "_"<< BinFuncName() <<"("; + for (unsigned i = 0; i < vSubArguments.size(); i++) + { + if (i) + ss << ","; + vSubArguments[i]->GenSlidingWindowDecl(ss); + } + ss << ")\n {\n"; + ss <<" int gid0=get_global_id(0);\n"; + ss << " double tmp =0;\n"; + ss << " int i ;\n"; + GenTmpVariables(ss,vSubArguments); + ss << " for (i = "; + if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) { + ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n"; + } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) { + ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n"; + } else { + ss << "0; i < "<< nCurWindowSize <<"; i++)\n"; + } + ss << " {\n"; + if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) + { + ss<< " int doubleIndex =i+gid0;\n"; + }else + { + ss<< " int doubleIndex =i;\n"; + } + ss<< " int singleIndex =gid0;\n"; + int m=0; + for(unsigned j=0;j<vSubArguments.size();j+=2,m++) + { + CheckSubArgumentIsNan(ss,vSubArguments,j); + CheckSubArgumentIsNan(ss,vSubArguments,j+1); + ss <<" if(isequal("; + ss <<"tmp"; + ss <<j; + ss <<" , "; + ss << "tmp"; + ss << j+1; + ss << ")){\n"; + } + ss << " tmp =tmp +1;\n"; + for(unsigned j=0;j<=vSubArguments.size();j+=2,m--) + { + for(int n = 0;n<m+1;n++) + { + ss << " "; + } + ss<< "}\n"; + } + ss << "return tmp;\n"; + ss << "}"; +} void OpSumIfs::GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx index 12458e11248a..b7aec25157ab 100644 --- a/sc/source/core/opencl/op_math.hxx +++ b/sc/source/core/opencl/op_math.hxx @@ -232,6 +232,13 @@ public: const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "AverageIfs"; } }; +class OpCountIfs: public CheckVariables +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string BinFuncName(void) const { return "CountIfs"; } +}; }} #endif |