From e146b7812e861ac00a1fd53cd6af3e652dd19808 Mon Sep 17 00:00:00 2001 From: Jaydeep Date: Tue, 14 Jun 2022 08:00:17 +0000 Subject: [PATCH] SWDEV-332607 - If pitch returned from hipMallocPitch is equal to pitch passed to hipMemset2D then height passed to hipMemset2D must be less than or equal to height passed to hipMallocPitch. Change-Id: I8d9b0938fb592170008aaec9cedd519bf40c6201 [ROCm/clr commit: ea0590d1fecc0b7109a8645d62ac02217fb81d26] --- projects/clr/rocclr/platform/memory.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/projects/clr/rocclr/platform/memory.hpp b/projects/clr/rocclr/platform/memory.hpp index f37df7a083..8182378d1a 100644 --- a/projects/clr/rocclr/platform/memory.hpp +++ b/projects/clr/rocclr/platform/memory.hpp @@ -147,6 +147,15 @@ class Memory : public amd::RuntimeObject { int deviceId = 0; //!< Device ID memory is allocated on void* data = nullptr; //!< Opaque user data from CL or HIP or etc. unsigned int flags = 0; //!< HIP memory flags + //! hipMallocPitch allocates buffer using width & height and returns pitch & device pointer. + //! Since device pointer is void*, It looses the values of width & height used for allocation. + //! Memory object has total size however it's pitch * height * depth and its not straight forward to + //! deduce these numbers from size and thus, below metadata are added to memory class so that + //! can be used to validate in hipMemset2D's inputs. + size_t pitch_ = 0; //!< Pitch value in bytes + size_t width_ = 0; //!< Width value in bytes + size_t height_ = 0; //!< Height value + size_t depth_ = 0; //!< Depth value }; protected: