diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index 7af7401f87..124aeba557 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));