Compute Library
 19.08
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 36 of file BlobMemoryPool.cpp.

37  : _allocator(allocator), _blobs(), _blob_info(std::move(blob_info))
38 {
40  allocate_blobs(_blob_info);
41 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
src_target allocator() -> allocate()

References arm_compute::test::validation::allocator(), and ARM_COMPUTE_ERROR_ON.

◆ ~BlobMemoryPool()

Default Destructor.

Definition at line 43 of file BlobMemoryPool.cpp.

44 {
45  ARM_COMPUTE_ERROR_ON(!_allocator);
46  free_blobs();
47 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337

References ARM_COMPUTE_ERROR_ON.

◆ 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 49 of file BlobMemoryPool.cpp.

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

References ARM_COMPUTE_ERROR_ON.

◆ duplicate()

std::unique_ptr< IMemoryPool > duplicate ( )
overridevirtual

Duplicates the existing memory pool.

Returns
A duplicate of the existing pool

Implements IMemoryPool.

Definition at line 73 of file BlobMemoryPool.cpp.

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

References ARM_COMPUTE_ERROR_ON.

◆ 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 68 of file BlobMemoryPool.cpp.

69 {
70  return MappingType::BLOBS;
71 }
Mappings are in blob granularity.

References arm_compute::BLOBS.

◆ 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 59 of file BlobMemoryPool.cpp.

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

References ARM_COMPUTE_ERROR_ON.


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