ArmNN
 23.05
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 113 of file ClBackend.hpp.

Constructor & Destructor Documentation

◆ ClBackendCustomAllocatorWrapper()

ClBackendCustomAllocatorWrapper ( std::shared_ptr< ICustomAllocator alloc)
inline

Definition at line 116 of file ClBackend.hpp.

116  : m_CustomAllocator(alloc)
117  {}

Member Function Documentation

◆ allocate()

void* allocate ( size_t  size,
size_t  alignment 
)
inlineoverride

Definition at line 119 of file ClBackend.hpp.

120  {
121  auto alloc = m_CustomAllocator->allocate(size, alignment);
122  return MapAllocatedMemory(alloc, size, m_CustomAllocator->GetMemorySourceType());
123  }

◆ free()

void free ( void *  ptr)
inlineoverride

Definition at line 124 of file ClBackend.hpp.

125  {
126  auto hostMemPtr = m_AllocatedBufferMappings[ptr];
127  clReleaseMemObject(static_cast<cl_mem>(ptr));
128  m_CustomAllocator->free(hostMemPtr);
129  }

◆ make_region()

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

Definition at line 130 of file ClBackend.hpp.

131  {
132  auto hostMemPtr = m_CustomAllocator->allocate(size, alignment);
133  cl_mem buffer = MapAllocatedMemory(hostMemPtr, size, m_CustomAllocator->GetMemorySourceType());
134 
135  return std::make_unique<ClBackendCustomAllocatorMemoryRegion>(cl::Buffer(buffer),
136  hostMemPtr,
137  m_CustomAllocator->GetMemorySourceType());
138  }

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