ArmNN
 24.02
ClBackend::ClBackendCustomAllocatorWrapper Class Reference

#include <ClBackend.hpp>

Inheritance diagram for ClBackend::ClBackendCustomAllocatorWrapper:
[legend]
Collaboration diagram for ClBackend::ClBackendCustomAllocatorWrapper:
[legend]

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 97 of file ClBackend.hpp.

Constructor & Destructor Documentation

◆ ClBackendCustomAllocatorWrapper()

ClBackendCustomAllocatorWrapper ( std::shared_ptr< ICustomAllocator alloc)
inline

Definition at line 100 of file ClBackend.hpp.

100  : m_CustomAllocator(alloc)
101  {}

Member Function Documentation

◆ allocate()

void* allocate ( size_t  size,
size_t  alignment 
)
inlineoverride

Definition at line 103 of file ClBackend.hpp.

104  {
105  auto alloc = m_CustomAllocator->allocate(size, alignment);
106  return MapAllocatedMemory(alloc, size, m_CustomAllocator->GetMemorySourceType());
107  }

◆ free()

void free ( void *  ptr)
inlineoverride

Definition at line 108 of file ClBackend.hpp.

109  {
110  auto hostMemPtr = m_AllocatedBufferMappings[ptr];
111  clReleaseMemObject(static_cast<cl_mem>(ptr));
112  m_CustomAllocator->free(hostMemPtr);
113  }

◆ make_region()

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

Definition at line 114 of file ClBackend.hpp.

115  {
116  auto hostMemPtr = m_CustomAllocator->allocate(size, alignment);
117  cl_mem buffer = MapAllocatedMemory(hostMemPtr, size, m_CustomAllocator->GetMemorySourceType());
118 
119  return std::make_unique<ClBackendCustomAllocatorMemoryRegion>(cl::Buffer(buffer),
120  hostMemPtr,
121  m_CustomAllocator->GetMemorySourceType());
122  }

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