diff options
author | hongyu zhong <hongyu@multicorewareinc.com> | 2013-11-05 16:33:10 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-13 00:45:05 -0600 |
commit | 94eb481d26bcbeeed230d7cc9573890be9a3888f (patch) | |
tree | 21763aa94e8da78988bd72b6e071b236c1ac5272 | |
parent | GPU Calc: unit test cases for NPER (diff) | |
download | core-94eb481d26bcbeeed230d7cc9573890be9a3888f.tar.gz core-94eb481d26bcbeeed230d7cc9573890be9a3888f.zip |
GPU Calc: implemented NORMDIST
AMLOEXT-101 FIX
Change-Id: Id0e65824f63fd3d88b8092566b064719aeb11596
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 | 83 | ||||
-rw-r--r-- | sc/source/core/opencl/op_statistical.hxx | 6 |
3 files changed, 93 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index c5e967a7d433..ada65df24d34 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1080,6 +1080,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpNPER)); break; + case ocNormDist: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i],new OpNormdist)); + 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 5b61957e083c..f1758b5cbf22 100644 --- a/sc/source/core/opencl/op_statistical.cxx +++ b/sc/source/core/opencl/op_statistical.cxx @@ -938,6 +938,89 @@ void OpRsq::GenSlidingWindowFunction( ss << "return (tmp * tmp);\n"; ss << "}\n"; } +void OpNormdist::GenSlidingWindowFunction( + std::stringstream &ss, const std::string sSymName, + SubArguments &vSubArguments) +{ + 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 << " double x,mue,sigma,c;\n"; + ss << " int gid0=get_global_id(0);\n"; +#ifdef ISNAN + 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 << " int buffer_x_len = "; + ss << tmpCurDVR0->GetArrayLength(); + ss << ";\n"; + ss << " int buffer_mue_len = "; + ss << tmpCurDVR1->GetArrayLength(); + ss << ";\n"; + ss << " int buffer_sigma_len = "; + ss << tmpCurDVR2->GetArrayLength(); + ss << ";\n"; + ss << " int buffer_c_len = "; + ss << tmpCurDVR3->GetArrayLength(); + ss << ";\n"; +#endif +#ifdef ISNAN + ss <<"if((gid0)>=buffer_c_len || isNan("; + ss << vSubArguments[3]->GenSlidingWindowDeclRef(); + ss <<"))\n"; + ss <<" c = 0;\nelse \n"; +#endif + ss << " c = "<<vSubArguments[3]->GenSlidingWindowDeclRef(); + ss << ";\n"; +#ifdef ISNAN + ss <<"if((gid0)>=buffer_sigma_len || isNan("; + ss << vSubArguments[2]->GenSlidingWindowDeclRef(); + ss <<"))\n"; + ss <<" sigma = 0;\nelse \n"; +#endif + ss <<" sigma = "<<vSubArguments[2]->GenSlidingWindowDeclRef(); + ss <<";\n"; +#ifdef ISNAN + ss <<" if((gid0)>=buffer_mue_len || isNan("; + ss << vSubArguments[1]->GenSlidingWindowDeclRef(); + ss <<"))\n"; + ss <<" mue = 0;\nelse \n"; +#endif + ss <<" mue = "<<vSubArguments[1]->GenSlidingWindowDeclRef(); + ss <<";\n"; +#ifdef ISNAN + ss<<" if((gid0)>=buffer_x_len || isNan("; + ss << vSubArguments[0]->GenSlidingWindowDeclRef(); + ss<<"))\n"; + ss<<" x = 0;\nelse \n"; +#endif + ss <<" x = "<<vSubArguments[0]->GenSlidingWindowDeclRef(); + ss << ";\n"; + ss << "double mid,tmp;\n"; + ss << "mid = (x - mue)/sigma;\n"; + ss << "if(c)\n"; + ss << " tmp = 0.5 *erfc(-mid * 0.7071067811865475);\n"; + ss << "else \n"; + ss <<" tmp=(0.39894228040143268*exp(-(mid * mid)/2.0))/sigma;\n"; + ss << "return tmp;\n"; + ss << "}\n"; +} void OpMedian::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx index 87b02b9cbd17..e3e4573d3456 100644 --- a/sc/source/core/opencl/op_statistical.hxx +++ b/sc/source/core/opencl/op_statistical.hxx @@ -117,6 +117,12 @@ public: const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "OpRsq"; } }; +class OpNormdist:public Normal{ + public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string BinFuncName(void) const { return "OpNormdist"; } +}; class OpMedian:public Normal{ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, |