From c1c872f12797ef6fe52c4589113e7efc353e56eb Mon Sep 17 00:00:00 2001 From: Jan Eilers Date: Thu, 22 Jul 2021 13:17:04 +0100 Subject: Adds CustomAllocator interface and Sample App * Updates the runtime options with a CustomAllocatorMap which allows to define a CustomAllocator for specific backends * Change IBackendInternal interface to use a shared pointer to a custom allocator * Update ClBackend.hpp/cpp to use the CustomAllocator * Adds an example application and unit test which uses a CustomAllocator for GpuAcc * Refactor of the interface to use MemorySource instead of the user Mapping cl_mem directly * Modify the BackendRegistry to also hold a registry of CustomAllocators * BackendRegistry Deregister will also deregister any allocators associated with that backend id * set_global_allocator within the BaseMemoryManager so that it always matches the currently used allocator Signed-off-by: Jan Eilers Change-Id: I156d819686021865f4375e6cb7a5c5dec8fee9e8 Signed-off-by: David Monahan --- include/armnn/BackendRegistry.hpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/armnn/BackendRegistry.hpp') diff --git a/include/armnn/BackendRegistry.hpp b/include/armnn/BackendRegistry.hpp index fe6451cde0..c13aa9f8b6 100644 --- a/include/armnn/BackendRegistry.hpp +++ b/include/armnn/BackendRegistry.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,8 @@ public: BackendIdSet GetBackendIds() const; std::string GetBackendIdsAsString() const; void SetProfilingService(armnn::Optional profilingService); + void RegisterAllocator(const BackendId& id, std::shared_ptr alloc); + std::unordered_map> GetAllocators(); BackendRegistry() {} virtual ~BackendRegistry() {} @@ -50,6 +53,7 @@ public: }; void Deregister(const BackendId& id); + void DeregisterAllocator(const BackendId &id); protected: using FactoryStorage = std::unordered_map; @@ -63,6 +67,7 @@ private: FactoryStorage m_Factories; armnn::Optional m_ProfilingService; + std::unordered_map> m_CustomMemoryAllocatorMap; }; BackendRegistry& BackendRegistryInstance(); -- cgit v1.2.1