Skip to content

Commit

Permalink
SWDEV-437817 - Fix hipMemCpy2D case that erroneously fails with inval…
Browse files Browse the repository at this point in the history
…id 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
  • Loading branch information
iassiour committed Dec 18, 2023
1 parent 4a7291d commit d3bfb55
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hipamd/src/hip_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2149,13 +2149,13 @@ void ihipCopyMemParamSet(const HIP_MEMCPY3D* pCopy, hipMemoryType& srcMemType,
memObj->getMemFlags()) ? hipMemoryTypeHost : hipMemoryTypeDevice;
} else {
srcMemoryType = hipMemoryTypeHost;
const_cast<HIP_MEMCPY3D*>(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<HIP_MEMCPY3D*>(pCopy)->srcHost = pCopy->srcDevice;
const_cast<HIP_MEMCPY3D*>(pCopy)->srcXInBytes += offset;
// We don't need detect memory type again for hipMemoryTypeUnified
const_cast<HIP_MEMCPY3D*>(pCopy)->srcMemoryType = srcMemoryType;
}
Expand All @@ -2169,11 +2169,11 @@ void ihipCopyMemParamSet(const HIP_MEMCPY3D* pCopy, hipMemoryType& srcMemType,
memObj->getMemFlags()) ? hipMemoryTypeHost : hipMemoryTypeDevice;
} else {
dstMemoryType = hipMemoryTypeHost;
const_cast<HIP_MEMCPY3D*>(pCopy)->dstXInBytes += offset;
}

if (dstMemoryType == hipMemoryTypeHost) {
const_cast<HIP_MEMCPY3D*>(pCopy)->dstHost = pCopy->dstDevice;
const_cast<HIP_MEMCPY3D*>(pCopy)->dstXInBytes += offset;
// We don't need detect memory type again for hipMemoryTypeUnified
const_cast<HIP_MEMCPY3D*>(pCopy)->dstMemoryType = dstMemoryType;
}
Expand Down

0 comments on commit d3bfb55

Please sign in to comment.