From d3bfb55d7a934355257a72fab538a0a634b43cad Mon Sep 17 00:00:00 2001 From: Ioannis Assiouras Date: Sun, 17 Dec 2023 22:56:11 +0000 Subject: [PATCH] SWDEV-437817 - Fix hipMemCpy2D case that erroneously fails with invalid argument error When an offset is applied to the source or destination pointers plus the kind is set to hipMemcpyDefault and the source or destination is allocated with hipMallocManaged hipMemCpy2D erroneously fails with hipErrorInvalidValue. Change-Id: I0db4c17514f743652d8f9a2691da6601a2abb2a1 --- hipamd/src/hip_memory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index d3cdd23e55..5429ed8150 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -2149,13 +2149,13 @@ void ihipCopyMemParamSet(const HIP_MEMCPY3D* pCopy, hipMemoryType& srcMemType, memObj->getMemFlags()) ? hipMemoryTypeHost : hipMemoryTypeDevice; } else { srcMemoryType = hipMemoryTypeHost; + const_cast(pCopy)->srcXInBytes += offset; } if (srcMemoryType == hipMemoryTypeHost) { // {src/dst}Host may be unitialized. Copy over {src/dst}Device into it if we // detect system memory. const_cast(pCopy)->srcHost = pCopy->srcDevice; - const_cast(pCopy)->srcXInBytes += offset; // We don't need detect memory type again for hipMemoryTypeUnified const_cast(pCopy)->srcMemoryType = srcMemoryType; } @@ -2169,11 +2169,11 @@ void ihipCopyMemParamSet(const HIP_MEMCPY3D* pCopy, hipMemoryType& srcMemType, memObj->getMemFlags()) ? hipMemoryTypeHost : hipMemoryTypeDevice; } else { dstMemoryType = hipMemoryTypeHost; + const_cast(pCopy)->dstXInBytes += offset; } if (dstMemoryType == hipMemoryTypeHost) { const_cast(pCopy)->dstHost = pCopy->dstDevice; - const_cast(pCopy)->dstXInBytes += offset; // We don't need detect memory type again for hipMemoryTypeUnified const_cast(pCopy)->dstMemoryType = dstMemoryType; }