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

The CLDeviceContext class allows preparation of the device used for CLPrograms. More...

#include <CLDeviceContext.h>

Public Member Functions

 CLDeviceContext ()
 CLDeviceContext Creates a dummy CLDeviceContext. More...
 
 CLDeviceContext (std::string const &device)
 CLDeviceContext Creates a CLDeviceContext on the given device type. More...
 
 CLDeviceContext (const CLDeviceContext &other)
 CLDeviceContext Creates a shallow copy of the given CLDeviceContext. More...
 
CLDeviceContext const & operator= (CLDeviceContext const &other)
 operator = shallowly copies from other CLDeviceContext More...
 
 ~CLDeviceContext ()
 ~CLDeviceContext Destructor More...
 
CLBuffer createBuffer (const string &accessMode, size_t size, const void *src=0)
 createBuffer creates a buffer object for memory exchange with graphics card memory More...
 
CLBuffer createBuffer (const string &accessMode, size_t length, size_t byteDepth, const void *src=0)
 createBuffer createBuffer 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)
 createImage2D 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)
 createImage2D More...
 
std::string const getDeviceTypeString ()
 getDeviceTypeString Returns the device type as string More...
 
std::string const getDeviceTypeString () const
 getDeviceTypeString Returns the device type as string (const) More...
 
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 Member Functions

cl::Device & getDevice ()
 returns the internal cl device structure More...
 
cl::CommandQueue & getCommandQueue ()
 returns the internal cl command queue structure More...
 
cl::Context & getContext ()
 returns the internal cl context structure More...
 
CLBuffercreateBufferHeap (const string &accessMode, size_t length, size_t byteDepth, const void *src=0)
 createBufferHeap creates a buffer object pointer for memory exchange with graphics card memory. The pointer has to be handles by the user More...
 
CLImage2DcreateImage2DHeap (const string &accessMode, const size_t width, const size_t height, int depth, int num_channel, const void *src=0)
 createImage2DHeap Creates a image2D object pointer for memory exchange with graphics card memory. The pointer has to be handles by the user More...
 

Private Attributes

Impl * impl
 

Friends

class CLProgram
 for tight integration with CLProgram instances More...
 
class CLMemoryAssistant
 for tight integration with CLMemoryAssistant instances More...
 

Detailed Description

The CLDeviceContext class allows preparation of the device used for CLPrograms.

The CLDeviceContext class is a wrapper for the opencl c++ device, command queue and context classes. This class is used in CLProgram to instanciate a device and allocate memory. It also is used in CLMemoryAssistant to manage the buffer and image allocation. A CLDeviceContext can be shared over different CLPrograms to allow memory exchanges, e.g. for processing pipelines

Constructor & Destructor Documentation

◆ CLDeviceContext() [1/3]

icl::utils::CLDeviceContext::CLDeviceContext ( )

CLDeviceContext Creates a dummy CLDeviceContext.

◆ CLDeviceContext() [2/3]

icl::utils::CLDeviceContext::CLDeviceContext ( std::string const &  device)

CLDeviceContext Creates a CLDeviceContext on the given device type.

Parameters
devicetype of device as string. Current supported device types: "gpu","cpu".

◆ CLDeviceContext() [3/3]

icl::utils::CLDeviceContext::CLDeviceContext ( const CLDeviceContext other)

CLDeviceContext Creates a shallow copy of the given CLDeviceContext.

Parameters
otheranother CLDeviceContext to copy from

◆ ~CLDeviceContext()

icl::utils::CLDeviceContext::~CLDeviceContext ( )

~CLDeviceContext Destructor

Member Function Documentation

◆ createBuffer() [1/2]

CLBuffer icl::utils::CLDeviceContext::createBuffer ( const string &  accessMode,
size_t  size,
const void *  src = 0 
)

createBuffer creates a buffer object for memory exchange with graphics card memory

Parameters
accessModecan either be "r", "w" or "rw", which refers to the readibility of the data by the OpenCL source code
sizeFixed size for this buffer in bytes
srcOptional source pointer. If not NULL the content of this pointer will automatically be uploaded to the device.
Returns
The CLBuffer instance.

Throws a CLBufferException in case of allocation problems.

◆ createBuffer() [2/2]

CLBuffer icl::utils::CLDeviceContext::createBuffer ( const string &  accessMode,
size_t  length,
size_t  byteDepth,
const void *  src = 0 
)

createBuffer createBuffer creates a buffer object for memory exchange with graphics card memory

Parameters
accessModeaccessMode can either be "r", "w" or "rw", which refers to the readibility of the data by the OpenCL source code
lengthFixed length of the buffer (in original type size e.g. float,int, ..., etc.)
byteDepthByte depth of the data type (e.g. float = 4, int32 = 4, uchar = 1 ... etc.)
srcOptional source pointer. If not NULL the content of this pointer will automatically be uploaded to the device.
Returns

◆ createBufferHeap()

