From 8922e51bef1a11d50d3001df024bf09f196eae86 Mon Sep 17 00:00:00 2001 From: omarahmed1111 Date: Fri, 31 Jan 2025 17:38:43 +0000 Subject: [PATCH] Change MAX_MEMORY_BANDWIDTH device query to uint64 --- include/ur_api.h | 2 +- include/ur_print.hpp | 6 +++--- scripts/core/device.yml | 2 +- source/adapters/cuda/device.cpp | 4 +++- test/conformance/device/urDeviceGetInfo.cpp | 2 +- tools/urinfo/urinfo.hpp | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 72d35f03a8..dff4c040d6 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -2121,7 +2121,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 Mb/s UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96, /// [::ur_bool_t] device supports sRGB images UR_DEVICE_INFO_IMAGE_SRGB = 97, diff --git a/include/ur_print.hpp b/include/ur_print.hpp index cd96f26fe6..ae3fac295f 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -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; } diff --git a/scripts/core/device.yml b/scripts/core/device.yml index c1fb313fb3..848beebef3 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -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 Mb/s" - name: IMAGE_SRGB desc: "[$x_bool_t] device supports sRGB images" - name: BUILD_ON_SUBDEVICE diff --git a/source/adapters/cuda/device.cpp b/source/adapters/cuda/device.cpp index 3e0ce05c27..c9c87f8e47 100644 --- a/source/adapters/cuda/device.cpp +++ b/source/adapters/cuda/device.cpp @@ -1008,8 +1008,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, &MemoryBusWidth, CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH, hDevice->get())); } + uint64_t MemoryBandwidthConstant = 250; - uint32_t MemoryBandwidth = MemoryClockKHz * MemoryBusWidth * 250; + uint64_t MemoryBandwidth = + MemoryBandwidthConstant * MemoryClockKHz * MemoryBusWidth; return ReturnValue(MemoryBandwidth); } diff --git a/test/conformance/device/urDeviceGetInfo.cpp b/test/conformance/device/urDeviceGetInfo.cpp index 8c6ea452dc..e54ca9f47f 100644 --- a/test/conformance/device/urDeviceGetInfo.cpp +++ b/test/conformance/device/urDeviceGetInfo.cpp @@ -99,7 +99,7 @@ static std::unordered_map device_info_size_map = { {UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, sizeof(uint32_t)}, {UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE, sizeof(uint32_t)}, {UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU, sizeof(uint32_t)}, - {UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH, sizeof(uint32_t)}, + {UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH, sizeof(uint64_t)}, {UR_DEVICE_INFO_IMAGE_SRGB, sizeof(ur_bool_t)}, {UR_DEVICE_INFO_BUILD_ON_SUBDEVICE, sizeof(ur_bool_t)}, {UR_DEVICE_INFO_ATOMIC_64, sizeof(ur_bool_t)}, diff --git a/tools/urinfo/urinfo.hpp b/tools/urinfo/urinfo.hpp index d01245138f..1d465404eb 100644 --- a/tools/urinfo/urinfo.hpp +++ b/tools/urinfo/urinfo.hpp @@ -271,7 +271,7 @@ inline void printDeviceInfos(ur_device_handle_t hDevice, std::cout << prefix; printDeviceInfo(hDevice, UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU); std::cout << prefix; - printDeviceInfo(hDevice, UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH); + printDeviceInfo(hDevice, UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH); std::cout << prefix; printDeviceInfo(hDevice, UR_DEVICE_INFO_IMAGE_SRGB); std::cout << prefix;