From baf174e85ddb5399355281cd34d0f459d92124a7 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 8 Sep 2017 19:47:30 +0100 Subject: COMPMID-485: Memory Manager Change-Id: Ib421b7622838f050038cd81e7426bb1413a7d6e6 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87376 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- arm_compute/runtime/CL/CLTensorAllocator.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'arm_compute/runtime/CL/CLTensorAllocator.h') diff --git a/arm_compute/runtime/CL/CLTensorAllocator.h b/arm_compute/runtime/CL/CLTensorAllocator.h index ed371e0642..682de174a8 100644 --- a/arm_compute/runtime/CL/CLTensorAllocator.h +++ b/arm_compute/runtime/CL/CLTensorAllocator.h @@ -24,19 +24,27 @@ #ifndef __ARM_COMPUTE_CLTENSORALLOCATOR_H__ #define __ARM_COMPUTE_CLTENSORALLOCATOR_H__ -#include "arm_compute/core/CL/OpenCL.h" #include "arm_compute/runtime/ITensorAllocator.h" +#include "arm_compute/core/CL/OpenCL.h" + #include namespace arm_compute { +class CLTensor; +template +class MemoryGroupBase; +using CLMemoryGroup = MemoryGroupBase; + /** Basic implementation of a CL memory tensor allocator. */ class CLTensorAllocator : public ITensorAllocator { public: /** Default constructor. */ - CLTensorAllocator(); + CLTensorAllocator(CLTensor *owner = nullptr); + /** Default destructor */ + ~CLTensorAllocator(); /** Prevent instances of this class from being copied (As this class contains pointers). */ CLTensorAllocator(const CLTensorAllocator &) = delete; /** Prevent instances of this class from being copy assigned (As this class contains pointers). */ @@ -45,8 +53,6 @@ public: CLTensorAllocator(CLTensorAllocator &&) = default; /** Allow instances of this class to be moved */ CLTensorAllocator &operator=(CLTensorAllocator &&) = default; - /** Default destructor */ - ~CLTensorAllocator() = default; /** Interface to be implemented by the child class to return the pointer to the mapped data. */ uint8_t *data(); @@ -85,6 +91,11 @@ public: * */ void free() override; + /** Associates the tensor with a memory group + * + * @param[in] associated_memory_group Memory group to associate the tensor with + */ + void set_associated_memory_group(CLMemoryGroup *associated_memory_group); protected: /** Call map() on the OpenCL buffer. @@ -96,8 +107,10 @@ protected: void unlock() override; private: - cl::Buffer _buffer; /**< OpenCL buffer containing the tensor data. */ - uint8_t *_mapping; /**< Pointer to the CPU mapping of the OpenCL buffer. */ + CLMemoryGroup *_associated_memory_group; /**< Registered memory manager */ + cl::Buffer _buffer; /**< OpenCL buffer containing the tensor data. */ + uint8_t *_mapping; /**< Pointer to the CPU mapping of the OpenCL buffer. */ + CLTensor *_owner; /**< Owner of the allocator */ }; } #endif /* __ARM_COMPUTE_CLTENSORALLOCATOR_H__ */ -- cgit v1.2.1