Skip to content

Commit

Permalink
[UR][CUDA] Change MAX_MEMORY_BANDWIDTH device query to uint64 (#16869)
Browse files Browse the repository at this point in the history
Migrated from [PR
2653](oneapi-src/unified-runtime#2653)
  • Loading branch information
omarahmed1111 authored Feb 26, 2025
1 parent 9a20754 commit a4f9764
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion unified-runtime/include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ typedef enum ur_device_info_t {
UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94,
/// [uint32_t][optional-query] return Intel GPU number of threads per EU
UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95,
/// [uint32_t][optional-query] return max memory bandwidth in Mb/s
/// [uint64_t][optional-query] return max memory bandwidth in B/s
UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96,
/// [::ur_bool_t] device supports sRGB images
UR_DEVICE_INFO_IMAGE_SRGB = 97,
Expand Down
6 changes: 3 additions & 3 deletions unified-runtime/include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4186,9 +4186,9 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,
os << ")";
} break;
case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: {
const uint32_t *tptr = (const uint32_t *)ptr;
if (sizeof(uint32_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint32_t)
const uint64_t *tptr = (const uint64_t *)ptr;
if (sizeof(uint64_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint64_t)
<< ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
Expand Down
2 changes: 1 addition & 1 deletion unified-runtime/scripts/core/device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ etors:
- name: GPU_HW_THREADS_PER_EU
desc: "[uint32_t][optional-query] return Intel GPU number of threads per EU"
- name: MAX_MEMORY_BANDWIDTH
desc: "[uint32_t][optional-query] return max memory bandwidth in Mb/s"
desc: "[uint64_t][optional-query] return max memory bandwidth in B/s"
- name: IMAGE_SRGB
desc: "[$x_bool_t] device supports sRGB images"
- name: BUILD_ON_SUBDEVICE
Expand Down
6 changes: 5 additions & 1 deletion unified-runtime/source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
hDevice->get()));
}

uint32_t MemoryBandwidth = MemoryClockKHz * MemoryBusWidth * 250;
// This is a collection of all constants mentioned in this computation:
// https://github.com/jeffhammond/HPCInfo/blob/aae05c733016cc8fbb91ee71fc8076f17fa7b912/cuda/gpu-detect.cu#L241
constexpr uint64_t MemoryBandwidthConstant = 250;
uint64_t MemoryBandwidth =
MemoryBandwidthConstant * MemoryClockKHz * MemoryBusWidth;

return ReturnValue(MemoryBandwidth);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ TEST_P(urDeviceGetInfoTest, SuccessIntelMaxMemoryBandwidth) {
urDeviceGetInfo(device, property_name, 0, nullptr, &property_size),
property_name);

uint32_t property_value = 0;
uint64_t property_value = 0;
ASSERT_QUERY_RETURNS_VALUE(urDeviceGetInfo(device, property_name,
property_size, &property_value,
nullptr),
Expand Down
2 changes: 1 addition & 1 deletion unified-runtime/tools/urinfo/urinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ inline void printDeviceInfos(ur_device_handle_t hDevice,
std::cout << prefix;
printDeviceInfo<uint32_t>(hDevice, UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU);
std::cout << prefix;
printDeviceInfo<uint32_t>(hDevice, UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH);
printDeviceInfo<uint64_t>(hDevice, UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH);
std::cout << prefix;
printDeviceInfo<ur_bool_t>(hDevice, UR_DEVICE_INFO_IMAGE_SRGB);
std::cout << prefix;
Expand Down

0 comments on commit a4f9764

Please sign in to comment.