ArmNN
 24.02
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 231 of file GpuFsaBackend.hpp.

Constructor & Destructor Documentation

◆ ClBackendCustomAllocatorMemoryRegion()

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

Definition at line 235 of file GpuFsaBackend.hpp.

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

Member Function Documentation

◆ map()

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

Definition at line 249 of file GpuFsaBackend.hpp.

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

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

◆ ptr()

void* ptr ( )
inlineoverride

Definition at line 244 of file GpuFsaBackend.hpp.

245  {
246  return nullptr;
247  }

◆ unmap()

void unmap ( cl::CommandQueue &  q)
inlineoverride

Definition at line 278 of file GpuFsaBackend.hpp.

279  {
281  switch (m_MemorySource)
282  {
284  _mapping = nullptr;
285  break;
288  munmap(_mapping, _size);
289  _mapping = nullptr;
290  break;
291  default:
292  throw armnn::Exception("ClBackend: Attempting to unmap imported memory without a valid source");
293  break;
294  }
295  }

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