Skip to content

Commit 6a711b3

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 #1374
1 parent ed9fe09 commit 6a711b3

File tree

10 files changed

+40
-8
lines changed

10 files changed

+40
-8
lines changed

include/ur_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,8 @@ typedef enum ur_device_info_t {
16421642
UR_DEVICE_INFO_USM_POOL_SUPPORT = 119, ///< [::ur_bool_t] return true if the device supports USM pooling. Pertains
16431643
///< to the `USMPool` entry points and usage of the `pool` parameter of the
16441644
///< USM alloc entry points.
1645+
UR_DEVICE_INFO_USE_NATIVE_ASSERT = 120, ///< [::ur_bool_t] return true if the device has a native assert
1646+
///< implementation.
16451647
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of
16461648
///< command-buffers.
16471649
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
@@ -2553,6 +2553,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
25532553
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
25542554
os << "UR_DEVICE_INFO_USM_POOL_SUPPORT";
25552555
break;
2556+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
2557+
os << "UR_DEVICE_INFO_USE_NATIVE_ASSERT";
2558+
break;
25562559
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
25572560
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
25582561
break;
@@ -4067,6 +4070,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
40674070

40684071
os << ")";
40694072
} break;
4073+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT: {
4074+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
4075+
if (sizeof(ur_bool_t) > size) {
4076+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
4077+
return UR_RESULT_ERROR_INVALID_SIZE;
4078+
}
4079+
os << (const void *)(tptr) << " (";
4080+
4081+
os << *tptr;
4082+
4083+
os << ")";
4084+
} break;
40704085
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
40714086
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
40724087
if (sizeof(ur_bool_t) > size) {

scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ etors:
443443
desc: "[$x_bool_t] return true if the device supports the `EnqueueDeviceGlobalVariableWrite` and `EnqueueDeviceGlobalVariableRead` entry points."
444444
- name: USM_POOL_SUPPORT
445445
desc: "[$x_bool_t] return true if the device supports USM pooling. Pertains to the `USMPool` entry points and usage of the `pool` parameter of the USM alloc entry points."
446+
- name: USE_NATIVE_ASSERT
447+
desc: "[$x_bool_t] return true if the device has a native assert implementation."
446448
--- #--------------------------------------------------------------------------
447449
type: function
448450
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 ";
@@ -1107,6 +1106,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
11071106
CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR) >= 9;
11081107
return ReturnValue(static_cast<bool>(Value));
11091108
}
1109+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
1110+
return ReturnValue(true);
11101111

11111112
default:
11121113
break;

source/adapters/hip/device.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
543543
return ReturnValue("");
544544
}
545545
case UR_DEVICE_INFO_EXTENSIONS: {
546-
// TODO: Remove comment when HIP support native asserts.
547-
// DEVICELIB_ASSERT extension is set so fallback assert
548-
// postprocessing is NOP. HIP 4.3 docs indicate support for
549-
// native asserts are in progress
550546
std::string SupportedExtensions = "";
551-
SupportedExtensions += "cl_intel_devicelib_assert ";
552547
SupportedExtensions += "ur_exp_usm_p2p ";
553548

554549
int RuntimeVersion = 0;
@@ -935,6 +930,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
935930
}
936931
case UR_DEVICE_INFO_COMMAND_BUFFER_EVENT_SUPPORT_EXP:
937932
return ReturnValue(false);
933+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
934+
return ReturnValue(true);
938935
default:
939936
break;
940937
}

source/adapters/level_zero/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,8 @@ ur_result_t urDeviceGetInfo(
11511151
return ReturnValue(true);
11521152
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
11531153
return ReturnValue(true);
1154+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
1155+
return ReturnValue(false);
11541156
default:
11551157
logger::error("Unsupported ParamName in urGetDeviceInfo");
11561158
logger::error("ParamNameParamName={}(0x{})", ParamName,

source/adapters/native_cpu/device.cpp

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

417417
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
418418
return ReturnValue(false);
419+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
420+
return ReturnValue(false);
419421

420422
default:
421423
DIE_NO_IMPLEMENTATION;

source/adapters/opencl/device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
11191119
}
11201120
case UR_DEVICE_INFO_COMMAND_BUFFER_EVENT_SUPPORT_EXP:
11211121
return ReturnValue(false);
1122+
case UR_DEVICE_INFO_USE_NATIVE_ASSERT: {
1123+
bool Supported = false;
1124+
UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
1125+
cl_adapter::cast<cl_device_id>(hDevice), {"cl_intel_devicelib_assert"},
1126+
Supported));
1127+
return ReturnValue(Supported);
1128+
}
11221129
default: {
11231130
return UR_RESULT_ERROR_INVALID_ENUMERATION;
11241131
}

test/conformance/device/urDeviceGetInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ 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-
{UR_DEVICE_INFO_USM_POOL_SUPPORT, sizeof(ur_bool_t)}};
118+
{UR_DEVICE_INFO_USM_POOL_SUPPORT, sizeof(ur_bool_t)},
119+
{UR_DEVICE_INFO_USE_NATIVE_ASSERT, sizeof(ur_bool_t)}};
119120

120121
struct urDeviceGetInfoTest : uur::urAllDevicesTest,
121122
::testing::WithParamInterface<ur_device_info_t> {
@@ -237,7 +238,8 @@ INSTANTIATE_TEST_SUITE_P(
237238
UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, //
238239
UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, //
239240
UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS, //
240-
UR_DEVICE_INFO_USM_POOL_SUPPORT //
241+
UR_DEVICE_INFO_USM_POOL_SUPPORT, //
242+
UR_DEVICE_INFO_USE_NATIVE_ASSERT //
241243
),
242244
[](const ::testing::TestParamInfo<ur_device_info_t> &info) {
243245
std::stringstream ss;

tools/urinfo/urinfo.hpp

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

0 commit comments

Comments
 (0)