Image Component Library (ICL)
Public Types | Public Member Functions | Protected Attributes | List of all members
icl::utils::CLMemoryAssistant Class Reference

The CLMemoryAssistant class is a helper class to maintain buffers and images for opencl-program pipelines. More...

#include <CLMemoryAssistant.h>

Public Types

typedef std::string MemKeyType
 
typedef std::map< MemKeyType, CLMemory * > CLMemoryMap
 

Public Member Functions

 CLMemoryAssistant ()
 CLMemoryAssistant Default constructor, creates a dummy instance. More...
 
 CLMemoryAssistant (std::string const &deviceType)
 CLMemoryAssistant Creates an instance for the given device type (see CLDeviceContext for details) More...
 
 ~CLMemoryAssistant ()
 Destructor. More...
 
CLBuffer createNamedBuffer (MemKeyType const &key, const string &accessMode, const size_t length, const size_t byteDepth, const void *src=0)
 createNamedBuffer creates a CLBuffer object (internally handled as a CLMemory-pointer) More...
 
CLImage2D createNamedImage2D (MemKeyType const &key, const string &accessMode, const size_t width, const size_t height, const int depth, const int num_channel, const void *src=0)
 createNamedImage2D creates a Image2D object (internally handled as a CLMemory-pointer) More...
 
CLMemoryoperator[] (MemKeyType const &key)
 operator [] Direct access operator to the internal CLMemory More...
 
CLBufferasBuf (MemKeyType const &key)
 asBuf shortcut to access and cast the internal CLMemory instance (CLBuffer) More...
 
CLImage2DasImg (MemKeyType const &key)
 asBuf shortcut to access and cast the internal CLMemory instance (CLBuffer) More...
 
bool keyExist (MemKeyType const &key)
 keyExist Returns true if the given key exists in this instance More...
 
void clearAll ()
 clearAll clears and deletes all internal buffers. Use with care! More...
 
void remove (MemKeyType const &key)
 remove removes and deletes the CLMemory instance for key if available More...
 
CLDeviceContext const & getDeviceContext ()
 getDeviceContext returns the used device context that can be shared with CLProgram instances More...
 

Protected Attributes

CLDeviceContext m_context
 device context used More...
 
CLMemoryMap m_memory_map
 the map for internal storage More...
 

Detailed Description

The CLMemoryAssistant class is a helper class to maintain buffers and images for opencl-program pipelines.

In case of a pipeline of operators that use a CLProgram internally one can use the CLMemoryAssistant to instanciate a CLDeviceContext and create shared buffers and images for the device. So far, all implementations of an opencl program need to allow to pass CLBuffer or CLImage2D instances as in and output.

Member Typedef Documentation

◆ CLMemoryMap

◆ MemKeyType

Constructor & Destructor Documentation

◆ CLMemoryAssistant() [1/2]

icl::utils::CLMemoryAssistant::CLMemoryAssistant ( )

CLMemoryAssistant Default constructor, creates a dummy instance.

◆ CLMemoryAssistant() [2/2]

icl::utils::CLMemoryAssistant::CLMemoryAssistant ( std::string const &  deviceType)

CLMemoryAssistant Creates an instance for the given device type (see CLDeviceContext for details)

Parameters
deviceTypeDevice to use (see CLDeviceContext for details)

◆ ~CLMemoryAssistant()

icl::utils::CLMemoryAssistant::~CLMemoryAssistant ( )

Destructor.

Member Function Documentation

◆ asBuf()

CLBuffer& icl::utils::CLMemoryAssistant::asBuf ( MemKeyType const &  key)

asBuf shortcut to access and cast the internal CLMemory instance (CLBuffer)

Parameters
keyThe name (std::string) and identifier for this CLMemory instance
Returns
CLImage2D instance

◆ asImg()

CLImage2D& icl::utils::CLMemoryAssistant::asImg ( MemKeyType const &  key)

asBuf shortcut to access and cast the internal CLMemory instance (CLBuffer)

Parameters
keyThe name (std::string) and identifier for this CLMemory instance
Returns
CLImage2D instance

◆ clearAll()

void icl::utils::CLMemoryAssistant::clearAll ( )

clearAll clears and deletes all internal buffers. Use with care!

◆ createNamedBuffer()

CLBuffer icl::utils::CLMemoryAssistant::createNamedBuffer ( MemKeyType const &  key,
const string &  accessMode,
const size_t  length,
const size_t  byteDepth,
const void *  src = 0 
)

createNamedBuffer creates a CLBuffer object (internally handled as a CLMemory-pointer)

Parameters
keyThe name (std::string) and identifier for this CLMemory instance

Please see CLDeviceContext::createBuffer() for more details

◆ createNamedImage2D()

CLImage2D icl::utils::CLMemoryAssistant::createNamedImage2D ( MemKeyType const &  key,
const string &  accessMode,
const size_t  width,
const size_t  height,
const int  depth,
const int  num_channel,
const void *  src = 0 
)

createNamedImage2D creates a Image2D object (internally handled as a CLMemory-pointer)

Parameters
keyThe name (std::string) and identifier for this CLMemory instance

Please see CLDeviceContext::createImage2D() for more details

◆ getDeviceContext()

CLDeviceContext const& icl::utils::CLMemoryAssistant::getDeviceContext ( )
inline

getDeviceContext returns the used device context that can be shared with CLProgram instances

Returns
the internal CLDeviceContext instance

◆ keyExist()

bool icl::utils::CLMemoryAssistant::keyExist ( MemKeyType const &  key)
inline

keyExist Returns true if the given key exists in this instance

Parameters
keyThe name (std::string) and identifier for this CLMemory instance
Returns
true if the key exists, false otherwise

◆ operator[]()

CLMemory* icl::utils::CLMemoryAssistant::operator[] ( MemKeyType const &  key)

operator [] Direct access operator to the internal CLMemory

Parameters
keyThe name (std::string) and identifier for this CLMemory instance
Returns
CLMemory pointer

◆ remove()

void icl::utils::CLMemoryAssistant::remove ( MemKeyType const &  key)

remove removes and deletes the CLMemory instance for key if available

Parameters
keyIdentifier of the memory object to remove from this instance

Member Data Documentation

◆ m_context

CLDeviceContext icl::utils::CLMemoryAssistant::m_context
protected

device context used

◆ m_memory_map

CLMemoryMap icl::utils::CLMemoryAssistant::m_memory_map
protected

the map for internal storage


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