Skip to content

Commit ef696fc

Browse files
author
Petr Vesely
committed
[UR] Add extension documentation template
1 parent 836cbff commit ef696fc

File tree

15 files changed

+151
-370
lines changed

15 files changed

+151
-370
lines changed

include/ur.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,18 @@ def __str__(self):
273273
return hex(self.value)
274274

275275

276+
###############################################################################
277+
## @brief Extension name maximum length.
278+
UR_MAX_EXTENSION_NAME_LENGTH = 256
279+
280+
###############################################################################
281+
## @brief Extension type.
282+
class ur_platform_extension_t(Structure):
283+
_fields_ = [
284+
("name", c_char * UR_MAX_EXTENSION_NAME_LENGTH), ## [in] null-terminated extension name.
285+
("version", c_ulong) ## [in] version of the extension using ::UR_MAKE_VERSION.
286+
]
287+
276288
###############################################################################
277289
## @brief Supported platform info
278290
class ur_platform_info_v(IntEnum):
@@ -282,8 +294,9 @@ class ur_platform_info_v(IntEnum):
282294
## size of the info needs to be dynamically queried.
283295
VERSION = 3 ## [char[]] The string denoting the version of the platform. The size of
284296
## the info needs to be dynamically queried.
285-
EXTENSIONS = 4 ## [char[]] The string denoting extensions supported by the platform. The
286-
## size of the info needs to be dynamically queried.
297+
EXTENSIONS = 4 ## [::ur_platform_extension_t[]] an array of ::ur_platform_extension_t
298+
## which express which extensions supported by the platform.
299+
## The size of the info needs to be dynamically queried.
287300
PROFILE = 5 ## [char[]] The string denoting profile of the platform. The size of the
288301
## info needs to be dynamically queried.
289302
BACKEND = 6 ## [::ur_platform_backend_t] The backend of the platform. Identifies the
@@ -323,21 +336,6 @@ def __str__(self):
323336
return str(ur_platform_backend_v(self.value))
324337

325338

326-
###############################################################################
327-
## @brief Extension name maximum length.
328-
UR_MAX_EXTENSION_NAME_LENGTH = 256
329-
330-
###############################################################################
331-
## @brief Extension properties.
332-
class ur_extension_properties_t(Structure):
333-
_fields_ = [
334-
("stype", ur_structure_type_t), ## [in] type of this structure, must be
335-
## ::UR_STRUCTURE_TYPE_EXTENSION_PROPERTIES
336-
("pNext", c_void_p), ## [in,out][optional] pointer to extension-specific structure
337-
("name", c_char * UR_MAX_EXTENSION_NAME_LENGTH), ## [in] null-terminated extension name.
338-
("version", c_ulong) ## [in] version of the extension using ::UR_MAKE_VERSION.
339-
]
340-
341339
###############################################################################
342340
## @brief Target identification strings for
343341
## ::ur_device_binary_t.pDeviceTargetSpec
@@ -1767,13 +1765,6 @@ def __str__(self):
17671765
else:
17681766
_urPlatformGetBackendOption_t = CFUNCTYPE( ur_result_t, ur_platform_handle_t, c_char_p, POINTER(c_char_p) )
17691767

1770-
###############################################################################
1771-
## @brief Function-pointer for urPlatformGetExtensionProperties
1772-
if __use_win_types:
1773-
_urPlatformGetExtensionProperties_t = WINFUNCTYPE( ur_result_t, ur_platform_handle_t, c_ulong, POINTER(ur_extension_properties_t), POINTER(c_ulong) )
1774-
else:
1775-
_urPlatformGetExtensionProperties_t = CFUNCTYPE( ur_result_t, ur_platform_handle_t, c_ulong, POINTER(ur_extension_properties_t), POINTER(c_ulong) )
1776-
17771768

17781769
###############################################################################
17791770
## @brief Table of Platform functions pointers
@@ -1784,8 +1775,7 @@ class ur_platform_dditable_t(Structure):
17841775
("pfnGetNativeHandle", c_void_p), ## _urPlatformGetNativeHandle_t
17851776
("pfnCreateWithNativeHandle", c_void_p), ## _urPlatformCreateWithNativeHandle_t
17861777
("pfnGetApiVersion", c_void_p), ## _urPlatformGetApiVersion_t
1787-
("pfnGetBackendOption", c_void_p), ## _urPlatformGetBackendOption_t
1788-
("pfnGetExtensionProperties", c_void_p) ## _urPlatformGetExtensionProperties_t
1778+
("pfnGetBackendOption", c_void_p) ## _urPlatformGetBackendOption_t
17891779
]
17901780

