ArmNN
 21.08
ClBackend::ClBackendCustomAllocatorWrapper Class Reference

#include <ClBackend.hpp>

Inheritance diagram for ClBackend::ClBackendCustomAllocatorWrapper:

Public Member Functions

 ClBackendCustomAllocatorWrapper (std::shared_ptr< ICustomAllocator > alloc)
 
void * allocate (size_t size, size_t alignment) override
 
void free (void *ptr) override
 
std::unique_ptr< arm_compute::IMemoryRegion > make_region (size_t size, size_t alignment) override
 

Detailed Description

Definition at line 105 of file ClBackend.hpp.

Constructor & Destructor Documentation

◆ ClBackendCustomAllocatorWrapper()

ClBackendCustomAllocatorWrapper ( std::shared_ptr< ICustomAllocator alloc)
inline

Definition at line 108 of file ClBackend.hpp.

108  : m_CustomAllocator(alloc)
109  {}

Member Function Documentation

◆ allocate()

void* allocate ( size_t  size,
size_t  alignment 
)
inlineoverride

Definition at line 111 of file ClBackend.hpp.

112  {
113  auto alloc = m_CustomAllocator->allocate(size, alignment);
114  return MapAllocatedMemory(alloc, size, m_CustomAllocator->GetMemorySourceType());
115  }

◆ free()

void free ( void *  ptr)
inlineoverride

Definition at line 116 of file ClBackend.hpp.

117  {
118  auto hostMemPtr = m_AllocatedBufferMappings[ptr];
119  clReleaseMemObject(static_cast<cl_mem>(ptr));
120  m_CustomAllocator->free(hostMemPtr);
121  }

◆ make_region()

std::unique_ptr<arm_compute::IMemoryRegion> make_region ( size_t  size,
size_t  alignment 
)
inlineoverride

Definition at line 122 of file ClBackend.hpp.

References armnn::DmaBuf, armnn::DmaBufProtected, armnn::error, and armnn::Malloc.

123  {
124  auto hostMemPtr = m_CustomAllocator->allocate(size, alignment);
125  cl_mem buffer = MapAllocatedMemory(hostMemPtr, size, m_CustomAllocator->GetMemorySourceType());
126 
127  return std::make_unique<ClBackendCustomAllocatorMemoryRegion>(cl::Buffer(buffer),
128  hostMemPtr,
129  m_CustomAllocator->GetMemorySourceType());
130  }

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