diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2018-10-11 15:33:11 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:55:45 +0000 |
commit | 9da19e9da660057785fb736aba5c61b1ae773f2f (patch) | |
tree | b51b30bed8266571178834367437bab0d8a7a517 /src/runtime/PoolManager.cpp | |
parent | ffb57a05d624c2efe1b32cf6ece112ee28726058 (diff) | |
download | ComputeLibrary-9da19e9da660057785fb736aba5c61b1ae773f2f.tar.gz |
COMPMID-1605: API alignment for the MemoryManager with ARMNN
Change-Id: Iac6a95ba7f388e65b7f1c8865c3e9bf289b233ea
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/155490
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: bsgcomp <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/PoolManager.cpp')
-rw-r--r-- | src/runtime/PoolManager.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/runtime/PoolManager.cpp b/src/runtime/PoolManager.cpp index 293241d6f4..5ec2ce92c1 100644 --- a/src/runtime/PoolManager.cpp +++ b/src/runtime/PoolManager.cpp @@ -73,6 +73,36 @@ void PoolManager::register_pool(std::unique_ptr<IMemoryPool> pool) _sem = arm_compute::support::cpp14::make_unique<arm_compute::Semaphore>(_free_pools.size()); } +std::unique_ptr<IMemoryPool> PoolManager::release_pool() +{ + std::lock_guard<arm_compute::Mutex> lock(_mtx); + ARM_COMPUTE_ERROR_ON_MSG(!_occupied_pools.empty(), "All pools should be free in order to release one!"); + + if(!_free_pools.empty()) + { + std::unique_ptr<IMemoryPool> pool = std::move(_free_pools.front()); + ARM_COMPUTE_ERROR_ON(_free_pools.front() != nullptr); + _free_pools.pop_front(); + + // Update semaphore + _sem = arm_compute::support::cpp14::make_unique<arm_compute::Semaphore>(_free_pools.size()); + + return pool; + } + + return nullptr; +} + +void PoolManager::clear_pools() +{ + std::lock_guard<arm_compute::Mutex> lock(_mtx); + ARM_COMPUTE_ERROR_ON_MSG(!_occupied_pools.empty(), "All pools should be free in order to clear the PoolManager!"); + _free_pools.clear(); + + // Update semaphore + _sem = nullptr; +} + size_t PoolManager::num_pools() const { std::lock_guard<arm_compute::Mutex> lock(_mtx); |