From ec832d42d1c00a8ac40d9650642e863f8fa8152a Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary Date: Thu, 11 Feb 2021 06:47:32 -0800 Subject: [PATCH] SWDEV-272361 - Dont call memcpy2d if width is 0 or height or depth is 0 Change-Id: I22324a536d2a5e68b9fc3e5ee4ad821b49021a17 --- hipamd/rocclr/hip_conversions.hpp | 2 +- hipamd/rocclr/hip_memory.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hipamd/rocclr/hip_conversions.hpp b/hipamd/rocclr/hip_conversions.hpp index a15923c0f3..99f143b7c9 100644 --- a/hipamd/rocclr/hip_conversions.hpp +++ b/hipamd/rocclr/hip_conversions.hpp @@ -590,7 +590,7 @@ HIP_MEMCPY3D getDrvMemcpy3DDesc(const hip_Memcpy2D& desc2D) { desc3D.WidthInBytes = desc2D.WidthInBytes; desc3D.Height = desc2D.Height; - desc3D.Depth = 0; + desc3D.Depth = 1; return desc3D; } diff --git a/hipamd/rocclr/hip_memory.cpp b/hipamd/rocclr/hip_memory.cpp index 4f3ab69f8e..d8a089dcc2 100755 --- a/hipamd/rocclr/hip_memory.cpp +++ b/hipamd/rocclr/hip_memory.cpp @@ -1469,6 +1469,12 @@ hipError_t ihipMemcpyAtoH(hipArray* srcArray, hipError_t ihipMemcpyParam3D(const HIP_MEMCPY3D* pCopy, hipStream_t stream, bool isAsync = false) { + if(pCopy->WidthInBytes == 0 || pCopy->Height == 0 || pCopy->Depth == 0) { + LogPrintfInfo("Either Width :%d or Height: %d and Depth: %d is zero", pCopy->WidthInBytes, + pCopy->Height, pCopy->Depth); + return hipSuccess; + } + // If {src/dst}MemoryType is hipMemoryTypeUnified, {src/dst}Device and {src/dst}Pitch specify the (unified virtual address space) // base address of the source data and the bytes per row to apply. {src/dst}Array is ignored. hipMemoryType srcMemoryType = pCopy->srcMemoryType; @@ -1506,7 +1512,7 @@ hipError_t ihipMemcpyParam3D(const HIP_MEMCPY3D* pCopy, amd::Coord3D srcOrigin = {pCopy->srcXInBytes, pCopy->srcY, pCopy->srcZ}; amd::Coord3D dstOrigin = {pCopy->dstXInBytes, pCopy->dstY, pCopy->dstZ}; - amd::Coord3D copyRegion = {pCopy->WidthInBytes, (pCopy->Height != 0) ? pCopy->Height : 1, (pCopy->Depth != 0) ? pCopy->Depth : 1}; + amd::Coord3D copyRegion = {pCopy->WidthInBytes, pCopy->Height, pCopy->Depth}; if ((srcMemoryType == hipMemoryTypeHost) && (dstMemoryType == hipMemoryTypeHost)) { // Host to Host.