ArmNN
 24.05
GpuFsaBackend::ClBackendCustomAllocatorMemoryRegion Class Reference

#include <GpuFsaBackend.hpp>

Inheritance diagram for GpuFsaBackend::ClBackendCustomAllocatorMemoryRegion:
[legend]
Collaboration diagram for GpuFsaBackend::ClBackendCustomAllocatorMemoryRegion:
[legend]

Public Member Functions

 ClBackendCustomAllocatorMemoryRegion (const cl::Buffer &buffer, void *hostMemPtr, armnn::MemorySource source)
 
void * ptr () override
 
void * map (cl::CommandQueue &q, bool blocking) override
 
void unmap (cl::CommandQueue &q) override
 

Detailed Description

Definition at line 233 of file GpuFsaBackend.hpp.

Constructor & Destructor Documentation

◆ ClBackendCustomAllocatorMemoryRegion()

ClBackendCustomAllocatorMemoryRegion ( const cl::Buffer &  buffer,
void *  hostMemPtr,
armnn::MemorySource  source 
)
inline

Definition at line 237 of file GpuFsaBackend.hpp.

238  : ICLMemoryRegion(buffer.getInfo<CL_MEM_SIZE>())
239  {
240  _mem = buffer;
241  m_HostMemPtr = hostMemPtr;
242  m_MemorySource = source;
243  }

Member Function Documentation

◆ map()

void* map ( cl::CommandQueue &  q,
bool  blocking 
)
inlineoverride

Definition at line 251 of file GpuFsaBackend.hpp.

252  {
253  armnn::IgnoreUnused(q, blocking);
254  if (m_HostMemPtr == nullptr)
255  {
256  throw armnn::Exception("ClBackend: Attempting to map memory with an invalid host ptr");
257  }
258  if (_mapping != nullptr)
259  {
260  throw armnn::Exception("ClBackend: Attempting to map memory which has not yet been unmapped");
261  }
262  switch (m_MemorySource)
263  {
265  _mapping = m_HostMemPtr;
266  return _mapping;
267  break;
270  // If the source is a Dmabuf then the memory ptr should be pointing to an integer value for the fd
271  _mapping = mmap(NULL, _size, PROT_WRITE, MAP_SHARED, *(reinterpret_cast<int*>(m_HostMemPtr)), 0);
272  return _mapping;
273  break;
274  default:
275  throw armnn::Exception("ClBackend: Attempting to map imported memory without a valid source");
276  break;
277  }
278  }

References armnn::DmaBuf, armnn::DmaBufProtected, armnn::IgnoreUnused(), and armnn::Malloc.

◆ ptr()

void* ptr ( )
inlineoverride

Definition at line 246 of file GpuFsaBackend.hpp.

247  {
248  return nullptr;
249  }

◆ unmap()

void unmap ( cl::CommandQueue &  q)
inlineoverride

Definition at line 280 of file GpuFsaBackend.hpp.

281  {
283  switch (m_MemorySource)
284  {
286  _mapping = nullptr;
287  break;
290  munmap(_mapping, _size);
291  _mapping = nullptr;
292  break;
293  default:
294  throw armnn::Exception("ClBackend: Attempting to unmap imported memory without a valid source");
295  break;
296  }
297  }

References armnn::DmaBuf, armnn::DmaBufProtected, armnn::IgnoreUnused(), and armnn::Malloc.


The documentation for this class was generated from the following file:
armnn::MemorySource::Malloc
@ Malloc
armnn::MemorySource::DmaBufProtected
@ DmaBufProtected
armnn::MemorySource::DmaBuf
@ DmaBuf
armnn::Exception
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14