ArmNN
 24.02
GpuFsaBackendDefaultAllocator Class Reference

Default Memory Allocator class returned from IBackendInternal::GetDefaultAllocator(MemorySource) More...

#include <GpuFsaBackendDefaultAllocator.hpp>

Inheritance diagram for GpuFsaBackendDefaultAllocator:
[legend]
Collaboration diagram for GpuFsaBackendDefaultAllocator:
[legend]

Public Member Functions

 GpuFsaBackendDefaultAllocator ()=default
 
void * allocate (size_t size, size_t alignment=0) override
 Interface to be implemented by the child class to allocate bytes. More...
 
void free (void *ptr) override
 Interface to be implemented by the child class to free the allocated bytes. More...
 
MemorySource GetMemorySourceType () override
 Used to specify what type of memory is being allocated by this allocator. More...
 
void * GetMemoryRegionAtOffset (void *buffer, size_t offset, size_t alignment=0) override
 Interface that may be implemented to allow retrieval of Memory Region from allocated buffer at a certain offset. More...
 
- Public Member Functions inherited from ICustomAllocator
virtual ~ICustomAllocator ()=default
 Default virtual destructor. More...
 

Detailed Description

Default Memory Allocator class returned from IBackendInternal::GetDefaultAllocator(MemorySource)

Definition at line 18 of file GpuFsaBackendDefaultAllocator.hpp.

Constructor & Destructor Documentation

◆ GpuFsaBackendDefaultAllocator()

Member Function Documentation

◆ allocate()

void* allocate ( size_t  size,
size_t  alignment = 0 
)
inlineoverridevirtual

Interface to be implemented by the child class to allocate bytes.

Parameters
[in]sizeSize to allocate
[in]alignmentAlignment that the returned pointer should comply with
Returns
A pointer to the allocated memory The returned pointer must be host write accessible

Implements ICustomAllocator.

Definition at line 23 of file GpuFsaBackendDefaultAllocator.hpp.

24  {
25  IgnoreUnused(alignment);
26  cl_mem buf{ clCreateBuffer(arm_compute::CLScheduler::get().context().get(),
27  CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE,
28  size,
29  nullptr,
30  nullptr)};
31  return static_cast<void *>(buf);
32  }

References armnn::IgnoreUnused().

◆ free()

void free ( void *  ptr)
inlineoverridevirtual

Interface to be implemented by the child class to free the allocated bytes.

Implements ICustomAllocator.

Definition at line 34 of file GpuFsaBackendDefaultAllocator.hpp.

35  {
36  ARM_COMPUTE_ERROR_ON(ptr == nullptr);
37  clReleaseMemObject(static_cast<cl_mem>(ptr));
38  }

◆ GetMemoryRegionAtOffset()

void* GetMemoryRegionAtOffset ( void *  buffer,
size_t  offset,
size_t  alignment = 0 
)
inlineoverridevirtual

Interface that may be implemented to allow retrieval of Memory Region from allocated buffer at a certain offset.

Reimplemented from ICustomAllocator.

Definition at line 45 of file GpuFsaBackendDefaultAllocator.hpp.

46  {
47  IgnoreUnused(alignment);
48  return static_cast<char*>(buffer) + offset;
49  }

References armnn::IgnoreUnused().

◆ GetMemorySourceType()

MemorySource GetMemorySourceType ( )
inlineoverridevirtual

Used to specify what type of memory is being allocated by this allocator.

Supported types are: MemorySource::Malloc MemorySource::DmaBuf MemorySource::DmaBufProtected

Implements ICustomAllocator.

Definition at line 40 of file GpuFsaBackendDefaultAllocator.hpp.

41  {
42  return MemorySource::Gralloc;
43  }

References armnn::Gralloc.


The documentation for this class was generated from the following file:
armnn::MemorySource::Gralloc
@ Gralloc
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14