Loading...
Searching...
No Matches
itk::OpenCLVector< T > Class Template Reference

`#include <itkOpenCLVector.h>`

## Detailed Description

template<typename T>
class itk::OpenCLVector< T >

The OpenCLVector class represents a templated OpenCL buffer object.

OpenCLVector is a convenience template class that wraps an OpenCL buffer object to make it appear as a host-accessible array of elements of type T.

Whenever the host CPU calls operator[](), the array's contents are copied into host-accessible memory for direct access. When the host sets the vector on a OpenCLKernel as an argument, the data is copied back to the OpenCL compute device (e.g., the GPU).

The type T is restricted to primitive and movable types that do not require explicit construction, destruction, or operator=(). T can have constructors, but they will not be called. This is because the data will be copied to the OpenCL device in a different address space, and the OpenCL device will not know how to construct, destruct, or copy the data in a C++-compatible manner.

Elements of a buffer object can be a scalar data type (such as an int, float), vector data type, or a user-defined structure, not std::string.

Definition at line 52 of file itkOpenCLVector.h.

Inheritance diagram for itk::OpenCLVector< T >:
[legend]

## Public Types

using | Self = OpenCLVector

## Public Member Functions

OpenCLBuffer | GetBuffer () const
OpenCLContext * | GetContext () const
std::vcl_size_t | GetSize () const
bool | IsEmpty () const
bool | IsNull () const
| OpenCLVector ()
| OpenCLVector (const OpenCLVector< T > &other)
OpenCLVector< T > & | operator= (const OpenCLVector< T > &other)
T & | operator[] (const std::vcl_size_t index)
const T & | operator[] (const std::vcl_size_t index) const
void | Read (T *data, const std::vcl_size_t count, const std::vcl_size_t offset=0)
void | Release ()
void | Write (const T *data, const std::vcl_size_t count, const std::vcl_size_t offset=0)
void | Write (const Vector< T > &data, const std::vcl_size_t offset=0)
| ~OpenCLVector ()

## Private Member Functions

| OpenCLVector (OpenCLContext *context, const OpenCLMemoryObject::Access access, const std::vcl_size_t size)

## Friends

class | OpenCLContext

## Additional Inherited Members

Protected Member Functions inherited from itk::OpenCLVectorBase
void | Assign (const OpenCLVectorBase &other)
void | Create (OpenCLContext *context, const OpenCLMemoryObject::Access access, const std::vcl_size_t size)
OpenCLContext * | GetContext () const
cl_mem | GetKernelArgument () const
cl_mem | GetMemoryId () const
void | Map ()
| OpenCLVectorBase (const std::vcl_size_t elemSize)
| OpenCLVectorBase (const std::vcl_size_t elemSize, const OpenCLVectorBase &other)
void | Read (void *data, const std::vcl_size_t size, const std::vcl_size_t offset=0)
void | Release ()
void | Unmap () const
void | Write (const void *data, const std::vcl_size_t size, const std::vcl_size_t offset=0)
| ~OpenCLVectorBase ()
Protected Attributes inherited from itk::OpenCLVectorBase
OpenCLVectorBasePimpl * | d_ptr
std::vcl_size_t | m_ElementSize
void * | m_Mapped
std::vcl_size_t | m_Size

## Member Typedef Documentation

## Self

template<typename T>

using itk::OpenCLVector< T >::Self = OpenCLVector

Standard class typedefs.

Definition at line 56 of file itkOpenCLVector.h.

## Constructor & Destructor Documentation

## OpenCLVector() [1/3]

template<typename T>

itk::OpenCLVector< T >::OpenCLVector | ( |  | ) |

Creates a null OpenCL vector.

See also
  IsNull()

## OpenCLVector() [2/3]

template<typename T>

itk::OpenCLVector< T >::OpenCLVector | ( | const OpenCLVector< T > & | other | ) |

Creates a copy of the other vector reference. The vector's contents are not duplicated, modifications to this vector will also affect other.

See also
  operator=()

## ~OpenCLVector()

template<typename T>

itk::OpenCLVector< T >::~OpenCLVector | ( |  | ) |

Destroys this vector reference. If this is the last reference to the underlying data, the vector will be unmapped and deallocated.

## OpenCLVector() [3/3]

template<typename T>

itk::OpenCLVector< T >::OpenCLVector | ( | OpenCLContext * | context,
|  | const OpenCLMemoryObject::Access | access,
|  | const std::vcl_size_t | size )

private

Constructs an OpenCL vector object of size and associates it with context.

## Member Function Documentation

## GetBuffer()

template<typename T>

OpenCLBuffer itk::OpenCLVector< T >::GetBuffer | ( |  | ) | const

Returns the OpenCL buffer handle for this vector.

## GetContext()

template<typename T>

OpenCLContext * itk::OpenCLVector< T >::GetContext | ( |  | ) | const

Returns the OpenCL context that was used to create this vector.

## GetSize()

template<typename T>

std::vcl_size_t itk::OpenCLVector< T >::GetSize | ( |  | ) | const

inline

Returns the number of elements of type T in this OpenCL vector.

Definition at line 97 of file itkOpenCLVector.h.

## IsEmpty()

template<typename T>

bool itk::OpenCLVector< T >::IsEmpty | ( |  | ) | const

inline

Returns true if this OpenCL vector is empty, false otherwise.

Definition at line 90 of file itkOpenCLVector.h.

## IsNull()

template<typename T>

bool itk::OpenCLVector< T >::IsNull | ( |  | ) | const

Returns true if this vector is null, false otherwise.

## operator=()

template<typename T>

OpenCLVector< T > & itk::OpenCLVector< T >::operator= | ( | const OpenCLVector< T > & | other | ) |

Assigns the other vector reference to this object. The vector's contents are not duplicated, modifications to this vector will also affect other.

## operator[]() [1/2]

template<typename T>

T & itk::OpenCLVector< T >::operator[] | ( | const std::vcl_size_t | index | ) |

Returns a reference to the element at index in this OpenCL vector. The vector will be copied to host memory if necessary.

## operator[]() [2/2]

template<typename T>

const T & itk::OpenCLVector< T >::operator[] | ( | const std::vcl_size_t | index | ) | const

Returns a const reference to the element at index in this OpenCL vector. The vector will be copied to host memory if necessary.

## Read()

template<typename T>

void itk::OpenCLVector< T >::Read | ( | T * | data,
|  | const std::vcl_size_t | count,
|  | const std::vcl_size_t | offset = 0 )

Reads the count elements starting offset in this vector into data.

See also
  Write()

## Release()

template<typename T>

void itk::OpenCLVector< T >::Release | ( |  | ) |

Releases the contents of this OpenCL vector. If not explicitly released, the contents will be implicitly released when the vector is destroyed.

## Write() [1/2]

template<typename T>

void itk::OpenCLVector< T >::Write | ( | const T * | data,
|  | const std::vcl_size_t | count,
|  | const std::vcl_size_t | offset = 0 )

Writes the count elements from data to offset in this vector.

See also
  Read()

## Write() [2/2]

template<typename T>

void itk::OpenCLVector< T >::Write | ( | const Vector< T > & | data,
|  | const std::vcl_size_t | offset = 0 )

Writes the contents of data to offset in this vector.

## Friends And Related Symbol Documentation

## OpenCLContext

template<typename T>

friend class OpenCLContext

friend

friends from OpenCL core

Definition at line 140 of file itkOpenCLVector.h.

Generated on 1768596610 for elastix by 1.15.0 |