diff options
author | mingli <mingli@multicorewareinc.com> | 2013-11-05 15:34:53 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-13 00:45:03 -0600 |
commit | 2df5ef3821136cad0eb930ca2698be747b24f031 (patch) | |
tree | 7b5c536286d2c1263836904717d8b56beee8ce24 | |
parent | 84a63e75caa46188f8ae88c02bf82c512d3fa146 (diff) |
GPU Calc: implemented for KURT
AMLOEXT-87 FIX
Change-Id: I5b16116f53b00619b4bbeaa358545f32297f33da
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/opencl/op_statistical.cxx | 82 | ||||
-rw-r--r-- | sc/source/core/opencl/op_statistical.hxx | 8 |
3 files changed, 92 insertions, 2 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index b56ea0f0d378..34cf5737a78c 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1072,6 +1072,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],new OpVDB)); break; + case ocKurt: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i], new OpKurt)); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx index 356b17005141..5b61957e083c 100644 --- a/sc/source/core/opencl/op_statistical.cxx +++ b/sc/source/core/opencl/op_statistical.cxx @@ -1015,7 +1015,87 @@ void OpMedian::GenSlidingWindowFunction( ss <<" return tmp;\n"; ss << "}\n"; } - +void OpKurt:: GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments) +{ + FormulaToken *pCur = vSubArguments[0]->GetFormulaToken(); + assert(pCur); + const formula::DoubleVectorRefToken* pCurDVR = + dynamic_cast<const formula::DoubleVectorRefToken *>(pCur); + size_t nCurWindowSize = pCurDVR->GetRefRowSize(); + 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 fSum = 0.0;\n"; + ss << " double vSum = 0.0;\n"; + ss << " int length="<<nCurWindowSize<<";\n"; + ss << " double tmp = 0;\n"; + ss << " for (int i = 0; i <" << nCurWindowSize << "; i++)\n"; + ss << " {\n"; + ss << " double arg0 = "; + ss<< vSubArguments[0]->GenSlidingWindowDeclRef(); + ss << ";\n"; +#ifdef ISNAN + ss<< " if(isNan(arg0)||((gid0+i)>="; + ss<<pCurDVR->GetArrayLength(); + ss<< "))\n"; + ss<< " {\n"; + ss<< " length--;\n"; + ss<< " continue;\n"; + ss<< " }\n"; +#endif + ss<< " fSum += arg0;\n"; + ss<< " }\n"; + ss<< " double fMean = fSum / length;\n"; + ss<< " for (int i = 0; i <" << nCurWindowSize << "; i++)\n"; + ss<< " {\n"; + ss<< " double arg0 = "; + ss<< vSubArguments[0]->GenSlidingWindowDeclRef(); + ss<< ";\n"; +#ifdef ISNAN + ss<< " if(isNan(arg0)||((gid0+i)>="; + ss<< pCurDVR->GetArrayLength(); + ss<< "))\n"; + ss<< " {\n"; + ss<< " continue;\n"; + ss<< " }\n"; +#endif + ss<< " vSum += (arg0 - fMean) * (arg0 - fMean);\n"; + ss<< " }\n"; + ss<< " double fStdDev = sqrt(vSum / (length - 1.0));\n"; + ss<< " double dx = 0.0;\n"; + ss<< " double xpower4 = 0.0;\n"; + ss<< " for (int i = 0; i <" << nCurWindowSize << "; i++)\n"; + ss<< " {\n"; + ss<< " double arg0 = "; + ss<< vSubArguments[0]->GenSlidingWindowDeclRef(); + ss<< ";\n"; +#ifdef ISNAN + ss<< " if(isNan(arg0)||((gid0+i)>="; + ss<< pCurDVR->GetArrayLength(); + ss<< "))\n"; + ss<< " {\n"; + ss<< " continue;\n"; + ss<< " }\n"; +#endif + ss<< " dx = (arg0 -fMean) / fStdDev;\n"; + ss<< " xpower4 = xpower4 + (dx * dx * dx * dx);\n"; + ss<< " }\n"; + ss<< " double k_d = (length - 2.0) * (length - 3.0);\n"; + ss<< " double k_l = length * (length + 1.0) /"; + ss<< "((length - 1.0) * k_d);\n"; + ss<< " double k_t = 3.0 * (length - 1.0) * (length - 1.0) / k_d;\n"; + ss<< " tmp = xpower4 * k_l - k_t;\n"; + ss<< " return tmp;\n"; + ss<< "}"; +} }} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx index 1002fa9fe198..87b02b9cbd17 100644 --- a/sc/source/core/opencl/op_statistical.hxx +++ b/sc/source/core/opencl/op_statistical.hxx @@ -123,7 +123,13 @@ class OpMedian:public Normal{ const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "OpMedian"; } }; - +class OpKurt: public Normal +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string BinFuncName(void) const { return "Kurt"; } +}; }} #endif |