Compute Library
 21.05
ICLMemoryRegion Class Referenceabstract

OpenCL memory region interface. More...

#include <CLMemoryRegion.h>

Collaboration diagram for ICLMemoryRegion:
[legend]

Public Member Functions

 ICLMemoryRegion (CLCoreRuntimeContext *ctx, 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 36 of file CLMemoryRegion.h.

Constructor & Destructor Documentation

◆ ICLMemoryRegion() [1/3]

ICLMemoryRegion ( CLCoreRuntimeContext ctx,
size_t  size 
)

Constructor.

Parameters
[in]ctxRuntime context
[in]sizeRegion size

Definition at line 32 of file CLMemoryRegion.cpp.

34  _queue((ctx != nullptr) ? ctx->queue() : CLScheduler::get().queue()),
35  _ctx((ctx != nullptr) ? ctx->context() : CLScheduler::get().context()),
36  _mapping(nullptr),
37  _mem()
38 {
39 }
static CLScheduler & get()
Access the scheduler singleton.
cl::Context & context()
Accessor for the associated CL context.
Definition: CLScheduler.cpp:32
IMemoryRegion(size_t size)
Default constructor.
Definition: IMemoryRegion.h:40
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
Definition: CLScheduler.cpp:39
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 46 of file CLMemoryRegion.cpp.

47 {
48  return _mapping;
49 }

Referenced by CLBufferMemoryRegion::CLBufferMemoryRegion().

◆ 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 51 of file CLMemoryRegion.cpp.

52 {
53  return _mapping;
54 }

◆ cl_data()

const cl::Buffer & cl_data ( ) const

Returns the underlying CL buffer.

Returns
CL memory buffer object

Definition at line 41 of file CLMemoryRegion.cpp.

42 {
43  return _mem;
44 }

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

◆ 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 56 of file CLMemoryRegion.cpp.

57 {
59  return nullptr;
60 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:861
#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

References ARM_COMPUTE_UNUSED, offset(), and IMemoryRegion::size().

◆ 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: