Image Component Library (ICL)
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
icl::utils::CLKernel Class Reference

Wrapper for an OpenCL Kernel. More...

#include <CLKernel.h>

Classes

struct  Arg
 Utility structure for the CLKernel's index operator. More...
 
struct  LocalMemory
 struct that represents the dynamic local memory for a kernel More...
 

Public Member Functions

 CLKernel ()
 Default constructor (creates a dummy instance) More...
 
 CLKernel (const CLKernel &other)
 copy constructor (creates shallow copy) More...
 
CLKernel const & operator= (CLKernel const &other)
 assignment operator (creates shallow copy) More...
 
 ~CLKernel ()
 Destructor. More...
 
void apply (int gloW, int gloH=0, int gloC=0, int locW=0, int locH=0, int locC=0)
 executes kernel with given global and local coordinates More...
 
void finish ()
 calls the finish-fkt. of opencl to wait until the command queue is done More...
 
void setArg (const unsigned idx, const unsigned int &value)
 Overloaded Kernel argument setter for unsigned int values. More...
 
void setArg (const unsigned idx, const int &value)
 Overloaded Kernel argument setter for int values. More...
 
void setArg (const unsigned idx, const short &value)
 Overloaded Kernel argument setter for short values. More...
 
void setArg (const unsigned idx, const long &value)
 Overloaded Kernel argument setter for long values. More...
 
void setArg (const unsigned idx, const unsigned long &value)
 Overloaded Kernel argument setter for unsigned long values. More...
 
void setArg (const unsigned idx, const float &value)
 Overloaded Kernel argument setter for float values. More...
 
void setArg (const unsigned idx, const double &value)
 Overloaded Kernel argument setter for double values. More...
 
void setArg (const unsigned idx, const char &value)
 Overloaded Kernel argument setter for char values. More...
 
void setArg (const unsigned idx, const unsigned char &value)
 Overloaded Kernel argument setter for unsigned char values. More...
 
void setArg (const unsigned idx, const FixedArray< float, 4 > &value)
 Overloaded Kernel argument setter for 4D vectors. More...
 
void setArg (const unsigned idx, const FixedArray< float, 3 > &value)
 Overloaded Kernel argument setter for 3D vectors. More...
 
void setArg (const unsigned idx, const CLBuffer &value)
 Overloaded Kernel argument setter for CLBuffer values (aka arrays/pointers) More...
 
void setArg (const unsigned idx, const CLImage2D &value)
 Overloaded Kernel argument setter for CLImage2D values (aka arrays/pointers) More...
 
void setArg (const unsigned idx, const LocalMemory &value)
 Overloaded Kernel argument setter for dynamic local memory. More...
 
template<typename A >
void setArgs (const A &value)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B >
void setArgs (const A &valueA, const B &valueB)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C >
void setArgs (const A &valueA, const B &valueB, const C &valueC)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH, const I &valueI)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH, const I &valueI, const J &valueJ)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH, const I &valueI, const J &valueJ, const K &valueK)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH, const I &valueI, const J &valueJ, const K &valueK, const L &valueL)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH, const I &valueI, const J &valueJ, const K &valueK, const L &valueL, const M &valueM)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M , typename N >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH, const I &valueI, const J &valueJ, const K &valueK, const L &valueL, const M &valueM, const N &valueN)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M , typename N , typename O >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH, const I &valueI, const J &valueJ, const K &valueK, const L &valueL, const M &valueM, const N &valueN, const O &valueO)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M , typename N , typename O , typename P >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH, const I &valueI, const J &valueJ, const K &valueK, const L &valueL, const M &valueM, const N &valueN, const O &valueO, const P &valueP)
 sets mutiple kernel arguments at once More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M , typename N , typename O , typename P , typename Q >
void setArgs (const A &valueA, const B &valueB, const C &valueC, const D &valueD, const E &valueE, const F &valueF, const G &valueG, const H &valueH, const I &valueI, const J &valueJ, const K &valueK, const L &valueL, const M &valueM, const N &valueN, const O &valueO, const P &valueP, const Q &valueQ)
 sets mutiple kernel arguments at once More...
 
Arg operator[] (int idx)
 for index operator-based setting of kernel arguments More...
 

Private Member Functions

 CLKernel (const string &id, cl::Program &program, cl::CommandQueue &cmdQueue)
 private constructor (CLKernel instances can only be created by CLPrograms) More...
 

Private Attributes

Impl * impl
 internal implementation More...
 

Friends

class CLProgram
 for tight integration with the CLProgram class More...
 
class CLDeviceContext
 

Detailed Description

Wrapper for an OpenCL Kernel.

A Kernel is a callable OpenCL function. CLKernel instances can only be created by CLProgram instances. Please refer to the CLProgram reference for further details.

Kernel Arguments

Before, a Kernel (aka an OpenCL function) is called, its arguments have to be set. This can either be done step by step using one of the overloaded CLKernel.setArg-methods or using the assignment operator or with the templated CLKernel::setArgs method.

kernel.setArgs(inBuffer, outBuffer, inSize, outSize);

or: kernel[0] = inBuffer; kernel[1] = outBuffer; kernel[2] = inSize; kernel[3] = outSize;

Constructor & Destructor Documentation

◆ CLKernel() [1/3]

icl::utils::CLKernel::CLKernel ( const string &  id,
cl::Program &  program,
cl::CommandQueue &  cmdQueue 
)
private

private constructor (CLKernel instances can only be created by CLPrograms)

