diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2019-09-09 19:00:57 +0100 |
---|---|---|
committer | Georgios Pinitas <georgios.pinitas@arm.com> | 2019-09-17 11:37:02 +0000 |
commit | 26014cf4d0519aef280c8444c60ec34c4e37e3b6 (patch) | |
tree | 7f4b3cb8589c10e95288a722498c9256e8bf5e22 /arm_compute/runtime/IMemoryGroup.h | |
parent | caa7deedfe1b0d0020c6099d8f616ec92b1bd5e9 (diff) | |
download | ComputeLibrary-26014cf4d0519aef280c8444c60ec34c4e37e3b6.tar.gz |
COMPMID-2649: Generalize MemoryGroup.
Avoids any upcasting.
Change-Id: I2181c7c9df59a7fb8a78e11934fbd96058fd39c7
Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1918
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Diffstat (limited to 'arm_compute/runtime/IMemoryGroup.h')
-rw-r--r-- | arm_compute/runtime/IMemoryGroup.h | 36 |
1 files changed, 36 insertions, 0 deletions
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 { |