From 258cf47fd4af4372620cac183dcbc39628ef28d6 Mon Sep 17 00:00:00 2001 From: Jin Z <5zj@cousteau.ftpn.ornl.gov> Date: Fri, 27 Oct 2023 16:54:30 -0400 Subject: [PATCH 1/2] [HIP] Support range start address and size in the USM allocation --- source/adapters/hip/usm.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index 7af7401f87..3367fc03ab 100644 --- a/source/adapters/hip/usm.cpp +++ b/source/adapters/hip/usm.cpp @@ -190,9 +190,28 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem, #endif return ReturnValue(UR_USM_TYPE_UNKNOWN); } - case UR_USM_ALLOC_INFO_BASE_PTR: - case UR_USM_ALLOC_INFO_SIZE: + case UR_USM_ALLOC_INFO_BASE_PTR: { +#if (HIP_VERSION_MAJOR >= 5) + void *Base; + UR_CHECK_ERROR(hipPointerGetAttribute( + &Base, HIP_POINTER_ATTRIBUTE_RANGE_START_ADDR, + const_cast(pMem))); + return ReturnValue(Base); +#else return UR_RESULT_ERROR_INVALID_VALUE; +#endif + } + case UR_USM_ALLOC_INFO_SIZE: { +#if (HIP_VERSION_MAJOR >= 5) + size_t Value; + UR_CHECK_ERROR(hipPointerGetAttribute( + &Value, HIP_POINTER_ATTRIBUTE_RANGE_SIZE, + const_cast(pMem))); + return ReturnValue(Value); +#else + return UR_RESULT_ERROR_INVALID_VALUE; +#endif + } case UR_USM_ALLOC_INFO_DEVICE: { // get device index associated with this pointer UR_CHECK_ERROR(hipPointerGetAttributes(&hipPointerAttributeType, pMem)); From 15638c9a38d72b927aefb9a128c69d41ed76f1a4 Mon Sep 17 00:00:00 2001 From: Jin Z <5zj@cousteau.ftpn.ornl.gov> Date: Mon, 30 Oct 2023 21:28:30 -0400 Subject: [PATCH 2/2] [UR][HIP] format the codes --- source/adapters/hip/usm.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index 3367fc03ab..124aeba557 100644 --- a/source/adapters/hip/usm.cpp +++ b/source/adapters/hip/usm.cpp @@ -193,9 +193,9 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem, case UR_USM_ALLOC_INFO_BASE_PTR: { #if (HIP_VERSION_MAJOR >= 5) void *Base; - UR_CHECK_ERROR(hipPointerGetAttribute( - &Base, HIP_POINTER_ATTRIBUTE_RANGE_START_ADDR, - const_cast(pMem))); + UR_CHECK_ERROR( + hipPointerGetAttribute(&Base, HIP_POINTER_ATTRIBUTE_RANGE_START_ADDR, + const_cast(pMem))); return ReturnValue(Base); #else return UR_RESULT_ERROR_INVALID_VALUE; @@ -204,9 +204,9 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem, case UR_USM_ALLOC_INFO_SIZE: { #if (HIP_VERSION_MAJOR >= 5) size_t Value; - UR_CHECK_ERROR(hipPointerGetAttribute( - &Value, HIP_POINTER_ATTRIBUTE_RANGE_SIZE, - const_cast(pMem))); + UR_CHECK_ERROR(hipPointerGetAttribute(&Value, + HIP_POINTER_ATTRIBUTE_RANGE_SIZE, + const_cast(pMem))); return ReturnValue(Value); #else return UR_RESULT_ERROR_INVALID_VALUE;