Compute Library
 20.11
CLArray< T > Class Template Reference

CLArray implementation. More...

#include <CLArray.h>

Collaboration diagram for CLArray< T >:
[legend]

Public Member Functions

 CLArray ()
 Default constructor: empty array. More...
 
 CLArray (const CLArray &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLArrayoperator= (const CLArray &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLArray (CLArray &&)=default
 Allow instances of this class to be move constructed. More...
 
CLArrayoperator= (CLArray &&)=default
 Allow instances of this class to be moved. More...
 
 CLArray (size_t max_num_values)
 Constructor: initializes an array which can contain up to max_num_points values. More...
 
void map (bool blocking=true)
 Enqueue a map operation of the allocated buffer. More...
 
void unmap ()
 Enqueue an unmap operation of the allocated and mapped buffer. More...
 
const cl::Buffer & cl_buffer () const override
 Interface to be implemented by the child class to return a reference to the OpenCL buffer containing the array's data. More...
 
- Public Member Functions inherited from ICLArray< T >
 ICLArray (size_t max_num_values)
 Constructor. More...
 
 ICLArray (const ICLArray &)=delete
 Prevent instances of this class from being copy constructed. More...
 
ICLArrayoperator= (const ICLArray &)=delete
 Prevent instances of this class from being copied. More...
 
 ICLArray (ICLArray &&)=default
 Allow instances of this class to be move constructed. More...
 
ICLArrayoperator= (ICLArray &&)=default
 Allow instances of this class to be moved. More...
 
virtual ~ICLArray ()=default
 Default virtual destructor. More...
 
void map (cl::CommandQueue &q, bool blocking=true)
 Enqueue a map operation of the allocated buffer on the given queue. More...
 
void unmap (cl::CommandQueue &q)
 Enqueue an unmap operation of the allocated and mapped buffer on the given queue. More...
 
T * buffer () const override
 Pointer to the first element of the array. More...
 
- Public Member Functions inherited from IArray< T >
 IArray ()
 Default constructor. More...
 
 IArray (size_t max_num_values)
 Constructor: initializes an array which can contain up to max_num_points values. More...
 
size_t max_num_values () const
 Maximum number of values which can be stored in this array. More...
 
virtual ~IArray ()=default
 Default virtual destructor. More...
 
size_t num_values () const
 Number of values currently stored in the array. More...
 
bool push_back (const T &val)
 Append the passed argument to the end of the array if there is room. More...
 
void clear ()
 Clear all the points from the array. More...
 
bool overflow () const
 Did we lose some values because the array is too small? More...
 
virtual T & at (size_t index) const
 Reference to the element of the array located at the given index. More...
 
void resize (size_t num)
 Resizes the array to contain "num" elements. More...
 

Detailed Description

template<class T>
class arm_compute::CLArray< T >

CLArray implementation.

Definition at line 37 of file CLArray.h.

Constructor & Destructor Documentation

◆ CLArray() [1/4]

CLArray ( )
inline

Default constructor: empty array.

Definition at line 41 of file CLArray.h.

42  : ICLArray<T>(0), _buffer()
43  {
44  }

◆ CLArray() [2/4]

CLArray ( const CLArray< T > &  )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ CLArray() [3/4]

CLArray ( CLArray< T > &&  )
default

Allow instances of this class to be move constructed.

◆ CLArray() [4/4]

CLArray ( size_t  max_num_values)
inline

Constructor: initializes an array which can contain up to max_num_points values.

Parameters
[in]max_num_valuesMaximum number of values the array will be able to stored

Definition at line 57 of file CLArray.h.

58  : ICLArray<T>(max_num_values), _buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, max_num_values * sizeof(T))
59  {
60  }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:99
size_t max_num_values() const
Maximum number of values which can be stored in this array.
Definition: IArray.h:58

Member Function Documentation

◆ cl_buffer()

const cl::Buffer& cl_buffer ( ) const
inlineoverridevirtual

Interface to be implemented by the child class to return a reference to the OpenCL buffer containing the array's data.

Returns
A reference to an OpenCL buffer containing the array's data.

Implements ICLArray< T >.

Definition at line 84 of file CLArray.h.

85  {
86  return _buffer;
87  }

◆ map()

void map ( bool  blocking = true)
inline

Enqueue a map operation of the allocated buffer.

Parameters
[in]blockingIf true, then the mapping will be ready to use by the time this method returns, else it is the caller's responsibility to flush the queue and wait for the mapping operation to have completed.

Definition at line 67 of file CLArray.h.

68  {
69  ICLArray<T>::map(CLScheduler::get().queue(), blocking);
70  }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:99
void map(cl::CommandQueue &q, bool blocking=true)
Enqueue a map operation of the allocated buffer on the given queue.
Definition: ICLArray.h:72

◆ operator=() [1/2]

CLArray& operator= ( const CLArray< T > &  )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

CLArray& operator= ( CLArray< T > &&  )
default

Allow instances of this class to be moved.

◆ unmap()

void unmap ( )
inline

Enqueue an unmap operation of the allocated and mapped buffer.

Note
This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before the memory is accessed by the device.

Definition at line 77 of file CLArray.h.

78  {
80  }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:99
void unmap(cl::CommandQueue &q)
Enqueue an unmap operation of the allocated and mapped buffer on the given queue.
Definition: ICLArray.h:83

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