Skip to content

Commit a4f9764

Browse files
[UR][CUDA] Change MAX_MEMORY_BANDWIDTH device query to uint64 (#16869)
Migrated from [PR 2653](oneapi-src/unified-runtime#2653)
1 parent 9a20754 commit a4f9764

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

unified-runtime/include/ur_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@ typedef enum ur_device_info_t {
21232123
UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94,
21242124
/// [uint32_t][optional-query] return Intel GPU number of threads per EU
21252125
UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95,
2126-
/// [uint32_t][optional-query] return max memory bandwidth in Mb/s
2126+
/// [uint64_t][optional-query] return max memory bandwidth in B/s
21272127
UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96,
21282128
/// [::ur_bool_t] device supports sRGB images
21292129
UR_DEVICE_INFO_IMAGE_SRGB = 97,

unified-runtime/include/ur_print.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,9 +4186,9 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,
41864186
os << ")";
41874187
} break;
41884188
case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: {
4189-
const uint32_t *tptr = (const uint32_t *)ptr;
4190-
if (sizeof(uint32_t) > size) {
4191-
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint32_t)
4189+
const uint64_t *tptr = (const uint64_t *)ptr;
4190+
if (sizeof(uint64_t) > size) {
4191+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint64_t)
41924192
<< ")";
41934193
return UR_RESULT_ERROR_INVALID_SIZE;
41944194
}

unified-runtime/scripts/core/device.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ etors:
393393
- name: GPU_HW_THREADS_PER_EU
394394
desc: "[uint32_t][optional-query] return Intel GPU number of threads per EU"
395395
- name: MAX_MEMORY_BANDWIDTH
396-
desc: "[uint32_t][optional-query] return max memory bandwidth in Mb/s"
396+
desc: "[uint64_t][optional-query] return max memory bandwidth in B/s"
397397
- name: IMAGE_SRGB
398398
desc: "[$x_bool_t] device supports sRGB images"
399399
- name: BUILD_ON_SUBDEVICE

unified-runtime/source/adapters/cuda/device.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10091009
hDevice->get()));
10101010
}
10111011

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

10141018
return ReturnValue(MemoryBandwidth);
10151019
}

unified-runtime/test/conformance/device/urDeviceGetInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ TEST_P(urDeviceGetInfoTest, SuccessIntelMaxMemoryBandwidth) {
16431643
urDeviceGetInfo(device, property_name, 0, nullptr, &property_size),
16441644
property_name);
16451645

1646-
uint32_t property_value = 0;
1646+
uint64_t property_value = 0;
16471647
ASSERT_QUERY_RETURNS_VALUE(urDeviceGetInfo(device, property_name,
16481648
property_size, &property_value,
16491649
nullptr),

unified-runtime/tools/urinfo/urinfo.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ inline void printDeviceInfos(ur_device_handle_t hDevice,
271271
std::cout << prefix;
272272
printDeviceInfo<uint32_t>(hDevice, UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU);
273273
std::cout << prefix;
274-
printDeviceInfo<uint32_t>(hDevice, UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH);
274+
printDeviceInfo<uint64_t>(hDevice, UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH);
275275
std::cout << prefix;
276276
printDeviceInfo<ur_bool_t>(hDevice, UR_DEVICE_INFO_IMAGE_SRGB);
277277
std::cout << prefix;

0 commit comments

Comments
 (0)