Skip to content

Commit 14acfa8

Browse files
committed
Add device info query to report support for devicelib assert.
This allows cuda and hip to stop reporting the opencl extension string, see issue #1374
1 parent 73e54a0 commit 14acfa8

File tree

10 files changed

+40
-3
lines changed

10 files changed

+40
-3
lines changed

include/ur_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,7 @@ typedef enum ur_device_info_t {
16391639
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 118, ///< [::ur_bool_t] return true if the device supports the
16401640
///< `EnqueueDeviceGlobalVariableWrite` and
16411641
///< `EnqueueDeviceGlobalVariableRead` entry points.
1642+
UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT = 119, ///< [::ur_bool_t] return true if the backend supports devicelib assert.
16421643
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of
16431644
///< command-buffers.
16441645
UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_CAPABILITIES_EXP = 0x1001, ///< [::ur_device_command_buffer_update_capability_flags_t] Command-buffer

include/ur_print.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,6 +2550,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
25502550
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
25512551
os << "UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT";
25522552
break;
2553+
case UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT:
2554+
os << "UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT";
2555+
break;
25532556
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
25542557
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
25552558
break;
@@ -4052,6 +4055,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
40524055

40534056
os << ")";
40544057
} break;
4058+
case UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT: {
4059+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
4060+
if (sizeof(ur_bool_t) > size) {
4061+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
4062+
return UR_RESULT_ERROR_INVALID_SIZE;
4063+
}
4064+
os << (const void *)(tptr) << " (";
4065+
4066+
os << *tptr;
4067+
4068+
os << ")";
4069+
} break;
40554070
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
40564071
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
40574072
if (sizeof(ur_bool_t) > size) {

scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ etors:
441441
desc: "[$x_device_handle_t] The composite device containing this component device."
442442
- name: GLOBAL_VARIABLE_SUPPORT
443443
desc: "[$x_bool_t] return true if the device supports the `EnqueueDeviceGlobalVariableWrite` and `EnqueueDeviceGlobalVariableRead` entry points."
444+
- name: DEVICELIB_ASSERT_SUPPORT
445+
desc: "[$x_bool_t] return true if the backend supports devicelib assert."
444446
--- #--------------------------------------------------------------------------
445447
type: function
446448
desc: "Retrieves various information about device"

source/adapters/cuda/device.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
616616
case UR_DEVICE_INFO_EXTENSIONS: {
617617

618618
std::string SupportedExtensions = "cl_khr_fp64 cl_khr_subgroups ";
619-
SupportedExtensions += "cl_intel_devicelib_assert ";
620619
// Return supported for the UR command-buffer experimental feature
621620
SupportedExtensions += "ur_exp_command_buffer ";
622621
SupportedExtensions += "ur_exp_usm_p2p ";
@@ -1105,6 +1104,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
11051104
CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR) >= 9;
11061105
return ReturnValue(static_cast<bool>(Value));
11071106
}
1107+
case UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT:
1108+
return ReturnValue(true);
11081109

11091110
default:
11101111
break;

source/adapters/hip/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
933933
}
934934
case UR_DEVICE_INFO_COMMAND_BUFFER_EVENT_SUPPORT_EXP:
935935
return ReturnValue(false);
936+
case UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT:
937+
return ReturnValue(true);
936938
default:
937939
break;
938940
}

source/adapters/level_zero/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,8 @@ ur_result_t urDeviceGetInfo(
11551155
return ReturnValue(false);
11561156
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
11571157
return ReturnValue(true);
1158+
case UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT:
1159+
return ReturnValue(false);
11581160
default:
11591161
logger::error("Unsupported ParamName in urGetDeviceInfo");
11601162
logger::error("ParamNameParamName={}(0x{})", ParamName,

source/adapters/native_cpu/device.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
414414
case UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP:
415415
return ReturnValue(false);
416416

417+
case UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT:
418+
return ReturnValue(false);
419+
417420
default:
418421
DIE_NO_IMPLEMENTATION;
419422
}

source/adapters/opencl/device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10941094
}
10951095
case UR_DEVICE_INFO_COMMAND_BUFFER_EVENT_SUPPORT_EXP:
10961096
return ReturnValue(false);
1097+
case UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT: {
1098+
bool Supported = false;
1099+
UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
1100+
cl_adapter::cast<cl_device_id>(hDevice), {"cl_intel_devicelib_assert"},
1101+
Supported));
1102+
return ReturnValue(Supported);
1103+
}
10971104
default: {
10981105
return UR_RESULT_ERROR_INVALID_ENUMERATION;
10991106
}

test/conformance/device/urDeviceGetInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static std::unordered_map<ur_device_info_t, size_t> device_info_size_map = {
115115
{UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, sizeof(uint32_t)},
116116
{UR_DEVICE_INFO_COMPONENT_DEVICES, sizeof(uint32_t)},
117117
{UR_DEVICE_INFO_COMPOSITE_DEVICE, sizeof(ur_device_handle_t)},
118-
};
118+
{UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT, sizeof(ur_bool_t)}};
119119

120120
struct urDeviceGetInfoTest : uur::urAllDevicesTest,
121121
::testing::WithParamInterface<ur_device_info_t> {
@@ -236,7 +236,8 @@ INSTANTIATE_TEST_SUITE_P(
236236
UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED, //
237237
UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, //
238238
UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, //
239-
UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS //
239+
UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS, //
240+
UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT //
240241
),
241242
[](const ::testing::TestParamInfo<ur_device_info_t> &info) {
242243
std::stringstream ss;

tools/urinfo/urinfo.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@ inline void printDeviceInfos(ur_device_handle_t hDevice,
331331
std::cout << prefix;
332332
printDeviceInfo<ur_bool_t>(hDevice, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT);
333333
std::cout << prefix;
334+
printDeviceInfo<ur_bool_t>(hDevice,
335+
UR_DEVICE_INFO_DEVICELIB_ASSERT_SUPPORT);
336+
std::cout << prefix;
334337
printDeviceInfo<ur_bool_t>(hDevice,
335338
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP);
336339
std::cout << prefix;

0 commit comments

Comments
 (0)