Accelerated Computation Engine
|
#include <opencl_buffer.h>
Public Member Functions | |
void | operator= (Buffer< T > &&other) |
T & | operator[] (int index) |
Buffer ()=default | |
Buffer (Context *context, int size) | |
Buffer (Buffer< T > &&other) | |
~Buffer () | |
const T & | at (int index) const |
bool | isNull () const |
cl_mem | id () const |
int | size () const |
Event | mapRead (CommandQueue *queue) |
Event | mapWrite (CommandQueue *queue) |
Event | unmap (CommandQueue *queue) |
T * | data () |
This can contain an OpenCL buffer object or be set to null. The buffer this class contains can be moved to another instance but not copied. This is a template class to enforce strong type checking of the underlying buffer data. This class provides methods for mapping the OpenCL buffer memory to a temporary host pointer and can be accessed through other helper methods that provides range checking or through a raw memory pointer. Other methods are provided for getting the size of the buffer and the underlying OpenCL memory ID used by other OpenCL classes.
T | The type used to create the buffer data of this object. |
|
default |
Constructs a new buffer object that is set to null.
OpenCL::Buffer< T >::Buffer | ( | Context * | context, |
int | size | ||
) |
Constructs a new buffer object set to a new OpenCL buffer with the given context and size.
context | Pointer to context that this buffer object is created from. |
size | The size of the buffer created as the number of elements of the template type defined. |
OpenCL::Buffer< T >::Buffer | ( | Buffer< T > && | other | ) |
Constructs a new buffer object taking the state of the other given buffer object.
other | The other buffer object whose state, null or set to an OpenCL buffer, is taken by this new buffer object. |
OpenCL::Buffer< T >::~Buffer | ( | ) |
Clears all resources this buffer object may contain.
const T & OpenCL::Buffer< T >::at | ( | int | index | ) | const |
Returns a read only reference to the element with the given index in this buffer object's mapped data for reading. If this buffer object is not mapped, the mapping is not for reading, or the index is out of range then an exception is thrown.
index |
T * OpenCL::Buffer< T >::data | ( | ) |
Returns the host memory pointer of this object's mapped OpenCL buffer data. If this object's buffer is not mapped then an exception is thrown. Care must be taken to only read or write to this pointer depending on what type of mapping it is. Reading from a write mapping or writing to a read mapping is undefined.
cl_mem OpenCL::Buffer< T >::id | ( | ) | const |
bool OpenCL::Buffer< T >::isNull | ( | ) | const |
Tests if this buffer object is null or contains an OpenCL buffer.
Event OpenCL::Buffer< T >::mapRead | ( | CommandQueue * | queue | ) |
Maps this object's OpenCL buffer data to a host memory pointer for reading that can be accessed through other methods of this class. The command to map memory is sent to the given command queue and is not complete until the returned event is complete. If this object is null or is already mapped then an exception is thrown.
queue | Pointer to the command queue used to add the OpenCL command for mapping the memory. |
Event OpenCL::Buffer< T >::mapWrite | ( | CommandQueue * | queue | ) |
Maps this object's OpenCL buffer data to a host memory pointer for writing that can be accessed through other methods of this class. The command to map memory is sent to the given command queue and is not complete until the returned event is complete. If this object is null or is already mapped then an exception is thrown.
queue | Pointer to the command queue used to add the OpenCL command for mapping the memory. |
void OpenCL::Buffer< T >::operator= | ( | Buffer< T > && | other | ) |
T & OpenCL::Buffer< T >::operator[] | ( | int | index | ) |
Returns a reference to the element with the given index in this buffer object's mapped data for writing. If this buffer object is not mapped, the mapping is not for writing, or the index is out of range then an exception is thrown.
index | The index of the element whose reference is returned. |
int OpenCL::Buffer< T >::size | ( | ) | const |
Returns the size of this object's OpenCL buffer as the number of elements of the template type defined. If this object is null then -1 is returned.
Event OpenCL::Buffer< T >::unmap | ( | CommandQueue * | queue | ) |
Unmaps this object's OpenCL buffer data from host memory. The command to unmap memory is sent to the given command queue and is not complete until the returned event is complete. If the object is null or is not mapped then an exception is thrown.
queue | Pointer to the command queue used to add the OpenCL command for unmapping the memory. |