Compute Library
 21.02
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.

References ARM_COMPUTE_ERROR_ON.

43 {
44  ARM_COMPUTE_ERROR_ON(!_allocator);
45  free_blobs();
46 }
#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() [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 48 of file BlobMemoryPool.cpp.

References ARM_COMPUTE_ERROR_ON.

49 {
50  // Set memory to handlers
51  for(auto &handle : handles)
52  {
53  ARM_COMPUTE_ERROR_ON(handle.first == nullptr);
54  handle.first->set_region(_blobs[handle.second].get());
55  }
56 }
#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 72 of file BlobMemoryPool.cpp.

References ARM_COMPUTE_ERROR_ON, and IAllocator::make_region().

73 {
74  ARM_COMPUTE_ERROR_ON(!_allocator);
75  return std::make_unique<BlobMemoryPool>(_allocator, _blob_info);
76 }
#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 67 of file BlobMemoryPool.cpp.

References arm_compute::BLOBS.

68 {
69  return MappingType::BLOBS;
70 }
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 58 of file BlobMemoryPool.cpp.

References ARM_COMPUTE_ERROR_ON.

59 {
60  for(auto &handle : handles)
61  {
62  ARM_COMPUTE_ERROR_ON(handle.first == nullptr);
63  handle.first->set_region(nullptr);
64  }
65 }
#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: