From 26014cf4d0519aef280c8444c60ec34c4e37e3b6 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 9 Sep 2019 19:00:57 +0100 Subject: COMPMID-2649: Generalize MemoryGroup. Avoids any upcasting. Change-Id: I2181c7c9df59a7fb8a78e11934fbd96058fd39c7 Signed-off-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/1918 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice --- arm_compute/runtime/IMemoryGroup.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'arm_compute/runtime/IMemoryGroup.h') diff --git a/arm_compute/runtime/IMemoryGroup.h b/arm_compute/runtime/IMemoryGroup.h index 159e99aeb1..4736acb559 100644 --- a/arm_compute/runtime/IMemoryGroup.h +++ b/arm_compute/runtime/IMemoryGroup.h @@ -24,16 +24,39 @@ #ifndef __ARM_COMPUTE_IMEMORYGROUP_H__ #define __ARM_COMPUTE_IMEMORYGROUP_H__ +#include "arm_compute/runtime/IMemory.h" #include "arm_compute/runtime/Types.h" namespace arm_compute { +// Forward declarations +class IMemoryGroup; +class IMemoryManageable; + /** Memory group interface */ class IMemoryGroup { public: /** Default virtual destructor */ virtual ~IMemoryGroup() = default; + /** Sets a object to be managed by the given memory group + * + * @note Manager must not be finalized + * + * @param[in] obj Object to be managed + */ + virtual void manage(IMemoryManageable *obj) = 0; + /** Finalizes memory for a given object + * + * @note Manager must not be finalized + * + * @param[in, out] obj Object to request memory for + * @param[in, out] obj_memory Object's memory handling interface which can be used to alter the underlying memory + * that is used by the object. + * @param[in] size Size of memory to allocate + * @param[in] alignment (Optional) Alignment to use + */ + virtual void finalize_memory(IMemoryManageable *obj, IMemory &obj_memory, size_t size, size_t alignment) = 0; /** Acquires backing memory for the whole group */ virtual void acquire() = 0; /** Releases backing memory of the whole group */ @@ -42,6 +65,19 @@ public: virtual MemoryMappings &mappings() = 0; }; +/** Interface of an object than can be memory managed */ +class IMemoryManageable +{ +public: + /** Default virtual destructor */ + virtual ~IMemoryManageable() = default; + /** Associates a memory managable object with the memory group that manages it + * + * @param[in] memory_group Memory group that manages the object. + */ + virtual void associate_memory_group(IMemoryGroup *memory_group) = 0; +}; + /** Memory group resources scope handling class */ class MemoryGroupResourceScope { -- cgit v1.2.1