◆ CLKernel() [2/3]

icl::utils::CLKernel::CLKernel ( )

Default constructor (creates a dummy instance)

◆ CLKernel() [3/3]

icl::utils::CLKernel::CLKernel ( const CLKernel other)

copy constructor (creates shallow copy)

◆ ~CLKernel()

icl::utils::CLKernel::~CLKernel ( )

Destructor.

Member Function Documentation

◆ apply()

void icl::utils::CLKernel::apply ( int  gloW,
int  gloH = 0,
int  gloC = 0,
int  locW = 0,
int  locH = 0,
int  locC = 0 
)

executes kernel with given global and local coordinates

gloW can be accessed in the kernel code by get_global_id(0), and so on

◆ finish()

void icl::utils::CLKernel::finish ( )

calls the finish-fkt. of opencl to wait until the command queue is done

◆ operator=()

CLKernel const& icl::utils::CLKernel::operator= ( CLKernel const &  other)

assignment operator (creates shallow copy)

◆ operator[]()

Arg icl::utils::CLKernel::operator[] ( int  idx)
inline

for index operator-based setting of kernel arguments

◆ setArg() [1/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const unsigned int &  value 
)

Overloaded Kernel argument setter for unsigned int values.

◆ setArg() [2/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const int &  value 
)

Overloaded Kernel argument setter for int values.

◆ setArg() [3/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const short &  value 
)

Overloaded Kernel argument setter for short values.

◆ setArg() [4/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const long &  value 
)

Overloaded Kernel argument setter for long values.

◆ setArg() [5/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const unsigned long &  value 
)

Overloaded Kernel argument setter for unsigned long values.

◆ setArg() [6/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const float &  value 
)

Overloaded Kernel argument setter for float values.

◆ setArg() [7/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const double &  value 
)

Overloaded Kernel argument setter for double values.

◆ setArg() [8/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const char &  value 
)

Overloaded Kernel argument setter for char values.

◆ setArg() [9/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const unsigned char &  value 
)

Overloaded Kernel argument setter for unsigned char values.

◆ setArg() [10/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const FixedArray< float, 4 > &  value 
)

Overloaded Kernel argument setter for 4D vectors.

◆ setArg() [11/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const FixedArray< float, 3 > &  value 
)

Overloaded Kernel argument setter for 3D vectors.

◆ setArg() [12/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const CLBuffer value 
)

Overloaded Kernel argument setter for CLBuffer values (aka arrays/pointers)

◆ setArg() [13/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const CLImage2D value 
)

Overloaded Kernel argument setter for CLImage2D values (aka arrays/pointers)

◆ setArg() [14/14]

void icl::utils::CLKernel::setArg ( const unsigned  idx,
const LocalMemory value 
)

Overloaded Kernel argument setter for dynamic local memory.

◆ setArgs() [1/17]

template<typename A >
void icl::utils::CLKernel::setArgs ( const A &  value)
inline

sets mutiple kernel arguments at once

◆ setArgs() [2/17]

template<typename A , typename B >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [3/17]

template<typename A , typename B , typename C >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [4/17]

template<typename A , typename B , typename C , typename D >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [5/17]

template<typename A , typename B , typename C , typename D , typename E >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [6/17]

template<typename A , typename B , typename C , typename D , typename E , typename F >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [7/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [8/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [9/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH,
const I &  valueI 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [10/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH,
const I &  valueI,
const J &  valueJ 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [11/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH,
const I &  valueI,
const J &  valueJ,
const K &  valueK 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [12/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH,
const I &  valueI,
const J &  valueJ,
const K &  valueK,
const L &  valueL 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [13/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH,
const I &  valueI,
const J &  valueJ,
const K &  valueK,
const L &  valueL,
const M &  valueM 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [14/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M , typename N >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH,
const I &  valueI,
const J &  valueJ,
const K &  valueK,
const L &  valueL,
const M &  valueM,
const N &  valueN 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [15/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M , typename N , typename O >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH,
const I &  valueI,
const J &  valueJ,
const K &  valueK,
const L &  valueL,
const M &  valueM,
const N &  valueN,
const O &  valueO 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [16/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M , typename N , typename O , typename P >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH,
const I &  valueI,
const J &  valueJ,
const K &  valueK,
const L &  valueL,
const M &  valueM,
const N &  valueN,
const O &  valueO,
const P &  valueP 
)
inline

sets mutiple kernel arguments at once

◆ setArgs() [17/17]

template<typename A , typename B , typename C , typename D , typename E , typename F , typename G , typename H , typename I , typename J , typename K , typename L , typename M , typename N , typename O , typename P , typename Q >
void icl::utils::CLKernel::setArgs ( const A &  valueA,
const B &  valueB,
const C &  valueC,
const D &  valueD,
const E &  valueE,
const F &  valueF,
const G &  valueG,
const H &  valueH,
const I &  valueI,
const J &  valueJ,
const K &  valueK,
const L &  valueL,
const M &  valueM,
const N &  valueN,
const O &  valueO,
const P &  valueP,
const Q &  valueQ 
)
inline

sets mutiple kernel arguments at once

Friends And Related Function Documentation

◆ CLDeviceContext

friend class CLDeviceContext
friend

◆ CLProgram

friend class CLProgram
friend

for tight integration with the CLProgram class

Member Data Documentation

◆ impl

Impl* icl::utils::CLKernel::impl
private

internal implementation

internally used data


The documentation for this class was generated from the following file: