From 26c759b7dfcbceb295acbb1f895847bcc4dd6cce Mon Sep 17 00:00:00 2001 From: minwang Date: Sun, 17 Nov 2013 14:38:12 +0800 Subject: GPU Calc: implemented for AND AMLOEXT-217 FIX Change-Id: I95454c6e390ddc856b9a08d1db5a7a696a3928aa Signed-off-by: haochen Signed-off-by: I-Jui (Ray) Sung --- sc/Library_scopencl.mk | 1 + sc/source/core/opencl/formulagroupcl.cxx | 5 ++ sc/source/core/opencl/op_logical.cxx | 109 +++++++++++++++++++++++++++++++ sc/source/core/opencl/op_logical.hxx | 29 ++++++++ 4 files changed, 144 insertions(+) create mode 100644 sc/source/core/opencl/op_logical.cxx create mode 100644 sc/source/core/opencl/op_logical.hxx (limited to 'sc') 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 + + +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"<GetFormulaToken(); + if(tmpCur0->GetType() == formula::svSingleVectorRef) + { +#ifdef ISNAN + const formula::SingleVectorRefToken*pCurDVR= dynamic_cast(tmpCur0); + ss<< " int buffer_len"<GetArrayLength(); + ss<< ";\n"; + ss <<" if(gid0 >= buffer_len"<GenSlidingWindowDeclRef(); + ss <<"))\n"; + ss <<" tmp = 1;\n else\n"; +#endif + ss <<" tmp = "; + ss <GenSlidingWindowDeclRef()<<";\n"; + ss <<" tmp"<GetType() == formula::svDouble) + { + ss <<" tmp = "; + ss <GenSlidingWindowDeclRef()<<";\n"; + ss <<" tmp"<GetType() == formula::svDoubleVectorRef) + { + const formula::DoubleVectorRefToken*pCurDVR= dynamic_cast(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("<GenSlidingWindowDeclRef(); + ss <<")||i+gid0>="<GetArrayLength(); + ss <<")\n"; + ss <<" tmp = 1;\n else\n"; + } + else + { + ss <<" if(isNan("<GenSlidingWindowDeclRef(); + ss <<")||i>="<GetArrayLength(); + ss <<")\n"; + ss <<" tmp = 1;\n else\n"; + } +#endif + ss <<" tmp = "; + ss <GenSlidingWindowDeclRef()<<";\n"; + ss <<" tmp"<