Skip to content

Commit 9c1cb9c

Browse files
authored
[UR] Add a UR device info enum for checking native bfloat16 conversions (#17372)
Signed-off-by: jinge90 <ge.jin@intel.com>
1 parent aa0068b commit 9c1cb9c

File tree

10 files changed

+61
-0
lines changed

10 files changed

+61
-0
lines changed

unified-runtime/include/ur_api.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/include/ur_print.hpp

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ etors:
460460
desc: "[int32_t][optional-query] return min power limit in milliwatts."
461461
- name: MAX_POWER_LIMIT
462462
desc: "[int32_t][optional-query] return max power limit in milliwatts."
463+
- name: BFLOAT16_CONVERSIONS_NATIVE
464+
desc: "[$x_bool_t] support for native bfloat16 conversions"
463465
--- #--------------------------------------------------------------------------
464466
type: function
465467
desc: "Retrieves various information about device"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
254254
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
255255
return ReturnValue(Capabilities);
256256
}
257+
case UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE:
258+
return ReturnValue(false);
257259
case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: {
258260
// NVIDIA devices only support one sub-group size (the warp size)
259261
int WarpSize = 0;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10231023
#else
10241024
return ReturnValue(ur_bool_t{false});
10251025
#endif
1026+
case UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE:
1027+
return ReturnValue(false);
10261028
case UR_DEVICE_INFO_ASYNC_BARRIER:
10271029
return ReturnValue(false);
10281030
case UR_DEVICE_INFO_IL_VERSION:

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,14 @@ ur_result_t urDeviceGetInfo(
10381038
return ze2urResult(errc);
10391039
return ReturnValue(UrRootDev);
10401040
}
1041+
case UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE: {
1042+
bool Bfloat16ConversionSupport =
1043+
(Device->Platform->zeDriverExtensionMap.count(
1044+
ZE_BFLOAT16_CONVERSIONS_EXT_NAME)) ||
1045+
((Device->ZeDeviceProperties->deviceId & 0xfff) == 0x201 ||
1046+
(Device->ZeDeviceProperties->deviceId & 0xff0) == 0xbd0);
1047+
return ReturnValue(Bfloat16ConversionSupport);
1048+
}
10411049
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
10421050
return ReturnValue(true);
10431051
case UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_CAPABILITIES_EXP: {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
344344
return ReturnValue(bool{0});
345345
case UR_DEVICE_INFO_ATOMIC_64:
346346
return ReturnValue(bool{1});
347+
case UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE:
348+
return ReturnValue(bool{0});
347349
case UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT:
348350
return ReturnValue(bool{0});
349351
case UR_DEVICE_INFO_IMAGE_SRGB:

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
15141514
return ReturnValue(UR_EXP_DEVICE_2D_BLOCK_ARRAY_CAPABILITY_FLAG_LOAD |
15151515
UR_EXP_DEVICE_2D_BLOCK_ARRAY_CAPABILITY_FLAG_STORE);
15161516
}
1517+
case UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE: {
1518+
bool Supported = false;
1519+
UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
1520+
cl_adapter::cast<cl_device_id>(hDevice),
1521+
{"cl_intel_bfloat16_conversions"}, Supported));
1522+
return ReturnValue(Supported);
1523+
}
15171524
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
15181525
cl_device_id Dev = cl_adapter::cast<cl_device_id>(hDevice);
15191526
size_t ExtSize = 0;

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,6 +2561,23 @@ TEST_P(urDeviceGetInfoTest, SuccessUseNativeAssert) {
25612561
property_value);
25622562
}
25632563

2564+
TEST_P(urDeviceGetInfoTest, SuccessBfloat16ConversionsNative) {
2565+
size_t property_size = 0;
2566+
const ur_device_info_t property_name =
2567+
UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE;
2568+
2569+
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
2570+
urDeviceGetInfo(device, property_name, 0, nullptr, &property_size),
2571+
property_name);
2572+
ASSERT_EQ(property_size, sizeof(ur_bool_t));
2573+
2574+
uint32_t property_value = 0;
2575+
ASSERT_QUERY_RETURNS_VALUE(urDeviceGetInfo(device, property_name,
2576+
property_size, &property_value,
2577+
nullptr),
2578+
property_value);
2579+
}
2580+
25642581
TEST_P(urDeviceGetInfoTest, SuccessThrottleReasons) {
25652582
// TODO: enable when driver/library version mismatch is fixed in CI.
25662583
// See https://github.com/intel/llvm/issues/17614

unified-runtime/tools/urinfo/urinfo.hpp

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)