Compute Library
 21.05
CLMemory Class Reference

OpenCL implementation of memory object. More...

#include <CLMemory.h>

Collaboration diagram for CLMemory:
[legend]

Public Member Functions

 CLMemory ()
 Default Constructor. More...
 
 CLMemory (const std::shared_ptr< ICLMemoryRegion > &memory)
 Default Constructor. More...
 
 CLMemory (ICLMemoryRegion *memory)
 Default Constructor. More...
 
 CLMemory (const CLMemory &)=default
 Allow instances of this class to be copied. More...
 
CLMemoryoperator= (const CLMemory &)=default
 Allow instances of this class to be copy assigned. More...
 
 CLMemory (CLMemory &&) noexcept=default
 Allow instances of this class to be moved. More...
 
CLMemoryoperator= (CLMemory &&) noexcept=default
 Allow instances of this class to be move assigned. More...
 
ICLMemoryRegioncl_region ()
 OpenCL Region accessor. More...
 
ICLMemoryRegioncl_region () const
 OpenCL Region accessor. More...
 
IMemoryRegionregion () final
 Region accessor. More...
 
IMemoryRegionregion () const final
 Region accessor. More...
 
void set_region (IMemoryRegion *region) final
 Sets a memory region. More...
 
void set_owned_region (std::unique_ptr< IMemoryRegion > region) final
 Sets a memory region. More...
 
- Public Member Functions inherited from IMemory
virtual ~IMemory ()=default
 Virtual default destructor. More...
 

Detailed Description

OpenCL implementation of memory object.

Definition at line 38 of file CLMemory.h.

Constructor & Destructor Documentation

◆ CLMemory() [1/5]

CLMemory ( )

Default Constructor.

Definition at line 31 of file CLMemory.cpp.

32  : _region(nullptr), _region_owned(nullptr)
33 {
34 }

◆ CLMemory() [2/5]

CLMemory ( const std::shared_ptr< ICLMemoryRegion > &  memory)

Default Constructor.

Parameters
[in]memoryMemory to be imported

Definition at line 36 of file CLMemory.cpp.

37  : _region(nullptr), _region_owned(memory)
38 {
39  _region_owned = memory;
40  _region = _region_owned.get();
41 }

◆ CLMemory() [3/5]

CLMemory ( ICLMemoryRegion memory)

Default Constructor.

Note
Ownership of the memory is not transferred to this object. Thus management (allocate/free) should be done by the client.
Parameters
[in]memoryMemory to be imported

Definition at line 43 of file CLMemory.cpp.

44  : _region(memory), _region_owned(nullptr)
45 {
46  _region = memory;
47 }

◆ CLMemory() [4/5]

CLMemory ( const CLMemory )
default

Allow instances of this class to be copied.

◆ CLMemory() [5/5]

CLMemory ( CLMemory &&  )
defaultnoexcept

Allow instances of this class to be moved.

Member Function Documentation

◆ cl_region() [1/2]

ICLMemoryRegion * cl_region ( )

OpenCL Region accessor.

Returns
Memory region

Definition at line 49 of file CLMemory.cpp.

50 {
51  return _region;
52 }

Referenced by CLTensorAllocator::cl_data(), CLTensorAllocator::map(), CLTensorAllocator::set_associated_memory_group(), CLMemory::set_region(), and CLTensorAllocator::unmap().

◆ cl_region() [2/2]

ICLMemoryRegion * cl_region ( ) const

OpenCL Region accessor.

Returns
Memory region

Definition at line 54 of file CLMemory.cpp.

55 {
56  return _region;
57 }

◆ operator=() [1/2]

CLMemory& operator= ( const CLMemory )
default

Allow instances of this class to be copy assigned.

◆ operator=() [2/2]

CLMemory& operator= ( CLMemory &&  )
defaultnoexcept

Allow instances of this class to be move assigned.

◆ region() [1/2]

IMemoryRegion * region ( )
finalvirtual

Region accessor.

Returns
Memory region

Implements IMemory.

Definition at line 59 of file CLMemory.cpp.

60 {
61  return _region;
62 }

Referenced by CLTensorAllocator::cl_data(), CLTensorAllocator::map(), CLTensorAllocator::set_associated_memory_group(), CLMemory::set_owned_region(), CLMemory::set_region(), and CLTensorAllocator::unmap().

◆ region() [2/2]

IMemoryRegion * region ( ) const
finalvirtual

Region accessor.

Returns
Memory region

Implements IMemory.

Definition at line 64 of file CLMemory.cpp.

65 {
66  return _region;
67 }

◆ set_owned_region()

void set_owned_region ( std::unique_ptr< IMemoryRegion region)
finalvirtual

Sets a memory region.

Warning
Ownership of the memory region is transfered along
Parameters
regionMemory region

Implements IMemory.

Definition at line 76 of file CLMemory.cpp.

77 {
78  _region_owned = utils::cast::polymorphic_downcast_unique_ptr<ICLMemoryRegion>(std::move(region));
79  _region = _region_owned.get();
80 }
IMemoryRegion * region() final
Region accessor.
Definition: CLMemory.cpp:59

References CLMemory::region().

Referenced by CLTensorAllocator::allocate(), and CLTensorAllocator::import_memory().

◆ set_region()

void set_region ( IMemoryRegion region)
finalvirtual

Sets a memory region.

Warning
Ownership of the memory region remains to the caller
Parameters
regionMemory region

Implements IMemory.

Definition at line 69 of file CLMemory.cpp.

70 {
71  auto cl_region = utils::cast::polymorphic_downcast<ICLMemoryRegion *>(region);
72  _region_owned = nullptr;
73  _region = cl_region;
74 }
IMemoryRegion * region() final
Region accessor.
Definition: CLMemory.cpp:59
ICLMemoryRegion * cl_region()
OpenCL Region accessor.
Definition: CLMemory.cpp:49

References CLMemory::cl_region(), and CLMemory::region().

Referenced by CLTensorAllocator::free().


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