CLBuffer* icl::utils::CLDeviceContext::createBufferHeap ( const string &  accessMode,
size_t  length,
size_t  byteDepth,
const void *  src = 0 
)
private

createBufferHeap creates a buffer object pointer for memory exchange with graphics card memory. The pointer has to be handles by the user

Parameters
accessModeaccessMode can either be "r", "w" or "rw", which refers to the readibility of the data by the OpenCL source code
lengthFixed length of the buffer (in original type size e.g. float,int, ..., etc.)
byteDepthByte depth of the data type (e.g. float = 4, int32 = 4, uchar = 1 ... etc.)
srcOptional source pointer. If not NULL the content of this pointer will automatically be uploaded to the device.
Returns
Pointer to CLBuffer instance

Throws a CLBufferException in case of allocation problems.

◆ createImage2D() [1/2]

CLImage2D icl::utils::CLDeviceContext::createImage2D ( const string &  accessMode,
const size_t  width,
const size_t  height,
int  depth,
const void *  src = 0 
)

createImage2D Creates a image2D object for memory exchange with graphics card memory

Parameters
accessModeaccessMode accessMode can either be "r", "w" or "rw", which refers to the readibility of the data by the OpenCL source code
widthThe width of the image passed
heightThe height of the image passed
depthvarious 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 (WARNING! float64 is not always supported by opencl and thus is not handled in ICL so far)
srcOptional source pointer. If not NULL the content of this pointer will automatically be uploaded to the device.
Returns
CLImage2D instance

In this case, the number of channels are assumed to be equal to one.
Throws a CLBufferException in case of allocation problems.

◆ createImage2D() [2/2]

CLImage2D icl::utils::CLDeviceContext::createImage2D ( const string &  accessMode,
const size_t  width,
const size_t  height,
int  depth,
int  num_channel,
const void *  src = 0 
)

createImage2D

Parameters
accessMode
width
height
depthvarious 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 (WARNING! float64 is not always supported by opencl and thus is not handled in ICL so far)
num_channelThe number of image channels
srcOptional source pointer. If not NULL the content of this pointer will automatically be uploaded to the device.
Returns
CLImage2D instance

Throws a CLBufferException in case of allocation problems.

◆ createImage2DHeap()

CLImage2D* icl::utils::CLDeviceContext::createImage2DHeap ( const string &  accessMode,
const size_t  width,
const size_t  height,
int  depth,
int  num_channel,
const void *  src = 0 
)
private

createImage2DHeap Creates a image2D object pointer for memory exchange with graphics card memory. The pointer has to be handles by the user

Parameters
accessModeaccessMode accessMode can either be "r", "w" or "rw", which refers to the readibility of the data by the OpenCL source code
widthThe width of the image passed
heightThe height of the image passed
depthvarious 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 (WARNING! float64 is not always supported by opencl and thus is not handled in ICL so far)
num_channelThe number of image channels
srcOptional source pointer. If not NULL the content of this pointer will automatically be uploaded to the device.
Returns
pointer to CLImage2D instance

Throws a CLBufferException in case of allocation problems.

◆ getCommandQueue()

cl::CommandQueue& icl::utils::CLDeviceContext::getCommandQueue ( )
private

returns the internal cl command queue structure

◆ getContext()

cl::Context& icl::utils::CLDeviceContext::getContext ( )
private

returns the internal cl context structure

◆ getDevice()

cl::Device& icl::utils::CLDeviceContext::getDevice ( )
private

returns the internal cl device structure

◆ getDeviceTypeString() [1/2]

std::string const icl::utils::CLDeviceContext::getDeviceTypeString ( )

getDeviceTypeString Returns the device type as string

Returns
The device type as string ("gpu" or "cpu")

◆ getDeviceTypeString() [2/2]

std::string const icl::utils::CLDeviceContext::getDeviceTypeString ( ) const

getDeviceTypeString Returns the device type as string (const)

Returns
The device type as string ("gpu" or "cpu")

◆ listAllPlatforms()

static void icl::utils::CLDeviceContext::listAllPlatforms ( )
static

lists various properties of all platforms

◆ listAllPlatformsAndDevices()

static void icl::utils::CLDeviceContext::listAllPlatformsAndDevices ( )
static

lists various properties of all platforms and their devices

◆ listSelectedDevice()

void icl::utils::CLDeviceContext::listSelectedDevice ( )

lists various properties of the selected device

◆ listSelectedPlatform()

void icl::utils::CLDeviceContext::listSelectedPlatform ( )

lists various properties of the selected platform

◆ operator=()

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

operator = shallowly copies from other CLDeviceContext

Parameters
other
Returns

Friends And Related Function Documentation

◆ CLMemoryAssistant

friend class CLMemoryAssistant
friend

for tight integration with CLMemoryAssistant instances

◆ CLProgram

friend class CLProgram
friend

for tight integration with CLProgram instances

Member Data Documentation

◆ impl

Impl* icl::utils::CLDeviceContext::impl
private

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