Compute Library
 21.11
BlobMemoryPool Class Reference

Blob memory pool. More...

#include <BlobMemoryPool.h>

Collaboration diagram for BlobMemoryPool:
[legend]

Public Member Functions

 BlobMemoryPool (IAllocator *allocator, std::vector< BlobInfo > blob_info)
 Default Constructor. More...
 
 ~BlobMemoryPool ()
 Default Destructor. More...
 
 BlobMemoryPool (const BlobMemoryPool &)=delete
 Prevent instances of this class to be copy constructed. More...
 
BlobMemoryPooloperator= (const BlobMemoryPool &)=delete
 Prevent instances of this class to be copy assigned. More...
 
 BlobMemoryPool (BlobMemoryPool &&)=default
 Allow instances of this class to be move constructed. More...
 
BlobMemoryPooloperator= (BlobMemoryPool &&)=default
 Allow instances of this class to be move assigned. More...
 
void acquire (MemoryMappings &handles) override
 Sets occupant to the memory pool. More...
 
void release (MemoryMappings &handles) override
 Releases a memory block. More...
 
MappingType mapping_type () const override
 Returns the mapping types that this pool accepts. More...
 
std::unique_ptr< IMemoryPoolduplicate () override
 Duplicates the existing memory pool. More...
 
- Public Member Functions inherited from IMemoryPool
virtual ~IMemoryPool ()=default
 Default Virtual Destructor. More...
 

Detailed Description

Blob memory pool.

Definition at line 42 of file BlobMemoryPool.h.

Constructor & Destructor Documentation

◆ BlobMemoryPool() [1/3]

BlobMemoryPool ( IAllocator allocator,
std::vector< BlobInfo blob_info 
)

Default Constructor.

Note
allocator should outlive the memory pool
Parameters
[in]allocatorBacking memory allocator
[in]blob_infoConfiguration information of the blobs to be allocated

Definition at line 35 of file BlobMemoryPool.cpp.

References ARM_COMPUTE_ERROR_ON.

36  : _allocator(allocator), _blobs(), _blob_info(std::move(blob_info))
37 {
38  ARM_COMPUTE_ERROR_ON(!allocator);
39  allocate_blobs(_blob_info);
40 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

◆ ~BlobMemoryPool()

Default Destructor.

Definition at line 42 of file BlobMemoryPool.cpp.

43 {
44  free_blobs();
45 }

◆ BlobMemoryPool() [2/3]

BlobMemoryPool ( const BlobMemoryPool )
delete

Prevent instances of this class to be copy constructed.

◆ BlobMemoryPool() [3/3]

BlobMemoryPool ( BlobMemoryPool &&  )
default

Allow instances of this class to be move constructed.

Member Function Documentation

◆ acquire()

void acquire ( MemoryMappings handles)
overridevirtual

Sets occupant to the memory pool.

Parameters
[in]handlesA vector of pairs (handle, index)

Implements IMemoryPool.

Definition at line 47 of file BlobMemoryPool.cpp.

References ARM_COMPUTE_ERROR_ON.

48 {
49  // Set memory to handlers
50  for(auto &handle : handles)
51  {
52  ARM_COMPUTE_ERROR_ON(handle.first == nullptr);
53  handle.first->set_region(_blobs[handle.second].get());
54  }
55 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

◆ duplicate()

std::unique_ptr< IMemoryPool > duplicate ( )
overridevirtual

Duplicates the existing memory pool.

Returns
A duplicate of the existing pool

Implements IMemoryPool.

Definition at line 71 of file BlobMemoryPool.cpp.

References ARM_COMPUTE_ERROR_ON, and IAllocator::make_region().

72 {
73  ARM_COMPUTE_ERROR_ON(!_allocator);
74  return std::make_unique<BlobMemoryPool>(_allocator, _blob_info);
75 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

◆ mapping_type()

MappingType mapping_type ( ) const
overridevirtual

Returns the mapping types that this pool accepts.

Returns
the mapping type of the memory

Implements IMemoryPool.

Definition at line 66 of file BlobMemoryPool.cpp.

References arm_compute::BLOBS.

67 {
68  return MappingType::BLOBS;
69 }
Mappings are in blob granularity.

◆ operator=() [1/2]

BlobMemoryPool& operator= ( const BlobMemoryPool )
delete

Prevent instances of this class to be copy assigned.

◆ operator=() [2/2]

BlobMemoryPool& operator= ( BlobMemoryPool &&  )
default

Allow instances of this class to be move assigned.

◆ release()

void release ( MemoryMappings handles)
overridevirtual

Releases a memory block.

Parameters
[in]handlesA vector containing a pair of handles and indices

Implements IMemoryPool.

Definition at line 57 of file BlobMemoryPool.cpp.

References ARM_COMPUTE_ERROR_ON.

58 {
59  for(auto &handle : handles)
60  {
61  ARM_COMPUTE_ERROR_ON(handle.first == nullptr);
62  handle.first->set_region(nullptr);
63  }
64 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

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