Skip to content

Commit 1e55cf3

Browse files
authored
[SYCL][HIP] Fix max constant memory device query (#5168)
This fixes the `Basic/info.cpp` test for HIP AMD. The issue here is that AMD GPU report a very large constant memory (confirmed using `clinfo` as well). But the HIP entry point to query that information takes a `int*`. So the value will show up as negative, even though it's the correct value. So remove the assertion on if the value is positive and cast it back to `unsigned` before returning it.
1 parent 22532c2 commit 1e55cf3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sycl/plugins/hip/pi_hip.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,12 +1319,16 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name,
13191319
pi_uint64{bytes});
13201320
}
13211321
case PI_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE: {
1322-
int constant_memory = 0;
1322+
unsigned int constant_memory = 0;
1323+
1324+
// hipDeviceGetAttribute takes a int*, however the size of the constant
1325+
// memory on AMD GPU may be larger than what can fit in the positive part
1326+
// of a signed integer, so use an unsigned integer and cast the pointer to
1327+
// int*.
13231328
cl::sycl::detail::pi::assertion(
1324-
hipDeviceGetAttribute(&constant_memory,
1329+
hipDeviceGetAttribute(reinterpret_cast<int *>(&constant_memory),
13251330
hipDeviceAttributeTotalConstantMemory,
13261331
device->get()) == hipSuccess);
1327-
cl::sycl::detail::pi::assertion(constant_memory >= 0);
13281332

13291333
return getInfo(param_value_size, param_value, param_value_size_ret,
13301334
pi_uint64(constant_memory));

0 commit comments

Comments
 (0)