From 555f1c2241d6fa8c84926a72a0c54e4158817df4 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 14 Dec 2018 17:11:20 +0000 Subject: COMPMID-1710: Account alignment for blob-base allocations Change-Id: I290d33e25a5966d25a91df39ebc01c28bfa31f78 Reviewed-on: https://review.mlplatform.org/402 Reviewed-by: Anthony Barbier Tested-by: Arm Jenkins --- arm_compute/runtime/BlobMemoryPool.h | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'arm_compute/runtime/BlobMemoryPool.h') diff --git a/arm_compute/runtime/BlobMemoryPool.h b/arm_compute/runtime/BlobMemoryPool.h index c9c4da0f54..ba97dbd94e 100644 --- a/arm_compute/runtime/BlobMemoryPool.h +++ b/arm_compute/runtime/BlobMemoryPool.h @@ -35,8 +35,20 @@ namespace arm_compute { +// Forward declaration class IAllocator; +/** Meta-data information for each blob */ +struct BlobInfo +{ + BlobInfo(size_t size_ = 0, size_t alignment_ = 0) + : size(size_), alignment(alignment_) + { + } + size_t size; /**< Blob size */ + size_t alignment; /**< Blob alignment */ +}; + /** Blob memory pool */ class BlobMemoryPool : public IMemoryPool { @@ -45,10 +57,10 @@ public: * * @note allocator should outlive the memory pool * - * @param[in] allocator Backing memory allocator - * @param[in] blob_sizes Sizes of the blobs to be allocated + * @param[in] allocator Backing memory allocator + * @param[in] blob_info Configuration information of the blobs to be allocated */ - BlobMemoryPool(IAllocator *allocator, std::vector blob_sizes); + BlobMemoryPool(IAllocator *allocator, std::vector blob_info); /** Default Destructor */ ~BlobMemoryPool(); /** Prevent instances of this class to be copy constructed */ @@ -69,16 +81,16 @@ public: private: /** Allocates internal blobs * - * @param sizes Size of each blob + * @param blob_info Size of each blob */ - void allocate_blobs(const std::vector &sizes); + void allocate_blobs(const std::vector &blob_info); /** Frees blobs **/ void free_blobs(); private: - IAllocator *_allocator; /**< Allocator to use for internal allocation */ - std::vector> _blobs; /**< Vector holding all the memory blobs */ - std::vector _blob_sizes; /**< Sizes of each blob */ + IAllocator *_allocator; /**< Allocator to use for internal allocation */ + std::vector> _blobs; /**< Vector holding all the memory blobs */ + std::vector _blob_info; /**< Information of each blob */ }; } // namespace arm_compute #endif /* __ARM_COMPUTE_BLOBMEMORYPOOL_H__ */ -- cgit v1.2.1