ArmNN
 24.08
SampleMemoryManager.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
8 
9 #include <forward_list>
10 #include <vector>
11 
12 namespace sdb // sample dynamic backend
13 {
14 
15 // An implementation of IMemoryManager to be used with SampleTensorHandle
17 {
18 public:
20  virtual ~SampleMemoryManager();
21 
22  class Pool;
23 
24  Pool* Manage(unsigned int numBytes);
25 
26  void Allocate(Pool *pool);
27 
28  void* GetPointer(Pool *pool);
29 
30  void Acquire() override;
31  void Release() override;
32 
33  class Pool
34  {
35  public:
36  Pool(unsigned int numBytes);
37  ~Pool();
38 
39  void Acquire();
40  void Release();
41 
42  void* GetPointer();
43 
44  void Reserve(unsigned int numBytes);
45 
46  private:
47  unsigned int m_Size;
48  void* m_Pointer;
49  };
50 
51 private:
52  SampleMemoryManager(const SampleMemoryManager&) = delete; // Noncopyable
53  SampleMemoryManager& operator=(const SampleMemoryManager&) = delete; // Noncopyable
54 
55  std::forward_list<Pool> m_Pools;
56  std::vector<Pool*> m_FreePools;
57 };
58 
59 } // namespace sdb
sdb::SampleMemoryManager::Pool::Acquire
void Acquire()
Definition: SampleMemoryManager.cpp:84
sdb::SampleMemoryManager
Definition: SampleMemoryManager.hpp:16
sdb::SampleMemoryManager::Acquire
void Acquire() override
Definition: SampleMemoryManager.cpp:45
sdb::SampleMemoryManager::Manage
Pool * Manage(unsigned int numBytes)
Definition: SampleMemoryManager.cpp:19
sdb::SampleMemoryManager::SampleMemoryManager
SampleMemoryManager()
Definition: SampleMemoryManager.cpp:13
sdb
Definition: SampleDynamicAdditionWorkload.cpp:11
sdb::SampleMemoryManager::Release
void Release() override
Definition: SampleMemoryManager.cpp:53
armnn::IMemoryManager
Definition: IMemoryManager.hpp:12
sdb::SampleMemoryManager::Pool::Reserve
void Reserve(unsigned int numBytes)
Definition: SampleMemoryManager.cpp:79
sdb::SampleMemoryManager::Allocate
void Allocate(Pool *pool)
Definition: SampleMemoryManager.cpp:35
sdb::SampleMemoryManager::Pool::Pool
Pool(unsigned int numBytes)
Definition: SampleMemoryManager.cpp:61
sdb::SampleMemoryManager::~SampleMemoryManager
virtual ~SampleMemoryManager()
Definition: SampleMemoryManager.cpp:16
sdb::SampleMemoryManager::Pool::Release
void Release()
Definition: SampleMemoryManager.cpp:89
sdb::SampleMemoryManager::Pool::GetPointer
void * GetPointer()
Definition: SampleMemoryManager.cpp:74
sdb::SampleMemoryManager::Pool::~Pool
~Pool()
Definition: SampleMemoryManager.cpp:66
sdb::SampleMemoryManager::Pool
Definition: SampleMemoryManager.hpp:33
sdb::SampleMemoryManager::GetPointer
void * GetPointer(Pool *pool)
Definition: SampleMemoryManager.cpp:40
IMemoryManager.hpp