Compute Library
 22.05
ICLMemoryRegion Class Referenceabstract

OpenCL memory region interface. More...

#include <CLMemoryRegion.h>

Collaboration diagram for ICLMemoryRegion:
[legend]

Public Member Functions

 ICLMemoryRegion (size_t size)
 Constructor. More...
 
virtual ~ICLMemoryRegion ()=default
 Default Destructor. More...
 
 ICLMemoryRegion (const ICLMemoryRegion &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICLMemoryRegion (ICLMemoryRegion &&)=default
 Default move constructor. More...
 
ICLMemoryRegionoperator= (const ICLMemoryRegion &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICLMemoryRegionoperator= (ICLMemoryRegion &&)=default
 Default move assignment operator. More...
 
const cl::Buffer & cl_data () const
 Returns the underlying CL buffer. More...
 
virtual void * ptr ()=0
 Host/SVM pointer accessor. More...
 
virtual void * map (cl::CommandQueue &q, bool blocking)=0
 Enqueue a map operation of the allocated buffer on the given queue. More...
 
virtual void unmap (cl::CommandQueue &q)=0
 Enqueue an unmap operation of the allocated buffer on the given queue. More...
 
void * buffer () override
 Returns the pointer to the allocated data. More...
 
const void * buffer () const override
 Returns the pointer to the allocated data. More...
 
std::unique_ptr< IMemoryRegionextract_subregion (size_t offset, size_t size) override
 Extract a sub-region from the memory. More...
 
- Public Member Functions inherited from IMemoryRegion
 IMemoryRegion (size_t size)
 Default constructor. More...
 
virtual ~IMemoryRegion ()=default
 Virtual Destructor. More...
 
size_t size () const
 Memory region size accessor. More...
 
void set_size (size_t size)
 Sets size of region. More...
 

Detailed Description

OpenCL memory region interface.

Definition at line 35 of file CLMemoryRegion.h.

Constructor & Destructor Documentation

◆ ICLMemoryRegion() [1/3]

ICLMemoryRegion ( size_t  size)

Constructor.

Parameters
[in]sizeRegion size

Definition at line 31 of file CLMemoryRegion.cpp.

Referenced by CLBufferMemoryRegion::unmap().

33  _queue(CLScheduler::get().queue()),
34  _ctx(CLScheduler::get().context()),
35  _mapping(nullptr),
36  _mem()
37 {
38 }
static CLScheduler & get()
Access the scheduler singleton.
IMemoryRegion(size_t size)
Default constructor.
Definition: IMemoryRegion.h:40
size_t size() const
Memory region size accessor.
Definition: IMemoryRegion.h:73

◆ ~ICLMemoryRegion()

virtual ~ICLMemoryRegion ( )
virtualdefault

Default Destructor.

◆ ICLMemoryRegion() [2/3]

ICLMemoryRegion ( const ICLMemoryRegion )
delete

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

◆ ICLMemoryRegion() [3/3]

ICLMemoryRegion ( ICLMemoryRegion &&  )
default

Default move constructor.

Member Function Documentation

◆ buffer() [1/2]

void * buffer ( )
overridevirtual

Returns the pointer to the allocated data.

Returns
Pointer to the allocated data

Implements IMemoryRegion.

Definition at line 45 of file CLMemoryRegion.cpp.

Referenced by CLBufferMemoryRegion::CLBufferMemoryRegion().

46 {
47  return _mapping;
48 }

◆ buffer() [2/2]

const void * buffer ( ) const
overridevirtual

Returns the pointer to the allocated data.

Returns
Pointer to the allocated data

Implements IMemoryRegion.

Definition at line 50 of file CLMemoryRegion.cpp.

51 {
52  return _mapping;
53 }

◆ cl_data()

const cl::Buffer & cl_data ( ) const

Returns the underlying CL buffer.

Returns
CL memory buffer object

Definition at line 40 of file CLMemoryRegion.cpp.

Referenced by CLTensorAllocator::cl_data(), and CLTensorAllocator::set_associated_memory_group().

41 {
42  return _mem;
43 }

◆ extract_subregion()

std::unique_ptr< IMemoryRegion > extract_subregion ( size_t  offset,
size_t  size 
)
overridevirtual

Extract a sub-region from the memory.

Warning
Ownership is maintained by the parent memory, while a wrapped raw memory region is returned by this function. Thus parent memory should not be released before this.
Parameters
[in]offsetOffset to the region
[in]sizeSize of the region
Returns
A wrapped memory sub-region with no ownership of the underlying memory

Implements IMemoryRegion.

Definition at line 55 of file CLMemoryRegion.cpp.

References ARM_COMPUTE_UNUSED.

56 {
58  return nullptr;
59 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:1083
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
size_t size() const
Memory region size accessor.
Definition: IMemoryRegion.h:73

◆ map()

virtual void* map ( cl::CommandQueue &  q,
bool  blocking 
)
pure virtual

Enqueue a map operation of the allocated buffer on the given queue.

Parameters
[in,out]qThe CL command queue to use for the mapping operation.
[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 before using the returned mapping pointer.
Returns
The mapping address.

Implemented in CLFineSVMMemoryRegion, CLCoarseSVMMemoryRegion, and CLBufferMemoryRegion.

Referenced by CLTensorAllocator::map().

◆ operator=() [1/2]

ICLMemoryRegion& operator= ( const ICLMemoryRegion )
delete

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

◆ operator=() [2/2]

ICLMemoryRegion& operator= ( ICLMemoryRegion &&  )
default

Default move assignment operator.

◆ ptr()

virtual void* ptr ( )
pure virtual

Host/SVM pointer accessor.

Returns
Host/SVM pointer base

Implemented in CLBufferMemoryRegion.

◆ unmap()

virtual void unmap ( cl::CommandQueue &  q)
pure virtual

Enqueue an unmap operation of the allocated buffer on the given queue.

Note
This method simply enqueue 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.
Parameters
[in,out]qThe CL command queue to use for the mapping operation.

Implemented in CLFineSVMMemoryRegion, CLCoarseSVMMemoryRegion, and CLBufferMemoryRegion.

Referenced by CLTensorAllocator::unmap().


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