diff options
author | minwang <min@multicorewareinc.com> | 2013-11-17 14:38:12 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-17 01:03:40 -0600 |
commit | 26c759b7dfcbceb295acbb1f895847bcc4dd6cce (patch) | |
tree | 5d3f15ca32710f0a7a07de7e31ade919a3c01f45 /sc | |
parent | 42463328f5803d7d34a3bb05fbe1e24cdc02dff8 (diff) |
GPU Calc: implemented for AND
AMLOEXT-217 FIX
Change-Id: I95454c6e390ddc856b9a08d1db5a7a696a3928aa
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/Library_scopencl.mk | 1 | ||||
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/opencl/op_logical.cxx | 109 | ||||
-rw-r--r-- | sc/source/core/opencl/op_logical.hxx | 29 |
4 files changed, 144 insertions, 0 deletions
diff --git a/sc/Library_scopencl.mk b/sc/Library_scopencl.mk index 134afb81e579..2c0ac1662b43 100644 --- a/sc/Library_scopencl.mk +++ b/sc/Library_scopencl.mk @@ -43,6 +43,7 @@ $(eval $(call gb_Library_add_exception_objects,scopencl,\ sc/source/core/opencl/op_math \ sc/source/core/opencl/op_statistical \ sc/source/core/opencl/op_array \ + sc/source/core/opencl/op_logical \ sc/source/core/opencl/clcc/clew \ )) diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 36415e571945..85ebdf06dac5 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -21,6 +21,7 @@ #include "op_financial.hxx" #include "op_database.hxx" #include "op_math.hxx" +#include "op_logical.hxx" #include "op_statistical.hxx" #include "op_array.hxx" #include "formulagroupcl_public.hxx" @@ -1792,6 +1793,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpCovar)); break; + case ocAnd: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i], new OpAnd)); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) diff --git a/sc/source/core/opencl/op_logical.cxx b/sc/source/core/opencl/op_logical.cxx new file mode 100644 index 000000000000..dd455ec5cae5 --- /dev/null +++ b/sc/source/core/opencl/op_logical.cxx @@ -0,0 +1,109 @@ +/* -*- 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/. + */ + +#include "op_logical.hxx" + +#include "formulagroup.hxx" +#include "document.hxx" +#include "formulacell.hxx" +#include "tokenarray.hxx" +#include "compiler.hxx" +#include "interpre.hxx" +#include "formula/vectortoken.hxx" +#include <sstream> + + +using namespace formula; + +namespace sc { namespace opencl { +void OpAnd::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 << " int gid0 = get_global_id(0);\n"; + ss << " double t = 1,tmp=0;\n"; + for(unsigned int j = 0; j< vSubArguments.size(); j++) + { + ss << " double tmp"<<j<<" = 1;\n"; + FormulaToken *tmpCur0 = vSubArguments[j]->GetFormulaToken(); + if(tmpCur0->GetType() == formula::svSingleVectorRef) + { +#ifdef ISNAN + const formula::SingleVectorRefToken*pCurDVR= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur0); + ss<< " int buffer_len"<<j<<" = "<<pCurDVR->GetArrayLength(); + ss<< ";\n"; + ss <<" if(gid0 >= buffer_len"<<j<<" || isNan("; + ss <<vSubArguments[j]->GenSlidingWindowDeclRef(); + ss <<"))\n"; + ss <<" tmp = 1;\n else\n"; +#endif + ss <<" tmp = "; + ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n"; + ss <<" tmp"<<j<<" = tmp"<<j<<" && tmp;\n"; + } + else if(tmpCur0->GetType() == formula::svDouble) + { + ss <<" tmp = "; + ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n"; + ss <<" tmp"<<j<<" = tmp"<<j<<" && tmp;\n"; + } + else if(tmpCur0->GetType() == formula::svDoubleVectorRef) + { + const formula::DoubleVectorRefToken*pCurDVR= dynamic_cast<const + formula::DoubleVectorRefToken *>(tmpCur0); + size_t nCurWindowSize = pCurDVR->GetArrayLength() < + pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength(): + pCurDVR->GetRefRowSize() ; + ss << " for(int 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"; + } +#ifdef ISNAN + if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) + { + ss <<" if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef(); + ss <<")||i+gid0>="<<pCurDVR->GetArrayLength(); + ss <<")\n"; + ss <<" tmp = 1;\n else\n"; + } + else + { + ss <<" if(isNan("<<vSubArguments[j]->GenSlidingWindowDeclRef(); + ss <<")||i>="<<pCurDVR->GetArrayLength(); + ss <<")\n"; + ss <<" tmp = 1;\n else\n"; + } +#endif + ss <<" tmp = "; + ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n"; + ss <<" tmp"<<j<<" = tmp"<<j<<" && tmp;\n"; + ss <<" }\n"; + } + ss <<" t = t && tmp"<<j<<";\n"; + } + ss << " return t;\n"; + ss << "}\n"; +} +}} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/opencl/op_logical.hxx b/sc/source/core/opencl/op_logical.hxx new file mode 100644 index 000000000000..3015830a5daa --- /dev/null +++ b/sc/source/core/opencl/op_logical.hxx @@ -0,0 +1,29 @@ +/* -*- 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_OP_LOGICAL_HXX +#define SC_OPENCL_OP_LOGICAL_HXX + +#include "opbase.hxx" + + +namespace sc { namespace opencl { + +class OpAnd: public Normal +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string BinFuncName(void) const { return "And"; } +}; +}} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |