@@ -1621,6 +1621,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
1621
1621
// Determine if pSrc and/or pDst are system allocated pageable host memory.
1622
1622
bool srcIsSystemAlloc{false };
1623
1623
bool dstIsSystemAlloc{false };
1624
+
1625
+ hipError_t hipRes{};
1624
1626
// Error code hipErrorInvalidValue returned from hipPointerGetAttributes
1625
1627
// for a non-null pointer refers to an OS-allocation, hence we can work
1626
1628
// with the assumption that this is a pointer to a pageable host memory.
@@ -1630,11 +1632,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
1630
1632
// the pointer handle as system allocated pageable host memory.
1631
1633
// The HIP runtime can handle the registering/unregistering of the memory
1632
1634
// as long as the right copy-kind (direction) is provided to hipMemcpy2D*.
1633
- hipError_t hipRet = hipPointerGetAttributes (&srcAttribs, pSrc);
1634
- if (pSrc && hipRet == hipErrorInvalidValue)
1635
+ hipRes = hipPointerGetAttributes (&srcAttribs, pSrc);
1636
+ if (hipRes == hipErrorInvalidValue && pSrc )
1635
1637
srcIsSystemAlloc = true ;
1636
- hipRet = hipPointerGetAttributes (&dstAttribs, (const void *)pDst);
1637
- if (pDst && hipRet == hipErrorInvalidValue)
1638
+ hipRes = hipPointerGetAttributes (&dstAttribs, (const void *)pDst);
1639
+ if (hipRes == hipErrorInvalidValue && pDst )
1638
1640
dstIsSystemAlloc = true ;
1639
1641
#if HIP_VERSION_MAJOR >= 6
1640
1642
srcIsSystemAlloc |= srcAttribs.type == hipMemoryTypeUnregistered;
@@ -1653,7 +1655,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
1653
1655
// NOTE: The hipPointerGetAttribute API is marked as [BETA] and fails with
1654
1656
// exit code -11 when passing a system allocated pointer to it.
1655
1657
if (!srcIsSystemAlloc && srcAttribs.isManaged ) {
1656
- UR_ASSERT (srcAttribs.hostPointer && srcAttribs.hostPointer ,
1658
+ UR_ASSERT (srcAttribs.hostPointer && srcAttribs.devicePointer ,
1657
1659
UR_RESULT_ERROR_INVALID_VALUE);
1658
1660
UR_CHECK_ERROR (hipPointerGetAttribute (
1659
1661
&srcMemType, HIP_POINTER_ATTRIBUTE_MEMORY_TYPE,
0 commit comments