Skip to content

[SYCL][HIP] Fix max constant memory device query #5168

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

Merged
merged 2 commits into from
Jan 11, 2022
Merged
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
10 changes: 7 additions & 3 deletions sycl/plugins/hip/pi_hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,12 +1315,16 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name,
pi_uint64{bytes});
}
case PI_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE: {
int constant_memory = 0;
unsigned int constant_memory = 0;

// hipDeviceGetAttribute takes a int*, however the size of the constant
// memory on AMD GPU may be larger than what can fit in the positive part
// of a signed integer, so use an unsigned integer and cast the pointer to
// int*.
cl::sycl::detail::pi::assertion(
hipDeviceGetAttribute(&constant_memory,
hipDeviceGetAttribute(reinterpret_cast<int *>(&constant_memory),
hipDeviceAttributeTotalConstantMemory,
device->get()) == hipSuccess);
cl::sycl::detail::pi::assertion(constant_memory >= 0);

return getInfo(param_value_size, param_value, param_value_size_ret,
pi_uint64(constant_memory));
Expand Down