Skip to content

Commit efd29e7

Browse files
committed
Add device info query to report support for native asserts.
This allows cuda and hip to stop reporting the relevant opencl extension string, see issue intel#1374
1 parent 3f1274d commit efd29e7

File tree

10 files changed

+43
-8
lines changed

10 files changed

+43
-8
lines changed

unified-runtime/include/ur_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,6 +2194,9 @@ typedef enum ur_device_info_t {
21942194
/// [::ur_bool_t] support the ::urProgramSetSpecializationConstants entry
21952195
/// point
21962196
UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS = 121,
2197+
/// [::ur_bool_t] return true if the device has a native assert
2198+
/// implementation.
2199+
UR_DEVICE_INFO_USE_NATIVE_ASSERT = 122,
21972200
/// [::ur_bool_t] Returns true if the device supports the use of
21982201
/// command-buffers.
21992202
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000,

unified-runtime/include/ur_print.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,6 +2876,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
28762876
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
28772877
os << "UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS";
28782878
break;
2879+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
2880+
os << "UR_DEVICE_INFO_USE_NATIVE_ASSERT";
2881+
break;
28792882
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
28802883
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
28812884
break;
@@ -4533,6 +4536,19 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,
45334536

45344537
os << ")";
45354538
} break;
4539+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT: {
4540+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
4541+
if (sizeof(ur_bool_t) > size) {
4542+
os << "invalid size (is: " << size
4543+
<< ", expected: >=" << sizeof(ur_bool_t) << ")";
4544+
return UR_RESULT_ERROR_INVALID_SIZE;
4545+
}
4546+
os << (const void *)(tptr) << " (";
4547+
4548+
os << *tptr;
4549+
4550+
os << ")";
4551+
} break;
45364552
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
45374553
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
45384554
if (sizeof(ur_bool_t) > size) {

unified-runtime/scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ etors:
447447
desc: "[uint32_t] the number of compute units for specific backend."
448448
- name: PROGRAM_SET_SPECIALIZATION_CONSTANTS
449449
desc: "[$x_bool_t] support the $xProgramSetSpecializationConstants entry point"
450+
- name: USE_NATIVE_ASSERT
451+
desc: "[$x_bool_t] return true if the device has a native assert implementation."
450452
--- #--------------------------------------------------------------------------
451453
type: function
452454
desc: "Retrieves various information about device"

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

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

619619
std::string SupportedExtensions = "cl_khr_fp64 cl_khr_subgroups ";
620-
SupportedExtensions += "cl_intel_devicelib_assert ";
621620
// Return supported for the UR command-buffer experimental feature
622621
SupportedExtensions += "ur_exp_command_buffer ";
623622
SupportedExtensions += "ur_exp_usm_p2p ";
@@ -1114,6 +1113,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
11141113
}
11151114
case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP:
11161115
return ReturnValue(false);
1116+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
1117+
return ReturnValue(true);
1118+
11171119
default:
11181120
break;
11191121
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
558558
return ReturnValue("");
559559
}
560560
case UR_DEVICE_INFO_EXTENSIONS: {
561-
// TODO: Remove comment when HIP support native asserts.
562-
// DEVICELIB_ASSERT extension is set so fallback assert
563-
// postprocessing is NOP. HIP 4.3 docs indicate support for
564-
// native asserts are in progress
565561
std::string SupportedExtensions = "";
566-
SupportedExtensions += "cl_intel_devicelib_assert ";
567562
SupportedExtensions += "ur_exp_usm_p2p ";
568563

569564
int RuntimeVersion = 0;
@@ -1107,6 +1102,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
11071102
case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP: {
11081103
return ReturnValue(false);
11091104
}
1105+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
1106+
return ReturnValue(true);
11101107
default:
11111108
break;
11121109
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,8 @@ ur_result_t urDeviceGetInfo(
12101210
return ReturnValue(false);
12111211
case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED:
12121212
return ReturnValue(false);
1213+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
1214+
return ReturnValue(false);
12131215
default:
12141216
logger::error("Unsupported ParamName in urGetDeviceInfo");
12151217
logger::error("ParamNameParamName={}(0x{})", ParamName,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
426426

427427
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
428428
return ReturnValue(false);
429+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
430+
return ReturnValue(false);
429431

430432
case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP:
431433
return ReturnValue(false);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
12271227
return ReturnValue(false);
12281228
case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP:
12291229
return ReturnValue(false);
1230+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT: {
1231+
bool Supported = false;
1232+
UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
1233+
cl_adapter::cast<cl_device_id>(hDevice), {"cl_intel_devicelib_assert"},
1234+
Supported));
1235+
return ReturnValue(Supported);
1236+
}
12301237
default: {
12311238
return UR_RESULT_ERROR_INVALID_ENUMERATION;
12321239
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ static std::unordered_map<ur_device_info_t, size_t> device_info_size_map = {
129129
{UR_DEVICE_INFO_ESIMD_SUPPORT, sizeof(ur_bool_t)},
130130
{UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t)},
131131
{UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, sizeof(ur_bool_t)},
132-
{UR_DEVICE_INFO_NUM_COMPUTE_UNITS, sizeof(uint32_t)}};
132+
{UR_DEVICE_INFO_NUM_COMPUTE_UNITS, sizeof(uint32_t)},
133+
{UR_DEVICE_INFO_USE_NATIVE_ASSERT, sizeof(ur_bool_t)}};
133134

134135
using urDeviceGetInfoTest = uur::urDeviceTestWithParam<ur_device_info_t>;
135136

@@ -255,7 +256,8 @@ UUR_DEVICE_TEST_SUITE_WITH_PARAM(
255256
UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF, //
256257
UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT, //
257258
UR_DEVICE_INFO_NUM_COMPUTE_UNITS, //
258-
UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS //
259+
UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS, //
260+
UR_DEVICE_INFO_USE_NATIVE_ASSERT //
259261
),
260262
uur::deviceTestWithParamPrinter<ur_device_info_t>);
261263

unified-runtime/tools/urinfo/urinfo.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ inline void printDeviceInfos(ur_device_handle_t hDevice,
332332
printDeviceInfo<ur_bool_t>(
333333
hDevice, UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS);
334334
std::cout << prefix;
335+
printDeviceInfo<ur_bool_t>(hDevice, UR_DEVICE_INFO_USE_NATIVE_ASSERT);
336+
std::cout << prefix;
335337
printDeviceInfo<ur_bool_t>(hDevice,
336338
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP);
337339
std::cout << prefix;

0 commit comments

Comments
 (0)