Skip to content

[HIP] Support range start address and size in the USM allocation #1012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions source/adapters/hip/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe initialize Base (and Value in the case below) to silence the warning?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to reformat the codes for the check error.

Should we initialize these values in the CUDA and HIP versions ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware they are uninitialized there as well, sorry. I guess it would be helpful, build setups can fail with Werror and unitialized variable warnings.

UR_CHECK_ERROR(
hipPointerGetAttribute(&Base, HIP_POINTER_ATTRIBUTE_RANGE_START_ADDR,
const_cast<hipDeviceptr_t>(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<hipDeviceptr_t>(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));
Expand Down