Image Component Library (ICL)
|
Main class for OpenCL based accelleration. More...
#include <CLProgram.h>
Public Member Functions | |
CLProgram () | |
Default constructor (creates dummy instance) More... | |
CLProgram (const CLDeviceContext &device_context, const string &sourceCode) | |
CLProgram (const CLDeviceContext &device_context, ifstream &fileStream) | |
CLProgram (const string deviceType, const string &sourceCode) | |
create CLProgram with given device type (either "gpu" or "cpu") and souce-code More... | |
CLProgram (const string deviceType, ifstream &fileStream) | |
create CLProgram with given device type (either "gpu" or "cpu") and souce-code file More... | |
CLProgram (const string &sourceCode, const CLProgram &parent) | |
create CLProgram with given cl-program parent and souce-code More... | |
CLProgram (ifstream &fileStream, const CLProgram &parent) | |
create CLProgram with given cl-program parent and souce-code file More... | |
CLProgram (const CLProgram &other) | |
copy constructor (creating shallow copy) More... | |
CLProgram const & | operator= (CLProgram const &other) |
assignment operator (perorming shallow copy) More... | |
~CLProgram () | |
Destructor. More... | |
bool | isValid () |
isValid checks whether this is not a dummy but a valid initialized cl-program More... | |
bool | isValid () const |
isValid checks whether this is not a dummy but a valid initialized cl-program More... | |
CLBuffer | createBuffer (const string &accessMode, size_t size, const void *src=0) |
creates a buffer object for memory exchange with graphics card memory More... | |
CLImage2D | createImage2D (const string &accessMode, const size_t width, const size_t height, int depth, const void *src=0) |
creates a image2D object for memory exchange with graphics card memory More... | |
CLImage2D | createImage2D (const string &accessMode, const size_t width, const size_t height, int depth, int num_channel, const void *src=0) |
CLKernel | createKernel (const string &id) |
extract a kernel from the program More... | |
CLDeviceContext | getDeviceContext () |
void | listSelectedPlatform () |
lists various properties of the selected platform More... | |
void | listSelectedDevice () |
lists various properties of the selected device More... | |
Static Public Member Functions | |
static void | listAllPlatformsAndDevices () |
lists various properties of all platforms and their devices More... | |
static void | listAllPlatforms () |
lists various properties of all platforms More... | |
Private Attributes | |
Impl * | impl |
Main class for OpenCL based accelleration.
The CLProgram is the based class for ICL's OpenCL support framework. A Program instance can be used to create all other neccessary OpenCL support types. In contrast to OpenCL's C++ framework, ICL's framework is even settled on a higher level providing easier access to the relavant functionality.
A CLProgram is – as presented above – the main class for OpenCL acellerated implementations. It allows for selected a particular device, i.e. "cpu" or "gpu" devices and it automatically compiles the given OpenCL source code (either passed as string or as an input stream)
A CLBuffer is a memory segment located in the graphics-card's memory. Buffers are associated with a certain CLProgram and they can only be created by that program. Buffers are either read-only, write-only or read-write. This access mode always refers to how the buffer can be accessed by the OpenCL source code, i.e. a "read-only" buffer becomes a "const" data pointer in the corresponding OpenCL kernel interface. And a "write only" buffer cannot be written but not read by the OpenCL source code (?).
TODO: what are the differences ? Why can i use "r" and "w" without producing error messages? (seems to be an OpenCL bug/feature)
A CLImage2D is similar to the CLBuffer but additionally offers interpolation functionality which can be accessed in the kernel by using the sampler_t type. Also a build-in 2D access to the image pixels is supported.
A CLKernel is a callable OpenCL function. CLKernel instances are also created by a program (see Example (Image Convolution)) and each kernel refers to a single function in the OpenCL source code that is declared as "__kernel".
Before a kernel is called, its arguments are given by using the overloaded CLKernel::setArgs method.
The same example but this time CLImage2D is used for the memory access instead of CLBuffer.
icl::utils::CLProgram::CLProgram | ( | ) |
Default constructor (creates dummy instance)
icl::utils::CLProgram::CLProgram | ( | const CLDeviceContext & | device_context, |
const string & | sourceCode | ||
) |
icl::utils::CLProgram::CLProgram | ( | const CLDeviceContext & | device_context, |
ifstream & | fileStream | ||
) |
icl::utils::CLProgram::CLProgram | ( | const string | deviceType, |
const string & | sourceCode | ||
) |
create CLProgram with given device type (either "gpu" or "cpu") and souce-code
icl::utils::CLProgram::CLProgram | ( | const string | deviceType, |
ifstream & | fileStream | ||
) |
create CLProgram with given device type (either "gpu" or "cpu") and souce-code file
icl::utils::CLProgram::CLProgram | ( | const string & | sourceCode, |
const CLProgram & | parent | ||
) |
create CLProgram with given cl-program parent and souce-code
icl::utils::CLProgram::CLProgram | ( | ifstream & | fileStream, |
const CLProgram & | parent | ||
) |
create CLProgram with given cl-program parent and souce-code file
icl::utils::CLProgram::CLProgram | ( | const CLProgram & | other | ) |
copy constructor (creating shallow copy)
icl::utils::CLProgram::~CLProgram | ( | ) |
Destructor.
CLBuffer icl::utils::CLProgram::createBuffer | ( | const string & | accessMode, |
size_t | size, | ||
const void * | src = 0 |
||
) |
creates a buffer object for memory exchange with graphics card memory
acessMode can either be "r", "w" or "rw", which refers to the readibility of the data by the OpenCL source code (actually this seems to be not relevant since all buffers can be read and written).
Each buffer has a fixed size (given in bytes). Optionally an initial source pointer can be passed that is then automatically uploaded to the buffer exisiting in the graphics memory.
CLImage2D icl::utils::CLProgram::createImage2D | ( | const string & | accessMode, |
const size_t | width, | ||
const size_t | height, | ||
int | depth, | ||
const void * | src = 0 |
||
) |
creates a image2D object for memory exchange with graphics card memory
acessMode can either be "r", "w" or "rw", which refers to the readibility of the data by the OpenCL source code (actually this seems to be not relevant since all images can be read and written).
Optionally an initial source pointer can be passed that is then automatically uploaded to the image exisiting in the graphics memory.
various image depths can be used
depth8u = 0, < 8Bit unsigned integer values range {0,1,...255}
depth16s = 1, < 16Bit signed integer values
depth32s = 2, < 32Bit signed integer values
depth32f = 3, < 32Bit floating point values
depth64f = 4, < 64Bit floating point values
CLImage2D icl::utils::CLProgram::createImage2D | ( | const string & | accessMode, |
const size_t | width, | ||
const size_t | height, | ||
int | depth, | ||
int | num_channel, | ||
const void * | src = 0 |
||
) |
CLKernel icl::utils::CLProgram::createKernel | ( | const string & | id | ) |
extract a kernel from the program
Kernels in the CLProgram's source code have to be qualified with the __kernel qualifier. The kernel (aka function) name in the OpenCL source code is used as id.
CLDeviceContext icl::utils::CLProgram::getDeviceContext | ( | ) |
bool icl::utils::CLProgram::isValid | ( | ) |
isValid checks whether this is not a dummy but a valid initialized cl-program
bool icl::utils::CLProgram::isValid | ( | ) | const |
isValid checks whether this is not a dummy but a valid initialized cl-program
|
static |
lists various properties of all platforms
|
static |
lists various properties of all platforms and their devices
void icl::utils::CLProgram::listSelectedDevice | ( | ) |
lists various properties of the selected device
void icl::utils::CLProgram::listSelectedPlatform | ( | ) |
lists various properties of the selected platform
assignment operator (perorming shallow copy)
|
private |