Compute Library
 22.08
CLCoarseSVMMemoryRegion Class Referencefinal

OpenCL coarse-grain SVM memory region implementation. More...

#include <CLMemoryRegion.h>

Collaboration diagram for CLCoarseSVMMemoryRegion:
[legend]

Public Member Functions

 CLCoarseSVMMemoryRegion (cl_mem_flags flags, size_t size, size_t alignment)
 Constructor. More...
 
void * map (cl::CommandQueue &q, bool blocking) final
 Enqueue a map operation of the allocated buffer on the given queue. More...
 
void unmap (cl::CommandQueue &q) final
 Enqueue an unmap operation of the allocated buffer on the given queue. More...
 
- Public Member Functions inherited from ICLMemoryRegion
 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...
 
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 coarse-grain SVM memory region implementation.

Definition at line 146 of file CLMemoryRegion.h.

Constructor & Destructor Documentation

◆ CLCoarseSVMMemoryRegion()

CLCoarseSVMMemoryRegion ( cl_mem_flags  flags,
size_t  size,
size_t  alignment 
)

Constructor.

Parameters
[in]flagsMemory flags
[in]sizeRegion size
[in]alignmentAlignment

Definition at line 129 of file CLMemoryRegion.cpp.

130  : ICLSVMMemoryRegion(flags, size, alignment)
131 {
132 }
size_t size() const
Memory region size accessor.
Definition: IMemoryRegion.h:73

Member Function Documentation

◆ map()

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

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.

Implements ICLMemoryRegion.

Definition at line 134 of file CLMemoryRegion.cpp.

References ARM_COMPUTE_ERROR_ON, and clEnqueueSVMMap().

135 {
136  ARM_COMPUTE_ERROR_ON(_ptr == nullptr);
137  clEnqueueSVMMap(q.get(), blocking ? CL_TRUE : CL_FALSE, CL_MAP_READ | CL_MAP_WRITE, _ptr, _size, 0, nullptr, nullptr);
138  _mapping = _ptr;
139  return _mapping;
140 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
cl_int clEnqueueSVMMap(cl_command_queue command_queue, cl_bool blocking_map, cl_map_flags flags, void *svm_ptr, size_t size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
Definition: OpenCL.cpp:242

◆ unmap()

void unmap ( cl::CommandQueue &  q)
finalvirtual

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.

Implements ICLMemoryRegion.

Definition at line 142 of file CLMemoryRegion.cpp.

References ARM_COMPUTE_ERROR_ON, and clEnqueueSVMUnmap().

143 {
144  ARM_COMPUTE_ERROR_ON(_ptr == nullptr);
145  clEnqueueSVMUnmap(q.get(), _ptr, 0, nullptr, nullptr);
146  _mapping = nullptr;
147 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
cl_int clEnqueueSVMUnmap(cl_command_queue command_queue, void *svm_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
Definition: OpenCL.cpp:257

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