diff options
author | haochen <haochen@multicorewareinc.com> | 2013-10-25 10:05:54 +0800 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-29 17:00:23 -0400 |
commit | 3c7002e105f30ad0454a4895d4e4ce329a3bb58a (patch) | |
tree | ddec68604a3201db43cc00452b8954b9bd15e858 /sc | |
parent | b8c4a34be08f0d72f6423bb41020e4e568c88a3c (diff) |
Implement fix for COS in GPU Calc
Change-Id: I2f64599a0f26366214ae99294d27606620e11046
Signed-off-by: Wei Wei <weiwei@multicorewareinc.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/OP_math.cxx | 34 | ||||
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 4 |
2 files changed, 38 insertions, 0 deletions
diff --git a/sc/source/core/opencl/OP_math.cxx b/sc/source/core/opencl/OP_math.cxx index 739444adde29..2b97bd19074a 100644 --- a/sc/source/core/opencl/OP_math.cxx +++ b/sc/source/core/opencl/OP_math.cxx @@ -14,8 +14,42 @@ #include <memory> using namespace formula; +#define ISNAN namespace sc { namespace opencl { +class OpCos: public Normal +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments) + { + FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur); + ss << "\ndouble " << sSymName; + ss << "_"<< BinFuncName() <<"("; + for (unsigned i = 0; i < vSubArguments.size(); i++) + { + if (i) + ss << ","; + vSubArguments[i]->GenSlidingWindowDecl(ss); + } + ss << ")\n{\n\t"; + ss <<"int gid0=get_global_id(0);\n\t"; + ss << "double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef(); + ss << ";\n\t"; +#ifdef ISNAN + ss<< "if(isNan(arg0)||(gid0>="; + ss<<tmpCurDVR->GetArrayLength(); + ss<<"))\n\t\t"; + ss<<"arg0 = 0;\n\t"; +#endif + ss << "double tmp=cos(arg0);\n\t"; + ss << "return tmp;\n"; + ss << "}"; + } + virtual std::string BinFuncName(void) const { return "Cos"; } +}; }} #endif
\ No newline at end of file diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 490a9fabce98..3a71a2be64a8 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -803,6 +803,10 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s, mvSubArguments.push_back(SoPHelper<OpCorrel>(ts, ft->Children[i])); break; + case ocCos: + mvSubArguments.push_back(SoPHelper<OpCos>(ts, + ft->Children[i])); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) |