diff options
author | dechuang <dechuang@multicorewareinc.com> | 2013-11-08 09:27:58 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-14 14:09:43 -0600 |
commit | 27097337431ee4db3cf88f80c94817c91bb76dee (patch) | |
tree | a890b38b0feffc87f2fffd453995a852130afd26 | |
parent | 99910c63f77be475eb8481825ec38c74c6873e52 (diff) |
GPU Calc: implemented ODD
AMLOEXT-153 FIX
Change-Id: I97b823f3d31879a7b79456fd0a5c3696957795f9
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_math.cxx | 42 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.hxx | 7 | ||||
-rw-r--r-- | sc/source/core/opencl/opinlinefun_math.hxx | 26 |
4 files changed, 78 insertions, 1 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 8305686d04ee..507fe7d528da 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1224,6 +1224,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpPower)); break; + case ocOdd: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i], new OpOdd)); + 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 2ed358dee34b..671cb2f59788 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -16,6 +16,7 @@ #include "compiler.hxx" #include "interpre.hxx" #include "formula/vectortoken.hxx" +#include "opinlinefun_math.hxx" #include <sstream> using namespace formula; @@ -747,7 +748,46 @@ void OpRound::GenSlidingWindowFunction(std::stringstream &ss, ss << " return tmp;\n"; ss << "}"; } - +void OpOdd::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 << Math_Intg_Str; + 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 << " double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef(); + ss << ";\n"; +#ifdef ISNAN + ss<< " if(isNan(arg0)||(gid0>="; + ss<<tmpCurDVR->GetArrayLength(); + ss<<"))\n"; + ss<<" arg0 = 0;\n"; +#endif + ss << " if (arg0 > 0.0 ){\n"; + ss << " tmp=Intg(arg0);\n"; + ss << " if(tmp-trunc(tmp/2)*2 == 0)\n"; + ss << " tmp=tmp+1;\n"; + ss << " }else if (arg0 < 0.0 ){\n"; + ss << " tmp=Intg(arg0);\n"; + ss << " if(tmp-trunc(tmp/2)*2 == 0)\n"; + ss << " tmp=tmp-1.0;\n"; + ss << " }else if (arg0 == 0.0 )\n"; + ss << " tmp=1.0;\n"; + ss << " return tmp;\n"; + ss << "}"; +} }} diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx index af4b98d8bc18..c1feb0352122 100644 --- a/sc/source/core/opencl/op_math.hxx +++ b/sc/source/core/opencl/op_math.hxx @@ -190,6 +190,13 @@ public: const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "Power"; } }; +class OpOdd: public Normal +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string BinFuncName(void) const { return "Odd"; } +}; }} #endif diff --git a/sc/source/core/opencl/opinlinefun_math.hxx b/sc/source/core/opencl/opinlinefun_math.hxx new file mode 100644 index 000000000000..ebc98777a57a --- /dev/null +++ b/sc/source/core/opencl/opinlinefun_math.hxx @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef SC_OPENCL_OPINLINFUN_MATH +#define SC_OPENCL_OPINLINFUN_MATH + +std::string Math_Intg_Str= +"\ndouble Intg(double n)\n\ +{\n\ + if(trunc(n)==n )\n\ + return n;\n\ + else if(n<0)\n\ + return trunc(n)-1;\n\ + else\n\ + return trunc(n)+1;\n\ +}\n"; + +#endif //SC_OPENCL_OPINLINFUN_MATH + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |