32#define REDUCE_THRESHOLD 201
33#define UNROLLING_FACTOR 16
55 OpenCLError( std::string function, cl_int error, std::string file,
int line );
85#define CHECK_PARAMETER_COUNT(min, max) \
87 const int count = vSubArguments.size(); \
88 if( count < ( min ) || count > ( max )) \
89 throw InvalidParameterCount( count, __FILE__, __LINE__ ); \
91#define CHECK_PARAMETER_COUNT_MIN(min) \
93 const int count = vSubArguments.size(); \
94 if( count < ( min )) \
95 throw InvalidParameterCount( count, __FILE__, __LINE__ ); \
97#define CHECK_PARAMETER_DOUBLEVECTORREF(arg) \
99 formula::FormulaToken *token = vSubArguments[arg]->GetFormulaToken(); \
100 if (token == nullptr || token->GetType() != formula::svDoubleVectorRef) \
101 throw Unhandled(__FILE__, __LINE__); \
146 virtual size_t Marshal( cl_kernel,
int,
int, cl_program ) = 0;
157 virtual std::string
GenIsString(
bool =
false )
const {
return "false"; }
165 virtual void DumpInlineFun( std::set<std::string>&, std::set<std::string>& )
const;
166 const std::string&
GetName()
const;
169 virtual bool IsEmpty()
const {
return false; }
177 static int GetStringId(
const rtl_uString*
string );
202 virtual size_t Marshal( cl_kernel,
int,
int, cl_program )
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;
242 ss <<
"__global double *" <<
mSymName;
248 virtual std::string
GenIsString(
bool =
false )
const override;
249 virtual size_t Marshal( cl_kernel,
int,
int, cl_program )
override;
290 virtual size_t Marshal( cl_kernel k,
int argno,
int, cl_program )
override
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)
326 virtual std::string
Gen2(
const std::string&,
327 const std::string& )
const {
return "";}
328 static std::string
Gen( std::vector<std::string>& ) {
return "";};
331 std::set<std::string>& ) { }
411 const std::string& sSymName,
SubArguments& vSubArguments )
override;
426 SubArguments& vSubArguments,
int argumentNum,
const std::string&
p );
429 int nCurWindowSize );
444 std::shared_ptr<SlidingFunctionBase> CodeGen,
int index);
476 std::shared_ptr<SlidingFunctionBase> CodeGen,
int index);
516 const std::string& sSymName,
SubArguments& vSubArguments )
override;
static void CheckSubArgumentIsNan2(outputstream &ss, SubArguments &vSubArguments, int argumentNum, const std::string &p)
static void CheckSubArgumentIsNan(outputstream &ss, SubArguments &vSubArguments, int argumentNum)
static void GenTmpVariables(outputstream &ss, const SubArguments &vSubArguments)
static void UnrollDoubleVector(outputstream &ss, const outputstream &unrollstr, const formula::DoubleVectorRefToken *pCurDVR, int nCurWindowSize)
static void CheckAllSubArgumentIsNan(outputstream &ss, SubArguments &vSubArguments)
(Partially) abstract base class for an operand
virtual bool IsEmpty() const
If there's actually no argument, i.e. it expands to no code.
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.
static int GetStringId(const rtl_uString *string)
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
virtual std::string DumpOpName() const
formula::FormulaToken * GetFormulaToken() const
virtual bool NeedParallelReduction() const
const DynamicKernelArgument & operator=(const DynamicKernelArgument &)=delete
delete copy-assignment operator
virtual void GenDeclRef(outputstream &ss) const
Generate use/references to the argument.
const std::string & GetName() const
virtual void GenSlidingWindowFunction(outputstream &)
static void ClearStringIds()
virtual std::string GenIsString(bool=false) const
Will generate value saying whether the value is a string.
virtual std::string GenSlidingWindowDeclRef(bool=false) const =0
When referenced in a sliding window function.
virtual ~DynamicKernelArgument()
DynamicKernelArgument(const DynamicKernelArgument &)=delete
delete copy constructor
FormulaTreeNodeRef mFormulaTree
virtual size_t GetWindowSize() const =0
const ScCalcConfig & mCalcConfig
virtual void GenDecl(outputstream &ss) const =0
Generate declaration.
virtual std::string GenDoubleSlidingWindowDeclRef(bool=false) const
When Mix, it will be called.
Arguments that are actually compile-time constants.
virtual double GetDouble() const
virtual void GenDeclRef(outputstream &ss) const override
Generate use/references to the argument.
virtual void GenSlidingWindowDecl(outputstream &ss) const override
When declared as input to a sliding window function.
virtual size_t GetWindowSize() const override
virtual void GenDecl(outputstream &ss) const override
Generate declaration.
virtual std::string GenSlidingWindowDeclRef(bool=false) const override
When referenced in a sliding window function.
DynamicKernelConstantArgument(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft)
virtual size_t Marshal(cl_kernel k, int argno, int, cl_program) override
Create buffer and pass the buffer to a given kernel.
Handling a Double Vector that is used as a sliding window input to either a sliding window average or...
virtual bool NeedParallelReduction() const
bool GetStartFixed() const
size_t GenReductionLoopHeader(outputstream &ss, bool &needBody)
Controls how the elements in the DoubleVectorRef are traversed.
const formula::DoubleVectorRefToken * mpDVR
size_t GetArrayLength() const
size_t GetWindowSize() const
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 &)
std::shared_ptr< SlidingFunctionBase > mpCodeGen
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)
virtual void GenSlidingWindowFunction(outputstream &) override
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.
virtual void GenDecl(outputstream &ss) const override
Generate declaration.
virtual std::string GenSlidingWindowDeclRef(bool=false) const override
When referenced in a sliding window function.
DynamicKernelStringToZeroArgument(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft)
virtual double GetDouble() const override
InvalidParameterCount(int parameterCount, std::string file, int ln)
virtual bool takeString() const override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual bool takeNumeric() const override
Abstract class for code generation.
virtual std::string GetBottom()
virtual bool ZeroReturnZero()
virtual bool canHandleMultiVector() const
virtual std::string Gen2(const std::string &, const std::string &) const
static std::string Gen(std::vector< std::string > &)
virtual bool takeString() const =0
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &)
virtual bool takeNumeric() const =0
virtual std::string BinFuncName() const
virtual bool forceStringsToZero() const
OpenCLError(std::string function, cl_int error, std::string file, int line)
Handling a Double Vector that is used as a sliding window input Performs parallel reduction based on ...
bool GetStartFixed() const
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.
size_t GetWindowSize() const
const formula::DoubleVectorRefToken * mpDVR
size_t GetArrayLength() const
~ParallelReductionVectorRef()
std::shared_ptr< SlidingFunctionBase > mpCodeGen
virtual std::string GenSlidingWindowDeclRef(bool) const
virtual bool isMinOrMax() const
DynamicKernelSlidingArgument< DynamicKernelStringArgument > StringRange
DynamicKernelSlidingArgument< VectorRef > NumericRange
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual bool takeNumeric() const override
virtual bool isAverage() const
virtual bool takeString() const override
ParallelReductionVectorRef< VectorRef > ParallelNumericRange
Reduction(int nResultSize)
virtual bool HandleNaNArgument(outputstream &, unsigned, SubArguments &) const
DynamicKernelSlidingArgument< VectorRefStringsToZero > NumericRangeStringsToZero
void GenerateArg(const char *name, int arg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty=EmptyIsZero, GenerateArgTypeType generateType=DoNotGenerateArgType)
virtual void GenSlidingWindowFunction(outputstream &, const std::string &, SubArguments &)=0
static void GenerateDoubleVectorLoopHeader(outputstream &ss, const formula::DoubleVectorRefToken *pDVR, const char *firstElementDiff)
static void GenerateRangeArgElement(const char *name, int arg, const char *element, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty)
static void GenerateRangeArg(int arg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code)
void GenerateArgWithDefault(const char *name, int arg, double def, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty=EmptyIsZero)
void GenerateFunctionDeclaration(const std::string &sSymName, SubArguments &vSubArguments, outputstream &ss)
static void GenerateRangeArgPair(int arg1, int arg2, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code, const char *firstElementDiff=nullptr)
static void GenerateRangeArgs(int firstArg, int lastArg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code)
void GenerateRangeArg(int arg1, int arg2, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code, const char *firstElementDiff=nullptr)
std::vector< DynamicKernelArgumentRef > SubArguments
UnhandledToken(const char *m, std::string fn, int ln)
Unhandled(std::string fn, int ln)
VectorRefStringsToZero(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft, int index=0)
Holds an input (read-only) argument reference to a SingleVectorRef.
VectorRef(const ScCalcConfig &config, const std::string &s, const FormulaTreeNodeRef &ft, int index=0)
virtual bool NeedParallelReduction() const override
virtual void GenSlidingWindowDecl(outputstream &ss) const override
When declared as input to a sliding window function.
virtual std::string GenSlidingWindowDeclRef(bool=false) const override
When referenced in a sliding window function.
virtual void GenDecl(outputstream &ss) const override
Generate declaration.
const std::string & GetName() const
virtual void DumpInlineFun(std::set< std::string > &, std::set< std::string > &) const override
cl_mem GetCLBuffer() const
std::vector< double > dataBuffer
virtual std::string DumpOpName() const override
virtual size_t GetWindowSize() const override
virtual ~VectorRef() override
virtual void GenSlidingWindowFunction(outputstream &) override
virtual size_t Marshal(cl_kernel, int, int, cl_program) override
Create buffer and pass the buffer to a given kernel.
#define SAL_INFO(area, stream)
std::string preciseFloat(double f)
std::shared_ptr< FormulaTreeNode > FormulaTreeNodeRef
std::shared_ptr< DynamicKernelArgument > DynamicKernelArgumentRef
Configuration options for formula interpreter.