Skip to content

Commit 607dff4

Browse files
authored
[UR] Stop using extension strings to report support for exp features. (#16046)
With this change all experimental features now add a ur_device_info_t enum which adapters report support through, and all EXTENSION_STRING macros have been removed.
1 parent e68ceb9 commit 607dff4

File tree

27 files changed

+276
-251
lines changed

27 files changed

+276
-251
lines changed

sycl/unittests/helpers/UrMock.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ inline ur_result_t mock_urDeviceGetInfo(void *pParams) {
156156
auto params = reinterpret_cast<ur_device_get_info_params_t *>(pParams);
157157
constexpr char MockDeviceName[] = "Mock device";
158158
constexpr char MockSupportedExtensions[] =
159-
"cl_khr_fp64 cl_khr_fp16 cl_khr_il_program ur_exp_command_buffer";
159+
"cl_khr_fp64 cl_khr_fp16 cl_khr_il_program";
160160
switch (*params->ppropName) {
161161
case UR_DEVICE_INFO_TYPE: {
162162
// Act like any device is a GPU.

unified-runtime/include/ur_api.h

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,8 +2087,9 @@ typedef enum ur_device_info_t {
20872087
UR_DEVICE_INFO_VERSION = 70,
20882088
/// [char[]] null-terminated version of backend runtime
20892089
UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION = 71,
2090-
/// [char[]] Return a null-terminated space separated list of extension
2091-
/// names
2090+
/// [char[]] Return a null-terminated string representing any backend
2091+
/// extensions supported by the adapter. Format and content is entirely
2092+
/// adapter defined.
20922093
UR_DEVICE_INFO_EXTENSIONS = 72,
20932094
/// [size_t] Maximum size in bytes of internal printf buffer
20942095
UR_DEVICE_INFO_PRINTF_BUFFER_SIZE = 73,
@@ -2320,6 +2321,17 @@ typedef enum ur_device_info_t {
23202321
/// [::ur_bool_t] returns true if the device supports enqueueing of
23212322
/// allocations and frees.
23222323
UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_EXP = 0x2050,
2324+
/// [::ur_bool_t] Returns true if the device supports the use of kernel
2325+
/// launch properties.
2326+
UR_DEVICE_INFO_LAUNCH_PROPERTIES_SUPPORT_EXP = 0x3000,
2327+
/// [::ur_bool_t] Returns true if the device supports the USM P2P
2328+
/// experimental feature.
2329+
UR_DEVICE_INFO_USM_P2P_SUPPORT_EXP = 0x4000,
2330+
/// [::ur_bool_t] Returns true if the device supports cooperative kernels.
2331+
UR_DEVICE_INFO_COOPERATIVE_KERNEL_SUPPORT_EXP = 0x5000,
2332+
/// [::ur_bool_t] Returns true if the device supports the multi device
2333+
/// compile experimental feature.
2334+
UR_DEVICE_INFO_MULTI_DEVICE_COMPILE_SUPPORT_EXP = 0x6000,
23232335
/// @cond
23242336
UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff
23252337
/// @endcond
@@ -2345,7 +2357,7 @@ typedef enum ur_device_info_t {
23452357
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
23462358
/// + `NULL == hDevice`
23472359
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
2348-
/// + `::UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_EXP < propName`
2360+
/// + `::UR_DEVICE_INFO_MULTI_DEVICE_COMPILE_SUPPORT_EXP < propName`
23492361
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
23502362
/// + If `propName` is not supported by the adapter.
23512363
/// - ::UR_RESULT_ERROR_INVALID_SIZE
@@ -10421,13 +10433,6 @@ typedef enum ur_exp_command_buffer_command_info_t {
1042110433

1042210434
} ur_exp_command_buffer_command_info_t;
1042310435

10424-
///////////////////////////////////////////////////////////////////////////////
10425-
#ifndef UR_COMMAND_BUFFER_EXTENSION_STRING_EXP
10426-
/// @brief The extension string which defines support for command-buffers which
10427-
/// is returned when querying device extensions.
10428-
#define UR_COMMAND_BUFFER_EXTENSION_STRING_EXP "ur_exp_command_buffer"
10429-
#endif // UR_COMMAND_BUFFER_EXTENSION_STRING_EXP
10430-
1043110436
///////////////////////////////////////////////////////////////////////////////
1043210437
/// @brief Command-Buffer Descriptor Type
1043310438
typedef struct ur_exp_command_buffer_desc_t {
@@ -11722,13 +11727,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferGetInfoExp(
1172211727
#if !defined(__GNUC__)
1172311728
#pragma region cooperative_kernels_(experimental)
1172411729
#endif
11725-
///////////////////////////////////////////////////////////////////////////////
11726-
#ifndef UR_COOPERATIVE_KERNELS_EXTENSION_STRING_EXP
11727-
/// @brief The extension string which defines support for cooperative-kernels
11728-
/// which is returned when querying device extensions.
11729-
#define UR_COOPERATIVE_KERNELS_EXTENSION_STRING_EXP "ur_exp_cooperative_kernels"
11730-
#endif // UR_COOPERATIVE_KERNELS_EXTENSION_STRING_EXP
11731-
1173211730
///////////////////////////////////////////////////////////////////////////////
1173311731
/// @brief Enqueue a command to execute a cooperative kernel
1173411732
///
@@ -11878,13 +11876,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueTimestampRecordingExp(
1187811876
#if !defined(__GNUC__)
1187911877
#pragma region launch_properties_(experimental)
1188011878
#endif
11881-
///////////////////////////////////////////////////////////////////////////////
11882-
#ifndef UR_LAUNCH_PROPERTIES_EXTENSION_STRING_EXP
11883-
/// @brief The extension string that defines support for the Launch Properties
11884-
/// extension, which is returned when querying device extensions.
11885-
#define UR_LAUNCH_PROPERTIES_EXTENSION_STRING_EXP "ur_exp_launch_properties"
11886-
#endif // UR_LAUNCH_PROPERTIES_EXTENSION_STRING_EXP
11887-
1188811879
///////////////////////////////////////////////////////////////////////////////
1188911880
/// @brief Specifies a launch property id
1189011881
///
@@ -12031,14 +12022,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp(
1203112022
#if !defined(__GNUC__)
1203212023
#pragma region multi_device_compile_(experimental)
1203312024
#endif
12034-
///////////////////////////////////////////////////////////////////////////////
12035-
#ifndef UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
12036-
/// @brief The extension string which defines support for test
12037-
/// which is returned when querying device extensions.
12038-
#define UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP \
12039-
"ur_exp_multi_device_compile"
12040-
#endif // UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
12041-
1204212025
///////////////////////////////////////////////////////////////////////////////
1204312026
/// @brief Produces an executable program from one program, negates need for the
1204412027
/// linking step.
@@ -12226,13 +12209,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMReleaseExp(
1222612209
#if !defined(__GNUC__)
1222712210
#pragma region usm_p2p_(experimental)
1222812211
#endif
12229-
///////////////////////////////////////////////////////////////////////////////
12230-
#ifndef UR_USM_P2P_EXTENSION_STRING_EXP
12231-
/// @brief The extension string that defines support for USM P2P which is
12232-
/// returned when querying device extensions.
12233-
#define UR_USM_P2P_EXTENSION_STRING_EXP "ur_exp_usm_p2p"
12234-
#endif // UR_USM_P2P_EXTENSION_STRING_EXP
12235-
1223612212
///////////////////////////////////////////////////////////////////////////////
1223712213
/// @brief Supported peer info
1223812214
typedef enum ur_exp_peer_info_t {

unified-runtime/include/ur_print.hpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,18 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
30323032
case UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_EXP:
30333033
os << "UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_EXP";
30343034
break;
3035+
case UR_DEVICE_INFO_LAUNCH_PROPERTIES_SUPPORT_EXP:
3036+
os << "UR_DEVICE_INFO_LAUNCH_PROPERTIES_SUPPORT_EXP";
3037+
break;
3038+
case UR_DEVICE_INFO_USM_P2P_SUPPORT_EXP:
3039+
os << "UR_DEVICE_INFO_USM_P2P_SUPPORT_EXP";
3040+
break;
3041+
case UR_DEVICE_INFO_COOPERATIVE_KERNEL_SUPPORT_EXP:
3042+
os << "UR_DEVICE_INFO_COOPERATIVE_KERNEL_SUPPORT_EXP";
3043+
break;
3044+
case UR_DEVICE_INFO_MULTI_DEVICE_COMPILE_SUPPORT_EXP:
3045+
os << "UR_DEVICE_INFO_MULTI_DEVICE_COMPILE_SUPPORT_EXP";
3046+
break;
30353047
default:
30363048
os << "unknown enumerator";
30373049
break;
@@ -5036,6 +5048,58 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,
50365048

50375049
os << ")";
50385050
} break;
5051+
case UR_DEVICE_INFO_LAUNCH_PROPERTIES_SUPPORT_EXP: {
5052+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
5053+
if (sizeof(ur_bool_t) > size) {
5054+
os << "invalid size (is: " << size
5055+
<< ", expected: >=" << sizeof(ur_bool_t) << ")";
5056+
return UR_RESULT_ERROR_INVALID_SIZE;
5057+
}
5058+
os << (const void *)(tptr) << " (";
5059+
5060+
os << *tptr;
5061+
5062+
os << ")";
5063+
} break;
5064+
case UR_DEVICE_INFO_USM_P2P_SUPPORT_EXP: {
5065+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
5066+
if (sizeof(ur_bool_t) > size) {
5067+
os << "invalid size (is: " << size
5068+
<< ", expected: >=" << sizeof(ur_bool_t) << ")";
5069+
return UR_RESULT_ERROR_INVALID_SIZE;
5070+
}
5071+
os << (const void *)(tptr) << " (";
5072+
5073+
os << *tptr;
5074+
5075+
os << ")";
5076+
} break;
5077+
case UR_DEVICE_INFO_COOPERATIVE_KERNEL_SUPPORT_EXP: {
5078+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
5079+
if (sizeof(ur_bool_t) > size) {
5080+
os << "invalid size (is: " << size
5081+
<< ", expected: >=" << sizeof(ur_bool_t) << ")";
5082+
return UR_RESULT_ERROR_INVALID_SIZE;
5083+
}
5084+
os << (const void *)(tptr) << " (";
5085+
5086+
os << *tptr;
5087+
5088+
os << ")";
5089+
} break;
5090+
case UR_DEVICE_INFO_MULTI_DEVICE_COMPILE_SUPPORT_EXP: {
5091+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
5092+
if (sizeof(ur_bool_t) > size) {
5093+
os << "invalid size (is: " << size
5094+
<< ", expected: >=" << sizeof(ur_bool_t) << ")";
5095+
return UR_RESULT_ERROR_INVALID_SIZE;
5096+
}
5097+
os << (const void *)(tptr) << " (";
5098+
5099+
os << *tptr;
5100+
5101+
os << ")";
5102+
} break;
50395103
default:
50405104
os << "unknown enumerator";
50415105
return UR_RESULT_ERROR_INVALID_ENUMERATION;

unified-runtime/scripts/core/EXP-COMMAND-BUFFER.rst

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,36 +40,14 @@ Querying Command-Buffer Support
4040
--------------------------------------------------------------------------------
4141

4242
Support for command-buffers can be queried for a given device/adapter by using
43-
the device info query with ${X}_DEVICE_INFO_EXTENSIONS. Adapters supporting this
44-
experimental feature will report the string "ur_exp_command_buffer" in the
45-
returned list of supported extensions.
46-
47-
.. hint::
48-
The macro ${X}_COMMAND_BUFFER_EXTENSION_STRING_EXP is defined for the string
49-
returned from extension queries for this feature. Since the actual string
50-
may be subject to change it is safer to use this macro when querying for
51-
support for this experimental feature.
43+
the device info query with ${X}_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP. Adapters
44+
supporting this experimental feature will report ``true``.
5245

5346
.. parsed-literal::
5447
55-
// Retrieve length of extension string
56-
size_t returnedSize;
57-
${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_EXTENSIONS, 0, nullptr,
58-
&returnedSize);
59-
60-
// Retrieve extension string
61-
std::unique_ptr<char[]> returnedExtensions(new char[returnedSize]);
62-
${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_EXTENSIONS, returnedSize,
63-
returnedExtensions.get(), nullptr);
64-
65-
std::string_view ExtensionsString(returnedExtensions.get());
66-
bool CmdBufferSupport =
67-
ExtensionsString.find(${X}_COMMAND_BUFFER_EXTENSION_STRING_EXP)
68-
!= std::string::npos;
69-
70-
.. note::
71-
The ${X}_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP device info query exists to
72-
serve the same purpose as ${X}_COMMAND_BUFFER_EXTENSION_STRING_EXP.
48+
ur_bool_t CmdBufferSupport = false;
49+
${x}DeviceGetInfo(hDevice, ${X}_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP,
50+
sizeof(CmdBufferSupport), &CmdBufferSupport, nullptr);
7351
7452
Command-Buffer Creation
7553
--------------------------------------------------------------------------------
@@ -402,10 +380,6 @@ ${x}CommandBufferUpdateSignalEventExp there must also have been a non-null
402380
API
403381
--------------------------------------------------------------------------------
404382

405-
Macros
406-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407-
* ${X}_COMMAND_BUFFER_EXTENSION_STRING_EXP
408-
409383
Enums
410384
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
411385
* ${x}_device_info_t
@@ -519,6 +493,9 @@ Changelog
519493
+-----------+-------------------------------------------------------+
520494
| 1.9 | Rename enqueue API to urEnqueueCommandBufferExp |
521495
+-----------+-------------------------------------------------------+
496+
| 1.10 | Remove extension string macro, make device info enum |
497+
| | primary mechanism for reporting support. |
498+
+-----------+-------------------------------------------------------+
522499

523500
Contributors
524501
--------------------------------------------------------------------------------

unified-runtime/scripts/core/EXP-COOPERATIVE-KERNELS.rst

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ The functions defined here align with those specified in Level Zero.
3636
API
3737
--------------------------------------------------------------------------------
3838

39-
Macros
39+
Enums
4040
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41-
* ${X}_COOPERATIVE_KERNELS_EXTENSION_STRING_EXP
41+
* ${x}_device_info_t
42+
* ${X}_DEVICE_INFO_COOPERATIVE_KERNEL_SUPPORT_EXP
4243

4344
Functions
4445
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -47,22 +48,25 @@ Functions
4748

4849
Changelog
4950
--------------------------------------------------------------------------------
50-
+-----------+------------------------+
51-
| Revision | Changes |
52-
+===========+========================+
53-
| 1.0 | Initial Draft |
54-
+-----------+------------------------+
51+
+-----------+---------------------------------------------+
52+
| Revision | Changes |
53+
+===========+=============================================+
54+
| 1.0 | Initial Draft |
55+
+-----------+---------------------------------------------+
56+
| 1.1 | Switch from extension string macro to |
57+
| | device info enum for reporting support. |
58+
+-----------+---------------------------------------------+
5559

5660
Support
5761
--------------------------------------------------------------------------------
5862

59-
Adapters which support this experimental feature *must* return the valid string
60-
defined in ``${X}_COOPERATIVE_KERNELS_EXTENSION_STRING_EXP``
61-
as one of the options from ${x}DeviceGetInfo when querying for
62-
${X}_DEVICE_INFO_EXTENSIONS. Conversely, before using any of the
63-
functionality defined in this experimental feature the user *must* use the
64-
device query to determine if the adapter supports this feature.
63+
Adapters which support this experimental feature *must* return ``true`` when
64+
queried for ${X}_DEVICE_INFO_COOPERATIVE_KERNEL_SUPPORT_EXP via
65+
${x}DeviceGetInfo. Conversely, before using any of the functionality defined in
66+
this experimental feature the user *must* use the device query to determine if
67+
the adapter supports this feature.
6568

6669
Contributors
6770
--------------------------------------------------------------------------------
6871
* Michael Aziz `michael.aziz@intel.com <michael.aziz@intel.com>`_
72+
* Aaron Greig `aaron.greig@codeplay.com <aaron.greig@codeplay.com>`_

unified-runtime/scripts/core/EXP-LAUNCH-PROPERTIES.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,12 @@ cooperative kernels Unified-Runtime extension.
5555
API
5656
--------------------------------------------------------------------------------
5757

58-
Macros
59-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60-
61-
* ${X}_LAUNCH_PROPERTIES_EXTENSION_STRING_EXP
62-
6358
Enums
6459
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6560

61+
* ${x}_device_info_t
62+
* ${X}_DEVICE_INFO_LAUNCH_PROPERTIES_SUPPORT_EXP
63+
6664
* ${x}_exp_launch_property_id_t
6765

6866
Unions
@@ -83,9 +81,12 @@ Functions
8381
Support
8482
--------------------------------------------------------------------------------
8583

86-
Adapters which support this experimental feature *must* return the valid string
87-
defined in ${X}_LAUNCH_PROPERTIES_EXTENSION_STRING_EXP as one of the options from
88-
${x}DeviceGetInfo when querying for ${X}_DEVICE_INFO_EXTENSIONS.
84+
Adapters which support this experimental feature *must* return ``true`` when
85+
queried for ${X}_DEVICE_INFO_LAUNCH_PROPERTIES_SUPPORT_EXP via
86+
${x}DeviceGetInfo. Conversely, before using any of the functionality defined
87+
in this experimental feature the user *must* use the device query to determine
88+
if the adapter supports this feature.
89+
8990

9091
Changelog
9192
--------------------------------------------------------------------------------
@@ -95,8 +96,12 @@ Changelog
9596
+===========+=============================================+
9697
| 1.0 | Initial Draft |
9798
+-----------+---------------------------------------------+
99+
| 1.1 | Switch from extension string macro to |
100+
| | device info enum for reporting support. |
101+
+-----------+---------------------------------------------+
98102

99103
Contributors
100104
--------------------------------------------------------------------------------
101105

102106
* JackAKirk `jack.kirk@codeplay.com <jack.kirk@codeplay.com>`_
107+
* Aaron Greig `aaron.greig@codeplay.com <aaron.greig@codeplay.com>`_

0 commit comments

Comments
 (0)