LibreOffice Module sc (master) 1
opbase.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#pragma once
11
12#include <clew/clew.h>
13#include <formula/token.hxx>
14#include <formula/types.hxx>
16#include <opencl/OpenCLZone.hxx>
17#include <sal/log.hxx>
18#include <memory>
19#include <set>
20#include <vector>
21#include "utils.hxx"
22
23struct ScCalcConfig;
24
25namespace sc::opencl {
26
27// FIXME: The idea that somebody would bother to (now and then? once a year? once a month?) manually
28// edit a source file and change the value of some #defined constant and run some ill-defined
29// "correctness test" is of course ludicrous. Either things are checked in normal unit tests, in
30// every 'make check', or not at all. The below comments are ridiculous.
31
32#define REDUCE_THRESHOLD 201 // set to 4 for correctness testing. priority 1
33#define UNROLLING_FACTOR 16 // set to 4 for correctness testing (if no reduce)
34
35
36class FormulaTreeNode;
37
39
42{
43public:
44 UnhandledToken( const char* m, std::string fn, int ln );
45
46 std::string mMessage;
47 std::string mFile;
49};
50
53{
54public:
55 OpenCLError( std::string function, cl_int error, std::string file, int line );
56
57 std::string mFunction;
58 cl_int mError;
59 std::string mFile;
61};
62
65{
66public:
67 Unhandled( std::string fn, int ln );
68
69 std::string mFile;
71};
72
74{
75public:
76 InvalidParameterCount( int parameterCount, std::string file, int ln );
77
79 std::string mFile;
80 int const mLineNumber;
81};
82
83// Helper macros to be used in code emitting OpenCL code for Calc functions.
84// Require the vSubArguments parameter.
85#define CHECK_PARAMETER_COUNT(min, max) \
86 do { \
87 const int count = vSubArguments.size(); \
88 if( count < ( min ) || count > ( max )) \
89 throw InvalidParameterCount( count, __FILE__, __LINE__ ); \
90 } while( false )
91#define CHECK_PARAMETER_COUNT_MIN(min) \
92 do { \
93 const int count = vSubArguments.size(); \
94 if( count < ( min )) \
95 throw InvalidParameterCount( count, __FILE__, __LINE__ ); \
96 } while( false )
97#define CHECK_PARAMETER_DOUBLEVECTORREF(arg) \
98 do { \
99 formula::FormulaToken *token = vSubArguments[arg]->GetFormulaToken(); \
100 if (token == nullptr || token->GetType() != formula::svDoubleVectorRef) \
101 throw Unhandled(__FILE__, __LINE__); \
102 } while( false )
103
104typedef std::shared_ptr<FormulaTreeNode> FormulaTreeNodeRef;
105
107{
108public:
110 {
111 Children.reserve(8);
112 }
113 std::vector<FormulaTreeNodeRef> Children;
115 {
116 return const_cast<formula::FormulaToken*>(mpCurrentFormula.get());
117 }
118
119private:
121};
122
125{
126public:
129
132
133 DynamicKernelArgument( const ScCalcConfig& config, std::string s, FormulaTreeNodeRef ft );
135
137 virtual void GenDecl( outputstream& ss ) const = 0;
138
140 virtual void GenSlidingWindowDecl( outputstream& ss ) const = 0;
141
143 virtual std::string GenSlidingWindowDeclRef( bool = false ) const = 0;
144
146 virtual size_t Marshal( cl_kernel, int, int, cl_program ) = 0;
147
148 virtual size_t GetWindowSize() const = 0;
149
151 virtual std::string GenDoubleSlidingWindowDeclRef( bool = false ) const;
152
154 virtual std::string GenStringSlidingWindowDeclRef( bool = false ) const;
155
157 virtual std::string GenIsString( bool = false ) const { return "false"; }
158
160 virtual void GenDeclRef( outputstream& ss ) const;
161
162 virtual void GenSlidingWindowFunction( outputstream& );
164 virtual std::string DumpOpName() const;
165 virtual void DumpInlineFun( std::set<std::string>&, std::set<std::string>& ) const;
166 const std::string& GetName() const;
167 virtual bool NeedParallelReduction() const;
169 virtual bool IsEmpty() const { return false; }
170
171 static void ClearStringIds();
172
173protected:
175 std::string mSymName;
177 static int GetStringId( const rtl_uString* string );
178};
179
180typedef std::shared_ptr<DynamicKernelArgument> DynamicKernelArgumentRef;
181
188{
189public:
190 VectorRef( const ScCalcConfig& config, const std::string& s, const FormulaTreeNodeRef& ft, int index = 0 );
191 virtual ~VectorRef() override;
192
194 virtual void GenDecl( outputstream& ss ) const override;
196 virtual void GenSlidingWindowDecl( outputstream& ss ) const override;
197
199 virtual std::string GenSlidingWindowDeclRef( bool = false ) const override;
200
202 virtual size_t Marshal( cl_kernel, int, int, cl_program ) override;
203
204 virtual void GenSlidingWindowFunction( outputstream& ) override;
205 virtual size_t GetWindowSize() const override;
206 virtual std::string DumpOpName() const override;
207 virtual void DumpInlineFun( std::set<std::string>&, std::set<std::string>& ) const override;
208 const std::string& GetName() const;
209 cl_mem GetCLBuffer() const;
210 virtual bool NeedParallelReduction() const override;
211
212protected:
213 // Used by marshaling
214 cl_mem mpClmem;
215 // index in multiple double vector refs that have multiple ranges
216 const int mnIndex;
217 // Makes Marshall convert strings to 0 values.
219 // Used for storing when the data needs to be modified before sending to OpenCL.
220 std::vector< double > dataBuffer;
221};
222
223// Sets VectorRef::forceStringsToZero.
225{
226public:
227 VectorRefStringsToZero( const ScCalcConfig& config, const std::string& s, const FormulaTreeNodeRef& ft, int index = 0 );
228};
229
232{
233public:
234 DynamicKernelStringArgument( const ScCalcConfig& config, const std::string& s,
235 const FormulaTreeNodeRef& ft, int index = 0 ) :
236 VectorRef(config, s, ft, index) { }
237
238 virtual void GenSlidingWindowFunction( outputstream& ) override { }
240 virtual void GenDecl( outputstream& ss ) const override
241 {
242 ss << "__global double *" << mSymName;
243 }
244 virtual void GenSlidingWindowDecl( outputstream& ss ) const override
245 {
247 }
248 virtual std::string GenIsString( bool = false ) const override;
249 virtual size_t Marshal( cl_kernel, int, int, cl_program ) override;
250};
251
254{
255public:
256 DynamicKernelConstantArgument( const ScCalcConfig& config, const std::string& s,
257 const FormulaTreeNodeRef& ft ) :
260 virtual void GenDecl( outputstream& ss ) const override
261 {
262 ss << "double " << mSymName;
263 }
264 virtual void GenDeclRef( outputstream& ss ) const override
265 {
266 ss << mSymName;
267 }
268 virtual void GenSlidingWindowDecl( outputstream& ss ) const override
269 {
270 GenDecl(ss);
271 }
272 virtual std::string GenSlidingWindowDeclRef( bool = false ) const override
273 {
274 if (GetFormulaToken()->GetType() != formula::svDouble)
275 throw Unhandled(__FILE__, __LINE__);
276 return mSymName;
277 }
278 virtual size_t GetWindowSize() const override
279 {
280 return 1;
281 }
282 virtual double GetDouble() const
283 {
285 if (Tok->GetType() != formula::svDouble)
286 throw Unhandled(__FILE__, __LINE__);
287 return Tok->GetDouble();
288 }
290 virtual size_t Marshal( cl_kernel k, int argno, int, cl_program ) override
291 {
292 OpenCLZone zone;
293 double tmp = GetDouble();
294 // Pass the scalar result back to the rest of the formula kernel
295 SAL_INFO("sc.opencl", "Kernel " << k << " arg " << argno << ": double: " << preciseFloat( tmp ));
296 cl_int err = clSetKernelArg(k, argno, sizeof(double), static_cast<void*>(&tmp));
297 if (CL_SUCCESS != err)
298 throw OpenCLError("clSetKernelArg", err, __FILE__, __LINE__);
299 return 1;
300 }
301};
302
303// Constant 0 argument when a string is forced to zero.
305{
306public:
307 DynamicKernelStringToZeroArgument( const ScCalcConfig& config, const std::string& s,
308 const FormulaTreeNodeRef& ft ) :
310 virtual std::string GenSlidingWindowDeclRef( bool = false ) const override
311 {
312 return mSymName;
313 }
314 virtual double GetDouble() const override { return 0; }
315};
316
317
320{
321public:
322 // FIXME: What exactly is this? It seems to be a starting value for some calculations
323 // (1 for OpMul, MAXFLOAT for OpMin), but it's often used pointlessly and sometimes
324 // even incorrectly (default value for when the cell is empty).
325 virtual std::string GetBottom() { return "";};
326 virtual std::string Gen2( const std::string&/*lhs*/,
327 const std::string&/*rhs*/ ) const { return "";}
328 static std::string Gen( std::vector<std::string>& /*argVector*/ ) { return "";};
329 virtual std::string BinFuncName() const { return "";};
330 virtual void BinInlineFun( std::set<std::string>&,
331 std::set<std::string>& ) { }
332 virtual bool takeString() const = 0;
333 virtual bool takeNumeric() const = 0;
334 // Whether DoubleRef containing more than one column is handled properly.
335 virtual bool canHandleMultiVector() const { return false; }
336 //Continue process 'Zero' or Not(like OpMul, not continue process when meet
337 // 'Zero'
338 virtual bool ZeroReturnZero() { return false;}
339 // For use with COUNTA() etc, input strings will be converted to 0 in data.
340 virtual bool forceStringsToZero() const { return false; }
341 virtual ~OpBase() { }
342};
343
345{
346public:
347 typedef std::vector<DynamicKernelArgumentRef> SubArguments;
349 const std::string&, SubArguments& ) = 0;
350protected:
351 // This enum controls how the generated code will handle empty cells in ranges.
353 {
354 EmptyIsZero, // empty cells become 0.0
355 EmptyIsNan, // empty cells become NAN, use isnan() to check in code
356 SkipEmpty // empty cells will be skipped
357 };
358 // This enum controls whether the generated code will also include variable
359 // <name>_is_string that will be set depending on the value type.
361 {
364 };
365 void GenerateFunctionDeclaration( const std::string& sSymName,
366 SubArguments& vSubArguments, outputstream& ss );
367 // Generate code for "double <name> = <value>;" from vSubArguments, svDoubleVectorRef is not supported.
368 void GenerateArg( const char* name, int arg, SubArguments& vSubArguments, outputstream& ss,
370 // overload, variable will be named "arg<arg>"
371 void GenerateArg( int arg, SubArguments& vSubArguments, outputstream& ss,
373 // generate code for "double <name> = <value>;" from vSubArguments, if it exists,
374 // otherwise set to <def>
375 void GenerateArgWithDefault( const char* name, int arg, double def, SubArguments& vSubArguments,
377 // Generate code that will handle all arguments firstArg-lastArg (zero-based, inclusive),
378 // including range arguments (svDoubleVectorRef) and each value will be processed by 'code',
379 // value will be named "arg".
380 static void GenerateRangeArgs( int firstArg, int lastArg, SubArguments& vSubArguments,
381 outputstream& ss, EmptyArgType empty, const char* code );
382 // overload, handle all arguments
383 static void GenerateRangeArgs( SubArguments& vSubArguments, outputstream& ss,
384 EmptyArgType empty, const char* code );
385 // overload, handle the given argument
386 static void GenerateRangeArg( int arg, SubArguments& vSubArguments, outputstream& ss,
387 EmptyArgType empty, const char* code );
388 // Overload.
389 // Both arguments must be svDoubleRef of the same size.
390 // If 'firstElementDiff' is set, the loop start will be offset by '+ firstElementDiff'.
391 void GenerateRangeArg( int arg1, int arg2, SubArguments& vSubArguments,
392 outputstream& ss, EmptyArgType empty, const char* code, const char* firstElementDiff = nullptr );
393 // Generate code that will handle the given two arguments in one loop where n-th element of arg1 and arg2
394 // will be handled at the same time, named 'arg1' and 'arg2'.
395 // Both arguments must be svDoubleRef of the same size.
396 // If 'firstElementDiff' is set, the loop start will be offset by '+ firstElementDiff'.
397 static void GenerateRangeArgPair( int arg1, int arg2, SubArguments& vSubArguments,
398 outputstream& ss, EmptyArgType empty, const char* code, const char* firstElementDiff = nullptr );
399 // Generate code for "double <name> = range[<element>]" from vSubArguments.
400 // The argument must be svDoubleRef.
401 static void GenerateRangeArgElement( const char* name, int arg, const char* element,
402 SubArguments& vSubArguments, outputstream& ss, EmptyArgType empty );
404 const formula::DoubleVectorRefToken* pDVR, const char* firstElementDiff );
405};
406
408{
409public:
410 virtual void GenSlidingWindowFunction( outputstream& ss,
411 const std::string& sSymName, SubArguments& vSubArguments ) override;
412 virtual bool takeString() const override { return false; }
413 virtual bool takeNumeric() const override { return true; }
414};
415
416class CheckVariables : public Normal
417{
418public:
419 static void GenTmpVariables( outputstream& ss, const SubArguments& vSubArguments );
420 static void CheckSubArgumentIsNan( outputstream& ss,
421 SubArguments& vSubArguments, int argumentNum );
422 static void CheckAllSubArgumentIsNan( outputstream& ss,
423 SubArguments& vSubArguments );
424 // only check isnan
425 static void CheckSubArgumentIsNan2( outputstream& ss,
426 SubArguments& vSubArguments, int argumentNum, const std::string& p );
427 static void UnrollDoubleVector( outputstream& ss,
428 const outputstream& unrollstr, const formula::DoubleVectorRefToken* pCurDVR,
429 int nCurWindowSize );
430};
431
432class OpAverage;
433class OpCount;
434
438template<class Base>
440{
441public:
442 DynamicKernelSlidingArgument(const ScCalcConfig& config, const std::string& s,
443 const FormulaTreeNodeRef& ft,
444 std::shared_ptr<SlidingFunctionBase> CodeGen, int index);
445 // Should only be called by SumIfs. Yikes!
446 virtual bool NeedParallelReduction() const;
448
449 std::string GenSlidingWindowDeclRef( bool nested = false ) const;
451 size_t GenReductionLoopHeader( outputstream& ss, bool& needBody );
452
453 size_t GetArrayLength() const { return mpDVR->GetArrayLength(); }
454
455 size_t GetWindowSize() const { return mpDVR->GetRefRowSize(); }
456
457 bool GetStartFixed() const { return bIsStartFixed; }
458
459 bool GetEndFixed() const { return bIsEndFixed; }
460
461protected:
464 // from parent nodes
465 std::shared_ptr<SlidingFunctionBase> mpCodeGen;
466};
467
470template<class Base>
472{
473public:
474 ParallelReductionVectorRef(const ScCalcConfig& config, const std::string& s,
475 const FormulaTreeNodeRef& ft,
476 std::shared_ptr<SlidingFunctionBase> CodeGen, int index);
478
480 virtual void GenSlidingWindowFunction( outputstream& ss );
481 virtual std::string GenSlidingWindowDeclRef( bool ) const;
483 size_t GenReductionLoopHeader( outputstream& ss, int nResultSize, bool& needBody );
484 virtual size_t Marshal( cl_kernel k, int argno, int w, cl_program mpProgram );
485 size_t GetArrayLength() const { return mpDVR->GetArrayLength(); }
486 size_t GetWindowSize() const { return mpDVR->GetRefRowSize(); }
487 bool GetStartFixed() const { return bIsStartFixed; }
488 bool GetEndFixed() const { return bIsEndFixed; }
489
490protected:
493 // from parent nodes
494 std::shared_ptr<SlidingFunctionBase> mpCodeGen;
495 // controls whether to invoke the reduction kernel during marshaling or not
496 cl_mem mpClmem2;
497};
498
500{
501 int const mnResultSize;
502public:
503 explicit Reduction(int nResultSize) : mnResultSize(nResultSize) {}
504
509
510 virtual bool HandleNaNArgument( outputstream&, unsigned, SubArguments& ) const
511 {
512 return false;
513 }
514
515 virtual void GenSlidingWindowFunction( outputstream& ss,
516 const std::string& sSymName, SubArguments& vSubArguments ) override;
517 virtual bool isAverage() const { return false; }
518 virtual bool isMinOrMax() const { return false; }
519 virtual bool takeString() const override { return false; }
520 virtual bool takeNumeric() const override { return true; }
521};
522
523}
524
525/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
StackVar GetType() const
virtual double GetDouble() const
static void CheckSubArgumentIsNan2(outputstream &ss, SubArguments &vSubArguments, int argumentNum, const std::string &p)
Definition: opbase.cxx:669
static void CheckSubArgumentIsNan(outputstream &ss, SubArguments &vSubArguments, int argumentNum)
Definition: opbase.cxx:605
static void GenTmpVariables(outputstream &ss, const SubArguments &vSubArguments)
Definition: opbase.cxx:594
static void UnrollDoubleVector(outputstream &ss, const outputstream &unrollstr, const formula::DoubleVectorRefToken *pCurDVR, int nCurWindowSize)
Definition: opbase.cxx:706
static void CheckAllSubArgumentIsNan(outputstream &ss, SubArguments &vSubArguments)
Definition: opbase.cxx:696
(Partially) abstract base class for an operand
Definition: opbase.hxx:125
virtual bool IsEmpty() const
If there's actually no argument, i.e. it expands to no code.
Definition: opbase.hxx:169
virtual size_t Marshal(cl_kernel, int, int, cl_program)=0
Create buffer and pass the buffer to a given kernel.
virtual std::string GenStringSlidingWindowDeclRef(bool=false) const
When Mix, it will be called.
Definition: opbase.cxx:53
static int GetStringId(const rtl_uString *string)
Definition: opbase.cxx:110
virtual void GenSlidingWindowDecl(outputstream &ss) const =0
When declared as input to a sliding window function.
virtual void DumpInlineFun(std::set< std::string > &, std::set< std::string > &) const
Definition: opbase.cxx:76
virtual std::string DumpOpName() const
Definition: opbase.cxx:71
formula::FormulaToken * GetFormulaToken() const
Definition: opbase.cxx:66
virtual bool NeedParallelReduction() const
Definition: opbase.cxx:83
const DynamicKernelArgument & operator=(const DynamicKernelArgument &)=delete
delete copy-assignment operator
virtual void GenDeclRef(outputstream &ss) const
Generate use/references to the argument.
Definition: opbase.cxx:59
const std::string & GetName() const
Definition: opbase.cxx:78
virtual void GenSlidingWindowFunction(outputstream &)
Definition: opbase.cxx:64
virtual std::string GenIsString(bool=false) const
Will generate value saying whether the value is a string.
Definition: opbase.hxx:157
virtual std::string GenSlidingWindowDeclRef(bool=false) const =0
When referenced in a sliding window function.
DynamicKernelArgument(const DynamicKernelArgument &)=delete
delete copy constructor
FormulaTreeNodeRef mFormulaTree
Definition: opbase.hxx:176
virtual size_t GetWindowSize() const =0
const ScCalcConfig & mCalcConfig
Definition: opbase.hxx:174
virtual void GenDecl(outputstream &ss) const =0
Generate declaration.
virtual std::string GenDoubleSlidingWindowDeclRef(bool=false) const
When Mix, it will be called.
Definition: opbase.cxx:47
Arguments that are actually compile-time constants.
Definition: opbase.hxx:254
virtual double GetDouble() const
Definition: opbase.hxx:282
virtual void GenDeclRef(outputstream &ss) const override
Generate use/references to the argument.
Definition: opbase.hxx:264
virtual void GenSlidingWindowDecl(outputstream &ss) const override
When declared as input to a sliding window function.
Definition: opbase.hxx:268
virtual size_t GetWindowSize() const override
Definition: opbase.hxx:278
virtual void GenDecl(outputstream &ss) const override
Generate declaration.
Definition: opbase.hxx:260
virtual std::string GenSlidingWindowDeclRef(bool=false) const override
When referenced in a sliding window function.
Definition: opbase.hxx:272
DynamicKernelConstantArgument(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft)
Definition: opbase.hxx:256
virtual size_t Marshal(cl_kernel k, int argno, int, cl_program) override
Create buffer and pass the buffer to a given kernel.
Definition: opbase.hxx:290
Handling a Double Vector that is used as a sliding window input to either a sliding window average or...
Definition: opbase.hxx:440
size_t GenReductionLoopHeader(outputstream &ss, bool &needBody)
Controls how the elements in the DoubleVectorRef are traversed.
const formula::DoubleVectorRefToken * mpDVR
Definition: opbase.hxx:463
std::string GenSlidingWindowDeclRef(bool nested=false) const
DynamicKernelSlidingArgument(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft, std::shared_ptr< SlidingFunctionBase > CodeGen, int index)
virtual void GenSlidingWindowFunction(outputstream &)
Definition: opbase.hxx:447
std::shared_ptr< SlidingFunctionBase > mpCodeGen
Definition: opbase.hxx:465
virtual size_t Marshal(cl_kernel, int, int, cl_program) override
Create buffer and pass the buffer to a given kernel.
DynamicKernelStringArgument(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft, int index=0)
Definition: opbase.hxx:234
virtual void GenSlidingWindowFunction(outputstream &) override
Definition: opbase.hxx:238
virtual std::string GenIsString(bool=false) const override
Will generate value saying whether the value is a string.
virtual void GenSlidingWindowDecl(outputstream &ss) const override
When declared as input to a sliding window function.
Definition: opbase.hxx:244
virtual void GenDecl(outputstream &ss) const override
Generate declaration.
Definition: opbase.hxx:240
virtual std::string GenSlidingWindowDeclRef(bool=false) const override
When referenced in a sliding window function.
Definition: opbase.hxx:310
DynamicKernelStringToZeroArgument(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft)
Definition: opbase.hxx:307
virtual double GetDouble() const override
Definition: opbase.hxx:314
std::vector< FormulaTreeNodeRef > Children
Definition: opbase.hxx:113
formula::FormulaToken * GetFormulaToken() const
Definition: opbase.hxx:114
formula::FormulaConstTokenRef mpCurrentFormula
Definition: opbase.hxx:120
FormulaTreeNode(const formula::FormulaToken *ft)
Definition: opbase.hxx:109
InvalidParameterCount(int parameterCount, std::string file, int ln)
Definition: opbase.cxx:40
virtual bool takeString() const override
Definition: opbase.hxx:412
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: opbase.cxx:577
virtual bool takeNumeric() const override
Definition: opbase.hxx:413
Abstract class for code generation.
Definition: opbase.hxx:320
virtual std::string GetBottom()
Definition: opbase.hxx:325
virtual bool ZeroReturnZero()
Definition: opbase.hxx:338
virtual bool canHandleMultiVector() const
Definition: opbase.hxx:335
virtual std::string Gen2(const std::string &, const std::string &) const
Definition: opbase.hxx:326
static std::string Gen(std::vector< std::string > &)
Definition: opbase.hxx:328
virtual bool takeString() const =0
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &)
Definition: opbase.hxx:330
virtual bool takeNumeric() const =0
virtual std::string BinFuncName() const
Definition: opbase.hxx:329
virtual ~OpBase()
Definition: opbase.hxx:341
virtual bool forceStringsToZero() const
Definition: opbase.hxx:340
Failed in marshaling.
Definition: opbase.hxx:53
std::string mFunction
Definition: opbase.hxx:57
OpenCLError(std::string function, cl_int error, std::string file, int line)
Definition: opbase.cxx:27
std::string mFile
Definition: opbase.hxx:59
Handling a Double Vector that is used as a sliding window input Performs parallel reduction based on ...
Definition: opbase.hxx:472
virtual size_t Marshal(cl_kernel k, int argno, int w, cl_program mpProgram)
size_t GenReductionLoopHeader(outputstream &ss, int nResultSize, bool &needBody)
Controls how the elements in the DoubleVectorRef are traversed.
ParallelReductionVectorRef(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft, std::shared_ptr< SlidingFunctionBase > CodeGen, int index)
virtual void GenSlidingWindowFunction(outputstream &ss)
Emit the definition for the auxiliary reduction kernel.
const formula::DoubleVectorRefToken * mpDVR
Definition: opbase.hxx:492
std::shared_ptr< SlidingFunctionBase > mpCodeGen
Definition: opbase.hxx:494
virtual std::string GenSlidingWindowDeclRef(bool) const
int const mnResultSize
Definition: opbase.hxx:501
virtual bool isMinOrMax() const
Definition: opbase.hxx:518
DynamicKernelSlidingArgument< DynamicKernelStringArgument > StringRange
Definition: opbase.hxx:507
DynamicKernelSlidingArgument< VectorRef > NumericRange
Definition: opbase.hxx:505
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: opbase.cxx:784
virtual bool takeNumeric() const override
Definition: opbase.hxx:520
virtual bool isAverage() const
Definition: opbase.hxx:517
virtual bool takeString() const override
Definition: opbase.hxx:519
ParallelReductionVectorRef< VectorRef > ParallelNumericRange
Definition: opbase.hxx:508
Reduction(int nResultSize)
Definition: opbase.hxx:503
virtual bool HandleNaNArgument(outputstream &, unsigned, SubArguments &) const
Definition: opbase.hxx:510
DynamicKernelSlidingArgument< VectorRefStringsToZero > NumericRangeStringsToZero
Definition: opbase.hxx:506
void GenerateArg(const char *name, int arg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty=EmptyIsZero, GenerateArgTypeType generateType=DoNotGenerateArgType)
Definition: opbase.cxx:226
virtual void GenSlidingWindowFunction(outputstream &, const std::string &, SubArguments &)=0
static void GenerateDoubleVectorLoopHeader(outputstream &ss, const formula::DoubleVectorRefToken *pDVR, const char *firstElementDiff)
Definition: opbase.cxx:530
static void GenerateRangeArgElement(const char *name, int arg, const char *element, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty)
Definition: opbase.cxx:495
static void GenerateRangeArg(int arg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code)
Definition: opbase.cxx:414
void GenerateArgWithDefault(const char *name, int arg, double def, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty=EmptyIsZero)
Definition: opbase.cxx:304
void GenerateFunctionDeclaration(const std::string &sSymName, SubArguments &vSubArguments, outputstream &ss)
Definition: opbase.cxx:563
static void GenerateRangeArgPair(int arg1, int arg2, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code, const char *firstElementDiff=nullptr)
Definition: opbase.cxx:420
static void GenerateRangeArgs(int firstArg, int lastArg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code)
Definition: opbase.cxx:313
void GenerateRangeArg(int arg1, int arg2, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code, const char *firstElementDiff=nullptr)
std::vector< DynamicKernelArgumentRef > SubArguments
Definition: opbase.hxx:347
UnhandledToken(const char *m, std::string fn, int ln)
Definition: opbase.cxx:23
Inconsistent state.
Definition: opbase.hxx:65
Unhandled(std::string fn, int ln)
Definition: opbase.cxx:37
std::string mFile
Definition: opbase.hxx:69
VectorRefStringsToZero(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft, int index=0)
Definition: opbase.cxx:219
Holds an input (read-only) argument reference to a SingleVectorRef.
Definition: opbase.hxx:188
VectorRef(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft, int index=0)
Definition: opbase.cxx:128
virtual bool NeedParallelReduction() const override
Definition: opbase.cxx:214
virtual void GenSlidingWindowDecl(outputstream &ss) const override
When declared as input to a sliding window function.
Definition: opbase.cxx:156
virtual std::string GenSlidingWindowDeclRef(bool=false) const override
When referenced in a sliding window function.
Definition: opbase.cxx:162
virtual void GenDecl(outputstream &ss) const override
Generate declaration.
Definition: opbase.cxx:150
const std::string & GetName() const
Definition: opbase.cxx:204
virtual void DumpInlineFun(std::set< std::string > &, std::set< std::string > &) const override
Definition: opbase.cxx:202
cl_mem GetCLBuffer() const
Definition: opbase.cxx:209
std::vector< double > dataBuffer
Definition: opbase.hxx:220
virtual std::string DumpOpName() const override
Definition: opbase.cxx:197
virtual size_t GetWindowSize() const override
Definition: opbase.cxx:177
virtual ~VectorRef() override
Definition: opbase.cxx:139
virtual void GenSlidingWindowFunction(outputstream &) override
Definition: opbase.cxx:175
virtual size_t Marshal(cl_kernel, int, int, cl_program) override
Create buffer and pass the buffer to a given kernel.
cl_program mpProgram
void * p
#define SAL_INFO(area, stream)
err
::boost::intrusive_ptr< const FormulaToken > FormulaConstTokenRef
config
line
index
m
std::string preciseFloat(double f)
Definition: utils.cxx:55
std::shared_ptr< FormulaTreeNode > FormulaTreeNodeRef
Definition: opbase.hxx:104
std::shared_ptr< DynamicKernelArgument > DynamicKernelArgumentRef
Definition: opbase.hxx:180
sal_Int32 w
Configuration options for formula interpreter.
Definition: calcconfig.hxx:44
Base