[Libreoffice-commits] core.git: Branch 'private/kohei/calc-group-interpreter-4-dynamic-kernels-reviewed' - 3 commits - sc/Library_scopencl.mk sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Oct 29 21:53:06 CET 2013
sc/Library_scopencl.mk | 1
sc/source/core/opencl/formulagroupcl.cxx | 44 ++++-----
sc/source/core/opencl/op_financial.cxx | 5 -
sc/source/core/opencl/op_math.cxx | 5 -
sc/source/core/opencl/op_statistical.cxx | 5 -
sc/source/core/opencl/opbase.cxx | 107 +++++++++++++++++++++++
sc/source/core/opencl/opbase.hxx | 141 ++++++++-----------------------
7 files changed, 173 insertions(+), 135 deletions(-)
New commits:
commit 27de26f8bec9c6106fa92e4c50e05af6b1baa6e7
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 29 16:54:30 2013 -0400
We don't need these headers.
Change-Id: I8411b605edd27105bdc6cfc04acbd5cd9999e886
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 04d505a..5ae04ff 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -16,12 +16,8 @@
#include "compiler.hxx"
#include "interpre.hxx"
#include "formula/vectortoken.hxx"
-#include <list>
-#include <iostream>
#include <sstream>
-#include <algorithm>
-#include <memory>
using namespace formula;
namespace sc { namespace opencl {
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 83f780a..33ca0e5 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -16,12 +16,8 @@
#include "compiler.hxx"
#include "interpre.hxx"
#include "formula/vectortoken.hxx"
-#include <list>
-#include <iostream>
#include <sstream>
-#include <algorithm>
-#include <memory>
using namespace formula;
namespace sc { namespace opencl {
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index ec816c2..134a0ca 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -16,11 +16,7 @@
#include "compiler.hxx"
#include "interpre.hxx"
#include "formula/vectortoken.hxx"
-#include <list>
-#include <iostream>
#include <sstream>
-#include <algorithm>
-#include <memory>
using namespace formula;
commit 4ab0aa496709bf4386caf0d3a6f0d7fd160b198d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 29 16:52:01 2013 -0400
std::shared_ptr is C++11 specific. Use boost::shared_ptr instead.
Change-Id: I8e6780ae5b5042a0521687f3a3535e74d7a35d23
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 665f822..1dd7c89 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -93,7 +93,7 @@ class ConstStringArgument: public DynamicKernelArgument
{
public:
ConstStringArgument(const std::string &s,
- std::shared_ptr<FormulaTreeNode> ft):
+ boost::shared_ptr<FormulaTreeNode> ft):
DynamicKernelArgument(s, ft) {}
/// Generate declaration
virtual void GenDecl(std::stringstream &ss) const
@@ -151,7 +151,7 @@ class DynamicKernelConstantArgument: public DynamicKernelArgument
{
public:
DynamicKernelConstantArgument(const std::string &s,
- std::shared_ptr<FormulaTreeNode> ft):
+ boost::shared_ptr<FormulaTreeNode> ft):
DynamicKernelArgument(s, ft) {}
/// Generate declaration
virtual void GenDecl(std::stringstream &ss) const
@@ -195,7 +195,7 @@ class DynamicKernelStringArgument: public DynamicKernelArgument
{
public:
DynamicKernelStringArgument(const std::string &s,
- std::shared_ptr<FormulaTreeNode> ft):
+ boost::shared_ptr<FormulaTreeNode> ft):
DynamicKernelArgument(s, ft) {}
virtual void GenSlidingWindowFunction(std::stringstream &) {}
@@ -268,7 +268,7 @@ class DynamicKernelSlidingArgument: public Base
{
public:
DynamicKernelSlidingArgument(const std::string &s,
- std::shared_ptr<FormulaTreeNode> ft):
+ boost::shared_ptr<FormulaTreeNode> ft):
Base(s, ft)
{
FormulaToken *t = ft->GetFormulaToken();
@@ -664,7 +664,7 @@ public:
typedef std::unique_ptr<DynamicKernelArgument> SubArgument;
DynamicKernelSoPArguments(const std::string &s,
- std::shared_ptr<FormulaTreeNode> ft);
+ boost::shared_ptr<FormulaTreeNode> ft);
/// Create buffer and pass the buffer to a given kernel
virtual size_t Marshal(cl_kernel k, int argno, int nVectorWidth)
@@ -763,7 +763,7 @@ private:
template <class Op>
std::unique_ptr<DynamicKernelArgument> SoPHelper(const std::string &ts,
- std::shared_ptr<FormulaTreeNode> ft)
+ boost::shared_ptr<FormulaTreeNode> ft)
{
return std::unique_ptr<DynamicKernelArgument>(
new DynamicKernelSoPArguments<Op>(ts, ft));
@@ -771,7 +771,7 @@ std::unique_ptr<DynamicKernelArgument> SoPHelper(const std::string &ts,
template <class Op>
DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
- std::shared_ptr<FormulaTreeNode> ft):
+ boost::shared_ptr<FormulaTreeNode> ft):
DynamicKernelArgument(s, ft) {
size_t nChildren = ft->Children.size();
@@ -1100,12 +1100,12 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
class SymbolTable {
public:
typedef std::map<const FormulaToken *,
- std::shared_ptr<DynamicKernelArgument> > ArgumentMap;
+ boost::shared_ptr<DynamicKernelArgument> > ArgumentMap;
// This avoids instability caused by using pointer as the key type
- typedef std::list< std::shared_ptr<DynamicKernelArgument> > ArgumentList;
+ typedef std::list< boost::shared_ptr<DynamicKernelArgument> > ArgumentList;
SymbolTable(void):mCurId(0) {}
template <class T>
- const DynamicKernelArgument *DeclRefArg(std::shared_ptr<FormulaTreeNode>);
+ const DynamicKernelArgument *DeclRefArg(boost::shared_ptr<FormulaTreeNode>);
/// Used to generate sliding window helpers
void DumpSlidingWindowFunctions(std::stringstream &ss)
{
@@ -1136,7 +1136,7 @@ void SymbolTable::Marshal(cl_kernel k, int nVectorWidth)
/// Code generation
class DynamicKernel {
public:
- DynamicKernel(std::shared_ptr<FormulaTreeNode> r):mpRoot(r),
+ DynamicKernel(boost::shared_ptr<FormulaTreeNode> r):mpRoot(r),
mpProgram(NULL), mpKernel(NULL), mpResClmem(NULL) {}
/// Code generation in OpenCL
std::string CodeGen() {
@@ -1220,8 +1220,8 @@ public:
~DynamicKernel();
cl_mem GetResultBuffer(void) const { return mpResClmem; }
private:
- void TraverseAST(std::shared_ptr<FormulaTreeNode>);
- std::shared_ptr<FormulaTreeNode> mpRoot;
+ void TraverseAST(boost::shared_ptr<FormulaTreeNode>);
+ boost::shared_ptr<FormulaTreeNode> mpRoot;
SymbolTable mSyms;
std::string mKernelSignature, mKernelHash;
std::string mFullProgramSrc;
@@ -1282,7 +1282,7 @@ void DynamicKernel::CreateKernel(void)
// The template argument T must be a subclass of DynamicKernelArgument
template <typename T>
const DynamicKernelArgument *SymbolTable::DeclRefArg(
- std::shared_ptr<FormulaTreeNode> t)
+ boost::shared_ptr<FormulaTreeNode> t)
{
FormulaToken *ref = t->GetFormulaToken();
ArgumentMap::iterator it = mSymbols.find(ref);
@@ -1291,7 +1291,7 @@ const DynamicKernelArgument *SymbolTable::DeclRefArg(
std::cerr << "DeclRefArg: Allocate a new symbol:";
std::stringstream ss;
ss << "tmp"<< mCurId++;
- std::shared_ptr<DynamicKernelArgument> new_arg(new T(ss.str(), t));
+ boost::shared_ptr<DynamicKernelArgument> new_arg(new T(ss.str(), t));
mSymbols[ref] = new_arg;
mParams.push_back(new_arg);
std::cerr << ss.str() <<"\n";
@@ -1343,15 +1343,15 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
// Constructing "AST"
FormulaTokenIterator aCode = rCode;
std::list<FormulaToken *> list;
- std::map<FormulaToken *, std::shared_ptr<FormulaTreeNode>> m_hash_map;
+ std::map<FormulaToken *, boost::shared_ptr<FormulaTreeNode>> m_hash_map;
FormulaToken* pCur;
while( (pCur = (FormulaToken*)(aCode.Next()) ) != NULL)
{
OpCode eOp = pCur->GetOpCode();
if ( eOp != ocPush )
{
- std::shared_ptr<FormulaTreeNode> m_currNode =
- std::shared_ptr<FormulaTreeNode>(new FormulaTreeNode(pCur));
+ boost::shared_ptr<FormulaTreeNode> m_currNode =
+ boost::shared_ptr<FormulaTreeNode>(new FormulaTreeNode(pCur));
sal_uInt8 m_ParamCount = pCur->GetParamCount();
for(int i=0; i<m_ParamCount; i++)
{
@@ -1365,8 +1365,8 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
}
else
{
- std::shared_ptr<FormulaTreeNode> m_ChildTreeNode =
- std::shared_ptr<FormulaTreeNode>(
+ boost::shared_ptr<FormulaTreeNode> m_ChildTreeNode =
+ boost::shared_ptr<FormulaTreeNode>(
new FormulaTreeNode(m_TempFormula));
m_currNode->Children.push_back(m_ChildTreeNode);
}
@@ -1378,8 +1378,8 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
list.push_back(pCur);
}
- std::shared_ptr<FormulaTreeNode> Root =
- std::shared_ptr<FormulaTreeNode>(new FormulaTreeNode(NULL));
+ boost::shared_ptr<FormulaTreeNode> Root =
+ boost::shared_ptr<FormulaTreeNode>(new FormulaTreeNode(NULL));
Root->Children.push_back(m_hash_map[list.back()]);
// Code generation
mpKernel = new DynamicKernel(Root);
diff --git a/sc/source/core/opencl/opbase.cxx b/sc/source/core/opencl/opbase.cxx
index eef9eba..e7eae13 100644
--- a/sc/source/core/opencl/opbase.cxx
+++ b/sc/source/core/opencl/opbase.cxx
@@ -16,7 +16,7 @@ using namespace formula;
namespace sc { namespace opencl {
DynamicKernelArgument::DynamicKernelArgument(const std::string &s,
- std::shared_ptr<FormulaTreeNode> ft):
+ boost::shared_ptr<FormulaTreeNode> ft):
mSymName(s), mFormulaTree(ft), mpClmem(NULL) {}
/// Generate declaration
diff --git a/sc/source/core/opencl/opbase.hxx b/sc/source/core/opencl/opbase.hxx
index 5f17d85..a982533 100644
--- a/sc/source/core/opencl/opbase.hxx
+++ b/sc/source/core/opencl/opbase.hxx
@@ -14,6 +14,8 @@
#include "formula/token.hxx"
+#include <boost/shared_ptr.hpp>
+
#define ISNAN
namespace sc { namespace opencl {
@@ -49,7 +51,7 @@ public:
{
Children.reserve(8);
}
- std::vector<std::shared_ptr<FormulaTreeNode>> Children;
+ std::vector<boost::shared_ptr<FormulaTreeNode> > Children;
formula::FormulaToken *GetFormulaToken(void) const
{
return mpCurrentFormula;
@@ -66,7 +68,7 @@ private:
class DynamicKernelArgument
{
public:
- DynamicKernelArgument(const std::string &s, std::shared_ptr<FormulaTreeNode> ft);
+ DynamicKernelArgument(const std::string &s, boost::shared_ptr<FormulaTreeNode> ft);
const std::string &GetNameAsString(void) const { return mSymName; }
/// Generate declaration
@@ -94,7 +96,7 @@ public:
const std::string& GetName(void) const { return mSymName; }
protected:
const std::string mSymName;
- std::shared_ptr<FormulaTreeNode> mFormulaTree;
+ boost::shared_ptr<FormulaTreeNode> mFormulaTree;
// Used by marshaling
cl_mem mpClmem;
};
commit f53c5d8ca7f701be0683667e4941ad70ec44578b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 29 16:40:57 2013 -0400
Properly split opbase.hxx into header and source files.
Change-Id: I6ab5a792b5c31b44b8f302e45ec3511d3e2d6cdc
diff --git a/sc/Library_scopencl.mk b/sc/Library_scopencl.mk
index 0efe3cf..2fb8cfc 100644
--- a/sc/Library_scopencl.mk
+++ b/sc/Library_scopencl.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_Library_use_libraries,scopencl,\
$(eval $(call gb_Library_add_exception_objects,scopencl,\
sc/source/core/opencl/formulagroupcl \
sc/source/core/opencl/openclwrapper \
+ sc/source/core/opencl/opbase \
sc/source/core/opencl/op_financial \
sc/source/core/opencl/op_database \
sc/source/core/opencl/op_math \
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index a638530..04d505a 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -15,6 +15,7 @@
#include "tokenarray.hxx"
#include "compiler.hxx"
#include "interpre.hxx"
+#include "formula/vectortoken.hxx"
#include <list>
#include <iostream>
#include <sstream>
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 03fc9d3..83f780a 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -15,6 +15,7 @@
#include "tokenarray.hxx"
#include "compiler.hxx"
#include "interpre.hxx"
+#include "formula/vectortoken.hxx"
#include <list>
#include <iostream>
#include <sstream>
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 221d241..ec816c2 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -15,6 +15,7 @@
#include "tokenarray.hxx"
#include "compiler.hxx"
#include "interpre.hxx"
+#include "formula/vectortoken.hxx"
#include <list>
#include <iostream>
#include <sstream>
diff --git a/sc/source/core/opencl/opbase.cxx b/sc/source/core/opencl/opbase.cxx
new file mode 100644
index 0000000..eef9eba
--- /dev/null
+++ b/sc/source/core/opencl/opbase.cxx
@@ -0,0 +1,107 @@
+/* -*- 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 "opbase.hxx"
+
+#include "formula/vectortoken.hxx"
+
+using namespace formula;
+
+namespace sc { namespace opencl {
+
+DynamicKernelArgument::DynamicKernelArgument(const std::string &s,
+ std::shared_ptr<FormulaTreeNode> ft):
+ mSymName(s), mFormulaTree(ft), mpClmem(NULL) {}
+
+/// Generate declaration
+void DynamicKernelArgument::GenDecl(std::stringstream &ss) const
+{
+ ss << "__global double *"<<mSymName;
+}
+
+/// When declared as input to a sliding window function
+void DynamicKernelArgument::GenSlidingWindowDecl(std::stringstream &ss) const
+{
+ GenDecl(ss);
+}
+
+/// When referenced in a sliding window function
+std::string DynamicKernelArgument::GenSlidingWindowDeclRef(bool) const
+{
+ std::stringstream ss;
+ ss << mSymName << "[gid0]";
+ return ss.str();
+}
+
+/// Generate use/references to the argument
+void DynamicKernelArgument::GenDeclRef(std::stringstream &ss) const
+{
+ ss << mSymName;
+}
+
+DynamicKernelArgument::~DynamicKernelArgument()
+{
+ //std::cerr << "~DynamicKernelArgument: " << mSymName <<"\n";
+ if (mpClmem) {
+ //std::cerr << "\tFreeing cl_mem of " << mSymName <<"\n";
+ cl_int ret = clReleaseMemObject(mpClmem);
+ if (ret != CL_SUCCESS)
+ throw OpenCLError(ret);
+ }
+}
+
+FormulaToken* DynamicKernelArgument::GetFormulaToken(void) const
+{
+ return mFormulaTree->GetFormulaToken();
+}
+
+size_t DynamicKernelArgument::GetWindowSize(void) const
+{
+ FormulaToken *pCur = mFormulaTree->GetFormulaToken();
+ assert(pCur);
+ if (auto *pCurDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur))
+ {
+ return pCurDVR->GetRefRowSize();
+ } else if (dynamic_cast<const formula::SingleVectorRefToken *>(pCur))
+ {
+ // Prepare intermediate results (on CPU for now)
+ return 1;
+ } else {
+ throw Unhandled();
+ }
+ return 0;
+}
+
+void Normal::GenSlidingWindowFunction(
+ std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments)
+{
+ ArgVector argVector;
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
+ argVector.push_back(vSubArguments[i]->GenSlidingWindowDeclRef());
+ }
+ ss << ") {\n\t";
+ ss << "double tmp = " << GetBottom() <<";\n\t";
+ ss << "int gid0 = get_global_id(0);\n\t";
+ ss << "tmp = ";
+ ss << Gen(argVector);
+ ss << ";\n\t";
+ ss << "return tmp;\n";
+ ss << "}";
+}
+
+}}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/opbase.hxx b/sc/source/core/opencl/opbase.hxx
index acde3a9..5f17d85 100644
--- a/sc/source/core/opencl/opbase.hxx
+++ b/sc/source/core/opencl/opbase.hxx
@@ -10,44 +10,34 @@
#ifndef SC_OPENCL_OPBASE_HXX
#define SC_OPENCL_OPBASE_HXX
-#include "formulagroup.hxx"
-#include "document.hxx"
-#include "formulacell.hxx"
-#include "tokenarray.hxx"
-#include "compiler.hxx"
-#include "interpre.hxx"
-#include "formula/vectortoken.hxx"
-
#include "clcc/clew.h"
-#include <list>
-#include <iostream>
-#include <sstream>
-#include <algorithm>
+#include "formula/token.hxx"
-#include <memory>
#define ISNAN
-using namespace formula;
namespace sc { namespace opencl {
/// Exceptions
/// Failed in parsing
-class UnhandledToken {
+class UnhandledToken
+{
public:
- UnhandledToken(FormulaToken *t): mToken(t) {}
- FormulaToken *mToken;
+ UnhandledToken(formula::FormulaToken *t): mToken(t) {}
+ formula::FormulaToken *mToken;
};
/// Failed in marshaling
-class OpenCLError {
+class OpenCLError
+{
public:
OpenCLError(cl_int err): mError(err) {}
cl_int mError;
};
/// Inconsistent state
-class Unhandled {
+class Unhandled
+{
public:
Unhandled() {}
};
@@ -55,17 +45,17 @@ public:
class FormulaTreeNode
{
public:
- FormulaTreeNode(FormulaToken *ft): mpCurrentFormula(ft)
+ FormulaTreeNode(formula::FormulaToken *ft): mpCurrentFormula(ft)
{
Children.reserve(8);
}
std::vector<std::shared_ptr<FormulaTreeNode>> Children;
- FormulaToken *GetFormulaToken(void) const
+ formula::FormulaToken *GetFormulaToken(void) const
{
return mpCurrentFormula;
}
private:
- FormulaToken *const mpCurrentFormula;
+ formula::FormulaToken *const mpCurrentFormula;
};
/// Holds an input (read-only) argument reference to a SingleVectorRef.
@@ -73,69 +63,33 @@ private:
/// like SumOfProduct
/// In most of the cases the argument is introduced
/// by a Push operation in the given RPN.
-class DynamicKernelArgument {
+class DynamicKernelArgument
+{
public:
- DynamicKernelArgument(const std::string &s,
- std::shared_ptr<FormulaTreeNode> ft):
- mSymName(s), mFormulaTree(ft), mpClmem(NULL) {}
+ DynamicKernelArgument(const std::string &s, std::shared_ptr<FormulaTreeNode> ft);
+
const std::string &GetNameAsString(void) const { return mSymName; }
/// Generate declaration
- virtual void GenDecl(std::stringstream &ss) const
- {
- ss << "__global double *"<<mSymName;
- }
+ virtual void GenDecl(std::stringstream &ss) const;
+
/// When declared as input to a sliding window function
- virtual void GenSlidingWindowDecl(std::stringstream &ss) const
- {
- GenDecl(ss);
- }
+ virtual void GenSlidingWindowDecl(std::stringstream &ss) const;
+
/// When referenced in a sliding window function
- virtual std::string GenSlidingWindowDeclRef(bool=false) const
- {
- std::stringstream ss;
- ss << mSymName << "[gid0]";
- return ss.str();
- }
+ virtual std::string GenSlidingWindowDeclRef(bool=false) const;
+
/// Generate use/references to the argument
- virtual void GenDeclRef(std::stringstream &ss) const
- {
- ss << mSymName;
- }
+ virtual void GenDeclRef(std::stringstream &ss) const;
+
/// Create buffer and pass the buffer to a given kernel
virtual size_t Marshal(cl_kernel, int, int);
- virtual ~DynamicKernelArgument()
- {
- //std::cerr << "~DynamicKernelArgument: " << mSymName <<"\n";
- if (mpClmem) {
- //std::cerr << "\tFreeing cl_mem of " << mSymName <<"\n";
- cl_int ret = clReleaseMemObject(mpClmem);
- if (ret != CL_SUCCESS)
- throw OpenCLError(ret);
- }
- }
- virtual void GenSlidingWindowFunction(std::stringstream &) {};
+
+ virtual ~DynamicKernelArgument();
+
+ virtual void GenSlidingWindowFunction(std::stringstream &) {}
const std::string &GetSymName(void) const { return mSymName; }
- FormulaToken *GetFormulaToken(void) const
- {
- return mFormulaTree->GetFormulaToken();
- }
- virtual size_t GetWindowSize(void) const
- {
- FormulaToken *pCur = mFormulaTree->GetFormulaToken();
- assert(pCur);
- if (auto *pCurDVR =
- dynamic_cast<const formula::DoubleVectorRefToken *>(pCur))
- {
- return pCurDVR->GetRefRowSize();
- } else if (dynamic_cast<const formula::SingleVectorRefToken *>(pCur))
- {
- // Prepare intermediate results (on CPU for now)
- return 1;
- } else {
- throw Unhandled();
- }
- return 0;
- }
+ formula::FormulaToken *GetFormulaToken(void) const;
+ virtual size_t GetWindowSize(void) const;
virtual std::string DumpOpName(void) const { return std::string(""); }
const std::string& GetName(void) const { return mSymName; }
protected:
@@ -147,7 +101,8 @@ protected:
/// Abstract class for code generation
-class SlidingFunctionBase {
+class SlidingFunctionBase
+{
public:
typedef std::unique_ptr<DynamicKernelArgument> SubArgument;
typedef std::vector<SubArgument> SubArguments;
@@ -156,7 +111,8 @@ public:
virtual ~SlidingFunctionBase() {};
};
-class OpBase {
+class OpBase
+{
public:
typedef std::vector<std::string> ArgVector;
typedef std::vector<std::string>::iterator ArgVectorIter;
@@ -172,28 +128,9 @@ class Normal: public SlidingFunctionBase, public OpBase
{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
- const std::string sSymName, SubArguments &vSubArguments)
- {
- ArgVector argVector;
- ss << "\ndouble " << sSymName;
- ss << "_"<< BinFuncName() <<"(";
- for (unsigned i = 0; i < vSubArguments.size(); i++)
- {
- if (i)
- ss << ",";
- vSubArguments[i]->GenSlidingWindowDecl(ss);
- argVector.push_back(vSubArguments[i]->GenSlidingWindowDeclRef());
- }
- ss << ") {\n\t";
- ss << "double tmp = " << GetBottom() <<";\n\t";
- ss << "int gid0 = get_global_id(0);\n\t";
- ss << "tmp = ";
- ss << Gen(argVector);
- ss << ";\n\t";
- ss << "return tmp;\n";
- ss << "}";
- }
+ const std::string sSymName, SubArguments &vSubArguments);
};
+
}}
#endif
More information about the Libreoffice-commits
mailing list