From 40958adf8bad8fd9fefe591ee55a381f7bbb6fea Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 18 Sep 2019 12:04:56 +0100 Subject: COMPMID-2663: Interface to unbound mappings. Adds an interface to ILifetimeManager to unbound a list of mappings. Change-Id: I927fa1e0f83e6be778fd36794439f51d36dde408 Signed-off-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/1988 Tested-by: Arm Jenkins Reviewed-by: Michalis Spyrou Comments-Addressed: Arm Jenkins --- src/runtime/BlobLifetimeManager.cpp | 4 ++-- src/runtime/ISimpleLifetimeManager.cpp | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/runtime/BlobLifetimeManager.cpp b/src/runtime/BlobLifetimeManager.cpp index 7a4760a990..fb83834b5f 100644 --- a/src/runtime/BlobLifetimeManager.cpp +++ b/src/runtime/BlobLifetimeManager.cpp @@ -71,7 +71,7 @@ void BlobLifetimeManager::update_blobs_and_mappings() std::vector group_sizes; std::transform(std::begin(_free_blobs), std::end(_free_blobs), std::back_inserter(group_sizes), [](const Blob & b) { - return BlobInfo{ b.max_size, b.max_alignment }; + return BlobInfo{ b.max_size, b.max_alignment, b.bound_elements.size() }; }); // Update blob sizes @@ -80,7 +80,7 @@ void BlobLifetimeManager::update_blobs_and_mappings() group_sizes.resize(max_size); std::transform(std::begin(_blobs), std::end(_blobs), std::begin(group_sizes), std::begin(_blobs), [](BlobInfo lhs, BlobInfo rhs) { - return BlobInfo{ std::max(lhs.size, rhs.size), std::max(lhs.alignment, rhs.alignment) }; + return BlobInfo{ std::max(lhs.size, rhs.size), std::max(lhs.alignment, rhs.alignment), std::max(lhs.owners, rhs.owners) }; }); // Calculate group mappings diff --git a/src/runtime/ISimpleLifetimeManager.cpp b/src/runtime/ISimpleLifetimeManager.cpp index 39a4096799..b01de57c35 100644 --- a/src/runtime/ISimpleLifetimeManager.cpp +++ b/src/runtime/ISimpleLifetimeManager.cpp @@ -35,8 +35,8 @@ #include #include -using namespace arm_compute; - +namespace arm_compute +{ ISimpleLifetimeManager::ISimpleLifetimeManager() : _active_group(nullptr), _active_elements(), _free_blobs(), _occupied_blobs(), _finalized_groups() { @@ -51,6 +51,20 @@ void ISimpleLifetimeManager::register_group(IMemoryGroup *group) } } +bool ISimpleLifetimeManager::release_group(IMemoryGroup *group) +{ + if(group == nullptr) + { + return false; + } + const bool status = bool(_finalized_groups.erase(group)); + if(status) + { + group->mappings().clear(); + } + return status; +} + void ISimpleLifetimeManager::start_lifetime(void *obj) { ARM_COMPUTE_ERROR_ON(obj == nullptr); @@ -109,7 +123,7 @@ void ISimpleLifetimeManager::end_lifetime(void *obj, IMemory &obj_memory, size_t update_blobs_and_mappings(); // Update finalized groups - _finalized_groups[_active_group] = std::move(_active_elements); + _finalized_groups[_active_group].insert(std::begin(_active_elements), std::end(_active_elements)); // Reset state _active_elements.clear(); @@ -125,3 +139,4 @@ bool ISimpleLifetimeManager::are_all_finalized() const return !e.second.status; }); } +} // namespace arm_compute -- cgit v1.2.1