Skip to content

Commit

Permalink
Apply review feedback to remove unnecessary noise
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeWeb committed Apr 2, 2024
1 parent d96bd03 commit d50ea1d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions source/adapters/hip/enqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
// Determine if pSrc and/or pDst are system allocated pageable host memory.
bool srcIsSystemAlloc{false};
bool dstIsSystemAlloc{false};

hipError_t hipRes{};
// Error code hipErrorInvalidValue returned from hipPointerGetAttributes
// for a non-null pointer refers to an OS-allocation, hence we can work
// with the assumption that this is a pointer to a pageable host memory.
Expand All @@ -1630,11 +1632,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
// the pointer handle as system allocated pageable host memory.
// The HIP runtime can handle the registering/unregistering of the memory
// as long as the right copy-kind (direction) is provided to hipMemcpy2D*.
hipError_t hipRet = hipPointerGetAttributes(&srcAttribs, pSrc);
if (pSrc && hipRet == hipErrorInvalidValue)
hipRes = hipPointerGetAttributes(&srcAttribs, pSrc);
if (hipRes == hipErrorInvalidValue && pSrc)
srcIsSystemAlloc = true;
hipRet = hipPointerGetAttributes(&dstAttribs, (const void *)pDst);
if (pDst && hipRet == hipErrorInvalidValue)
hipRes = hipPointerGetAttributes(&dstAttribs, (const void *)pDst);
if (hipRes == hipErrorInvalidValue && pDst)
dstIsSystemAlloc = true;
#if HIP_VERSION_MAJOR >= 6
srcIsSystemAlloc |= srcAttribs.type == hipMemoryTypeUnregistered;
Expand All @@ -1653,7 +1655,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
// NOTE: The hipPointerGetAttribute API is marked as [BETA] and fails with
// exit code -11 when passing a system allocated pointer to it.
if (!srcIsSystemAlloc && srcAttribs.isManaged) {
UR_ASSERT(srcAttribs.hostPointer && srcAttribs.hostPointer,
UR_ASSERT(srcAttribs.hostPointer && srcAttribs.devicePointer,
UR_RESULT_ERROR_INVALID_VALUE);
UR_CHECK_ERROR(hipPointerGetAttribute(
&srcMemType, HIP_POINTER_ATTRIBUTE_MEMORY_TYPE,
Expand Down

0 comments on commit d50ea1d

Please sign in to comment.