17911781
###############################################################################
@@ -2784,7 +2774,6 @@ def __init__(self, version : ur_api_version_t):
27842774
self.urPlatformCreateWithNativeHandle = _urPlatformCreateWithNativeHandle_t(self.__dditable.Platform.pfnCreateWithNativeHandle)
27852775
self.urPlatformGetApiVersion = _urPlatformGetApiVersion_t(self.__dditable.Platform.pfnGetApiVersion)
27862776
self.urPlatformGetBackendOption = _urPlatformGetBackendOption_t(self.__dditable.Platform.pfnGetBackendOption)
2787-
self.urPlatformGetExtensionProperties = _urPlatformGetExtensionProperties_t(self.__dditable.Platform.pfnGetExtensionProperties)
27882777

27892778
# call driver to get function pointers
27902779
Context = ur_context_dditable_t()

include/ur_api.h

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,20 @@ urTearDown(
359359
#if !defined(__GNUC__)
360360
#pragma region platform
361361
#endif
362+
///////////////////////////////////////////////////////////////////////////////
363+
#ifndef UR_MAX_EXTENSION_NAME_LENGTH
364+
/// @brief Extension name maximum length.
365+
#define UR_MAX_EXTENSION_NAME_LENGTH 256
366+
#endif // UR_MAX_EXTENSION_NAME_LENGTH
367+
368+
///////////////////////////////////////////////////////////////////////////////
369+
/// @brief Extension type.
370+
typedef struct ur_platform_extension_t {
371+
char name[UR_MAX_EXTENSION_NAME_LENGTH]; ///< [in] null-terminated extension name.
372+
uint32_t version; ///< [in] version of the extension using ::UR_MAKE_VERSION.
373+
374+
} ur_platform_extension_t;
375+
362376
///////////////////////////////////////////////////////////////////////////////
363377
/// @brief Retrieves all available platforms
364378
///
@@ -398,8 +412,9 @@ typedef enum ur_platform_info_t {
398412
///< size of the info needs to be dynamically queried.
399413
UR_PLATFORM_INFO_VERSION = 3, ///< [char[]] The string denoting the version of the platform. The size of
400414
///< the info needs to be dynamically queried.
401-
UR_PLATFORM_INFO_EXTENSIONS = 4, ///< [char[]] The string denoting extensions supported by the platform. The
402-
///< size of the info needs to be dynamically queried.
415+
UR_PLATFORM_INFO_EXTENSIONS = 4, ///< [::ur_platform_extension_t[]] an array of ::ur_platform_extension_t
416+
///< which express which extensions supported by the platform.
417+
///< The size of the info needs to be dynamically queried.
403418
UR_PLATFORM_INFO_PROFILE = 5, ///< [char[]] The string denoting profile of the platform. The size of the
404419
///< info needs to be dynamically queried.
405420
UR_PLATFORM_INFO_BACKEND = 6, ///< [::ur_platform_backend_t] The backend of the platform. Identifies the
@@ -606,41 +621,6 @@ typedef enum ur_platform_backend_t {
606621

607622
} ur_platform_backend_t;
608623

609-
///////////////////////////////////////////////////////////////////////////////
610-
#ifndef UR_MAX_EXTENSION_NAME_LENGTH
611-
/// @brief Extension name maximum length.
612-
#define UR_MAX_EXTENSION_NAME_LENGTH 256
613-
#endif // UR_MAX_EXTENSION_NAME_LENGTH
614-
615-
///////////////////////////////////////////////////////////////////////////////
616-
/// @brief Extension properties.
617-
typedef struct ur_extension_properties_t {
618-
ur_structure_type_t stype; ///< [in] type of this structure, must be
619-
///< ::UR_STRUCTURE_TYPE_EXTENSION_PROPERTIES
620-
void *pNext; ///< [in,out][optional] pointer to extension-specific structure
621-
char name[UR_MAX_EXTENSION_NAME_LENGTH]; ///< [in] null-terminated extension name.
622-
uint32_t version; ///< [in] version of the extension using ::UR_MAKE_VERSION.
623-
624-
} ur_extension_properties_t;
625-
626-
///////////////////////////////////////////////////////////////////////////////
627-
/// @brief Retrieve the set of supported extensions.
628-
///
629-
/// @returns
630-
/// - ::UR_RESULT_SUCCESS
631-
/// - ::UR_RESULT_ERROR_UNINITIALIZED
632-
/// - ::UR_RESULT_ERROR_DEVICE_LOST
633-
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
634-
/// + `NULL == hPlatform`
635-
UR_APIEXPORT ur_result_t UR_APICALL
636-
urPlatformGetExtensionProperties(
637-
ur_platform_handle_t hPlatform, ///< [in] handle to the platform.
638-
uint32_t count, ///< [in] number of extension properties to fetch.
639-
ur_extension_properties_t *pExtensionProperties, ///< [out][optional] array of supported extension.
640-
uint32_t *pCountRet ///< [out][optional] will be updated with the total count of supported
641-
///< extensions.
642-
);
643-
644624
#if !defined(__GNUC__)
645625
#pragma endregion
646626
#endif
@@ -5706,17 +5686,6 @@ typedef struct ur_platform_get_backend_option_params_t {
57065686
const char ***pppPlatformOption;
57075687
} ur_platform_get_backend_option_params_t;
57085688

5709-
///////////////////////////////////////////////////////////////////////////////
5710-
/// @brief Function parameters for urPlatformGetExtensionProperties
5711-
/// @details Each entry is a pointer to the parameter passed to the function;
5712-
/// allowing the callback the ability to modify the parameter's value
5713-
typedef struct ur_platform_get_extension_properties_params_t {
5714-
ur_platform_handle_t *phPlatform;
5715-
uint32_t *pcount;
5716-
ur_extension_properties_t **ppExtensionProperties;
5717-
uint32_t **ppCountRet;
5718-
} ur_platform_get_extension_properties_params_t;
5719-
57205689
///////////////////////////////////////////////////////////////////////////////
57215690
/// @brief Function parameters for urContextCreate
57225691
/// @details Each entry is a pointer to the parameter passed to the function;

include/ur_ddi.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ typedef ur_result_t(UR_APICALL *ur_pfnPlatformGetBackendOption_t)(
6060
const char *,
6161
const char **);
6262

63-
///////////////////////////////////////////////////////////////////////////////
64-
/// @brief Function-pointer for urPlatformGetExtensionProperties
65-
typedef ur_result_t(UR_APICALL *ur_pfnPlatformGetExtensionProperties_t)(
66-
ur_platform_handle_t,
67-
uint32_t,
68-
ur_extension_properties_t *,
69-
uint32_t *);
70-
7163
///////////////////////////////////////////////////////////////////////////////
7264
/// @brief Table of Platform functions pointers
7365
typedef struct ur_platform_dditable_t {
@@ -77,7 +69,6 @@ typedef struct ur_platform_dditable_t {
7769
ur_pfnPlatformCreateWithNativeHandle_t pfnCreateWithNativeHandle;
7870
ur_pfnPlatformGetApiVersion_t pfnGetApiVersion;
7971
ur_pfnPlatformGetBackendOption_t pfnGetBackendOption;
80-
ur_pfnPlatformGetExtensionProperties_t pfnGetExtensionProperties;
8172
} ur_platform_dditable_t;
8273

8374
///////////////////////////////////////////////////////////////////////////////

scripts/core/EXT.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
X=x.upper()
55
%>
66
==============
7-
Extensions
7+
Extensions
88
==============
99

1010
Objective
@@ -87,5 +87,22 @@ the implementation will ignore extended structures that it does not support.
8787

8888
The extension must document the specific structures and functions that may be extended using the structure chain.
8989

90+
Adding an extension
91+
===================
9092

91-
// TODO - list all extensions
93+
* Extend the specification with the functions, enumerations, macros, and structures required by the extension, ensuring that
94+
all additions fully comply with the naming and ABI requirements detailed above.
95+
96+
* Document the extension in `EXT_<ext-name>.rst` file based on the `EXT_Template.rst`, ensuring it is added to the list of
97+
extensions below.
98+
99+
* The extension will only be accepted if all conditions are met and its addition is agreed upon by the Working Group.
100+
101+
102+
List of Standard Extensions
103+
===========================
104+
// TODO - list all standard extensions
105+
106+
List of Experimental Extensions
107+
===============================
108+
// TODO - list all experimental extensions

scripts/core/EXT_Template.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<%
2+
import re
3+
from templates import helper as th
4+
%><%
5+
OneApi=tags['$OneApi']
6+
x=tags['$x']
7+
X=x.upper()
8+
%>
9+
:orphan:
10+
11+
==================================
12+
Unified Runtime Extension Template
13+
==================================
14+
15+
API
16+
---
17+
18+
* Enumerations
19+
20+
21+
* List all enumerations defined by the extension.
22+
23+
24+
* Structures
25+
26+
27+
* List all structures defined by the extension.
28+
* ...
29+
30+
31+
* Functions
32+
33+
34+
* List all functions defined by the extension.
35+
* ...
36+
37+
38+
Unified Runtime Extension Template
39+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40+
41+
In this section describe in detail the purpose of the extension, along with its
42+
valid usage.

scripts/core/platform.yml

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ type: header
1010
desc: "Intel $OneApi Unified Runtime APIs for Platform"
1111
ordinal: "1"
1212
--- #--------------------------------------------------------------------------
13+
type: macro
14+
desc: "Extension name maximum length."
15+
name: $X_MAX_EXTENSION_NAME_LENGTH
16+
value: "256"
17+
--- #--------------------------------------------------------------------------
18+
type: struct
19+
desc: "Extension type."
20+
name: $x_platform_extension_t
21+
class: $xPlatform
22+
members:
23+
- type: char
24+
name: name[$X_MAX_EXTENSION_NAME_LENGTH]
25+
desc: "[in] null-terminated extension name."
26+
- type: uint32_t
27+
name: version
28+
desc: "[in] version of the extension using $X_MAKE_VERSION."
29+
--- #--------------------------------------------------------------------------
1330
type: function
1431
desc: "Retrieves all available platforms"
1532
class: $xPlatform
@@ -57,7 +74,9 @@ etors:
5774
desc: "[char[]] The string denoting the version of the platform. The size of the info needs to be dynamically queried."
5875
- name: EXTENSIONS
5976
value: "4"
60-
desc: "[char[]] The string denoting extensions supported by the platform. The size of the info needs to be dynamically queried."
77+
desc: |
78+
[$x_platform_extension_t[]] an array of $x_platform_extension_t which express which extensions supported by the platform.
79+
The size of the info needs to be dynamically queried.
6180
todo: "document extensions names and their meaning"
6281
- name: PROFILE
6382
value: "5"
@@ -242,40 +261,3 @@ etors:
242261
- name: HIP
243262
value: "4"
244263
desc: "The backend is HIP"
245-
--- #--------------------------------------------------------------------------
246-
type: macro
247-
desc: "Extension name maximum length."
248-
name: $X_MAX_EXTENSION_NAME_LENGTH
249-
value: "256"
250-
--- #--------------------------------------------------------------------------
251-
type: struct
252-
desc: "Extension properties."
253-
name: $x_extension_properties_t
254-
base: $x_base_properties_t
255-
class: $xPlatform
256-
members:
257-
- type: char
258-
name: name[$X_MAX_EXTENSION_NAME_LENGTH]
259-
desc: "[in] null-terminated extension name."
260-
- type: uint32_t
261-
name: version
262-
desc: "[in] version of the extension using $X_MAKE_VERSION."
263-
--- #--------------------------------------------------------------------------
264-
type: function
265-
desc: "Retrieve the set of supported extensions."
266-
class: $xPlatform
267-
name: GetExtensionProperties
268-
decl: static
269-
params:
270-
- type: $x_platform_handle_t
271-
name: hPlatform
272-
desc: "[in] handle to the platform."
273-
- type: uint32_t
274-
name: count
275-
desc: "[in] number of extension properties to fetch."
276-
- type: $x_extension_properties_t*
277-
name: pExtensionProperties
278-
desc: "[out][optional] array of supported extension."
279-
- type: uint32_t*
280-
name: pCountRet
281-
desc: "[out][optional] will be updated with the total count of supported extensions."

source/adapters/null/ur_nullddi.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -218,32 +218,6 @@ __urdlllocal ur_result_t UR_APICALL urGetLastResult(
218218
return result;
219219
}
220220

221-
///////////////////////////////////////////////////////////////////////////////
222-
/// @brief Intercept function for urPlatformGetExtensionProperties
223-
__urdlllocal ur_result_t UR_APICALL urPlatformGetExtensionProperties(
224-
ur_platform_handle_t hPlatform, ///< [in] handle to the platform.
225-
uint32_t count, ///< [in] number of extension properties to fetch.
226-
ur_extension_properties_t *
227-
pExtensionProperties, ///< [out][optional] array of supported extension.
228-
uint32_t *
229-
pCountRet ///< [out][optional] will be updated with the total count of supported
230-
///< extensions.
231-
) {
232-
ur_result_t result = UR_RESULT_SUCCESS;
233-
234-
// if the driver has created a custom function, then call it instead of using the generic path
235-
auto pfnGetExtensionProperties =
236-
d_context.urDdiTable.Platform.pfnGetExtensionProperties;
237-
if (nullptr != pfnGetExtensionProperties) {
238-
result = pfnGetExtensionProperties(hPlatform, count,
239-
pExtensionProperties, pCountRet);
240-
} else {
241-
// generic implementation
242-
}
243-
244-
return result;
245-
}
246-
247221
///////////////////////////////////////////////////////////////////////////////
248222
/// @brief Intercept function for urDeviceGet
249223
__urdlllocal ur_result_t UR_APICALL urDeviceGet(
@@ -3466,9 +3440,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable(
34663440

34673441
pDdiTable->pfnGetBackendOption = driver::urPlatformGetBackendOption;
34683442

3469-
pDdiTable->pfnGetExtensionProperties =
3470-
driver::urPlatformGetExtensionProperties;
3471-
34723443
return result;
34733444
}
34743445

0 commit comments

Comments
 (0)