Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,11 @@ if(UR_FORMAT_CPP_STYLE)
else()
message(WARNING "UR_FORMAT_CPP_STYLE not set. Targets: 'generate' and 'check-generated' and not available")
endif()


add_custom_target(sphinx-autobuild
COMMAND sphinx-autobuild -b html
${PROJECT_SOURCE_DIR}/docs/source ${PROJECT_SOURCE_DIR}/docs
DEPENDS generate
USES_TERMINAL
)
31 changes: 29 additions & 2 deletions include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,18 @@ def __str__(self):
return hex(self.value)


###############################################################################
## @brief Extension name maximum length.
UR_MAX_EXTENSION_NAME_LENGTH = 256

###############################################################################
## @brief Extension type.
class ur_platform_extension_t(Structure):
_fields_ = [
("name", c_char_p), ## [in] null-terminated extension name.
("version", c_ulong) ## [in] version of the extension using ::UR_MAKE_VERSION.
]

###############################################################################
## @brief Supported platform info
class ur_platform_info_v(IntEnum):
Expand All @@ -282,8 +294,9 @@ class ur_platform_info_v(IntEnum):
## size of the info needs to be dynamically queried.
VERSION = 3 ## [char[]] The string denoting the version of the platform. The size of
## the info needs to be dynamically queried.
EXTENSIONS = 4 ## [char[]] The string denoting extensions supported by the platform. The
## size of the info needs to be dynamically queried.
EXTENSIONS = 4 ## [::ur_platform_extension_t[]] an array of ::ur_platform_extension_t
## which express which extensions supported by the platform.
## The size of the info needs to be dynamically queried.
PROFILE = 5 ## [char[]] The string denoting profile of the platform. The size of the
## info needs to be dynamically queried.
BACKEND = 6 ## [::ur_platform_backend_t] The backend of the platform. Identifies the
Expand Down Expand Up @@ -688,6 +701,10 @@ def __str__(self):
return hex(self.value)


###############################################################################
## @brief Opaque Data extension.
UR_OPAQUE_DATA_EXT_NAME = "ur_ext_opaque_data"

###############################################################################
## @brief Context property type
class ur_context_flags_v(IntEnum):
Expand Down Expand Up @@ -1632,6 +1649,7 @@ class ur_function_v(IntEnum):
MEM_RELEASE = 66 ## Enumerator for ::urMemRelease
MEM_BUFFER_PARTITION = 67 ## Enumerator for ::urMemBufferPartition
MEM_GET_NATIVE_HANDLE = 68 ## Enumerator for ::urMemGetNativeHandle
PLATFORM_GET_OPAQUE_DATA_EXT = 69 ## Enumerator for ::urPlatformGetOpaqueDataExt
MEM_GET_INFO = 70 ## Enumerator for ::urMemGetInfo
MEM_IMAGE_GET_INFO = 71 ## Enumerator for ::urMemImageGetInfo
PLATFORM_GET = 72 ## Enumerator for ::urPlatformGet
Expand Down Expand Up @@ -1738,6 +1756,13 @@ def __str__(self):
else:
_urPlatformCreateWithNativeHandle_t = CFUNCTYPE( ur_result_t, ur_native_handle_t, POINTER(ur_platform_handle_t) )

###############################################################################
## @brief Function-pointer for urPlatformGetOpaqueDataExt
if __use_win_types:
_urPlatformGetOpaqueDataExt_t = WINFUNCTYPE( ur_result_t, c_void_p, POINTER(c_void_p) )
else:
_urPlatformGetOpaqueDataExt_t = CFUNCTYPE( ur_result_t, c_void_p, POINTER(c_void_p) )

###############################################################################
## @brief Function-pointer for urPlatformGetApiVersion
if __use_win_types:
Expand All @@ -1761,6 +1786,7 @@ class ur_platform_dditable_t(Structure):
("pfnGetInfo", c_void_p), ## _urPlatformGetInfo_t
("pfnGetNativeHandle", c_void_p), ## _urPlatformGetNativeHandle_t
("pfnCreateWithNativeHandle", c_void_p), ## _urPlatformCreateWithNativeHandle_t
("pfnGetOpaqueDataExt", c_void_p), ## _urPlatformGetOpaqueDataExt_t
("pfnGetApiVersion", c_void_p), ## _urPlatformGetApiVersion_t
("pfnGetBackendOption", c_void_p) ## _urPlatformGetBackendOption_t
]
Expand Down Expand Up @@ -2759,6 +2785,7 @@ def __init__(self, version : ur_api_version_t):
self.urPlatformGetInfo = _urPlatformGetInfo_t(self.__dditable.Platform.pfnGetInfo)
self.urPlatformGetNativeHandle = _urPlatformGetNativeHandle_t(self.__dditable.Platform.pfnGetNativeHandle)
self.urPlatformCreateWithNativeHandle = _urPlatformCreateWithNativeHandle_t(self.__dditable.Platform.pfnCreateWithNativeHandle)
self.urPlatformGetOpaqueDataExt = _urPlatformGetOpaqueDataExt_t(self.__dditable.Platform.pfnGetOpaqueDataExt)
self.urPlatformGetApiVersion = _urPlatformGetApiVersion_t(self.__dditable.Platform.pfnGetApiVersion)
self.urPlatformGetBackendOption = _urPlatformGetBackendOption_t(self.__dditable.Platform.pfnGetBackendOption)

Expand Down
61 changes: 59 additions & 2 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,20 @@ urTearDown(
#if !defined(__GNUC__)
#pragma region platform
#endif
///////////////////////////////////////////////////////////////////////////////
#ifndef UR_MAX_EXTENSION_NAME_LENGTH
/// @brief Extension name maximum length.
#define UR_MAX_EXTENSION_NAME_LENGTH 256
#endif // UR_MAX_EXTENSION_NAME_LENGTH

///////////////////////////////////////////////////////////////////////////////
/// @brief Extension type.
typedef struct ur_platform_extension_t {
char *name; ///< [in] null-terminated extension name.
uint32_t version; ///< [in] version of the extension using ::UR_MAKE_VERSION.

} ur_platform_extension_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Retrieves all available platforms
///
Expand Down Expand Up @@ -398,8 +412,9 @@ typedef enum ur_platform_info_t {
///< size of the info needs to be dynamically queried.
UR_PLATFORM_INFO_VERSION = 3, ///< [char[]] The string denoting the version of the platform. The size of
///< the info needs to be dynamically queried.
UR_PLATFORM_INFO_EXTENSIONS = 4, ///< [char[]] The string denoting extensions supported by the platform. The
///< size of the info needs to be dynamically queried.
UR_PLATFORM_INFO_EXTENSIONS = 4, ///< [::ur_platform_extension_t[]] an array of ::ur_platform_extension_t
///< which express which extensions supported by the platform.
///< The size of the info needs to be dynamically queried.
UR_PLATFORM_INFO_PROFILE = 5, ///< [char[]] The string denoting profile of the platform. The size of the
///< info needs to be dynamically queried.
UR_PLATFORM_INFO_BACKEND = 6, ///< [::ur_platform_backend_t] The backend of the platform. Identifies the
Expand Down Expand Up @@ -1288,6 +1303,38 @@ typedef enum ur_device_usm_access_capability_flag_t {
/// @brief Bit Mask for validating ur_device_usm_access_capability_flags_t
#define UR_DEVICE_USM_ACCESS_CAPABILITY_FLAGS_MASK 0xfffffff0

#if !defined(__GNUC__)
#pragma endregion
#endif
// Intel 'oneAPI' Unified Runtime APIs for Platform
#if !defined(__GNUC__)
#pragma region opaque_data
#endif
///////////////////////////////////////////////////////////////////////////////
#ifndef UR_OPAQUE_DATA_EXT_NAME
/// @brief Opaque Data extension.
#define UR_OPAQUE_DATA_EXT_NAME "ur_ext_opaque_data"
#endif // UR_OPAQUE_DATA_EXT_NAME

///////////////////////////////////////////////////////////////////////////////
/// @brief Get Opaque data from the platform.
///
/// @details
/// Some details.
///
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_UNINITIALIZED
/// - ::UR_RESULT_ERROR_DEVICE_LOST
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == pOpaqueDataParam`
/// + `NULL == ppOpaqueDataReturn`
UR_APIEXPORT ur_result_t UR_APICALL
urPlatformGetOpaqueDataExt(
void *pOpaqueDataParam, ///< [in] unspecified argument, interpretation is specific per adapter.
void **ppOpaqueDataReturn ///< [out] placeholder for the returned opaque data.
);

#if !defined(__GNUC__)
#pragma endregion
#endif
Expand Down Expand Up @@ -4442,6 +4489,7 @@ typedef enum ur_function_t {
UR_FUNCTION_MEM_RELEASE = 66, ///< Enumerator for ::urMemRelease
UR_FUNCTION_MEM_BUFFER_PARTITION = 67, ///< Enumerator for ::urMemBufferPartition
UR_FUNCTION_MEM_GET_NATIVE_HANDLE = 68, ///< Enumerator for ::urMemGetNativeHandle
UR_FUNCTION_PLATFORM_GET_OPAQUE_DATA_EXT = 69, ///< Enumerator for ::urPlatformGetOpaqueDataExt
UR_FUNCTION_MEM_GET_INFO = 70, ///< Enumerator for ::urMemGetInfo
UR_FUNCTION_MEM_IMAGE_GET_INFO = 71, ///< Enumerator for ::urMemImageGetInfo
UR_FUNCTION_PLATFORM_GET = 72, ///< Enumerator for ::urPlatformGet
Expand Down Expand Up @@ -5652,6 +5700,15 @@ typedef struct ur_platform_create_with_native_handle_params_t {
ur_platform_handle_t **pphPlatform;
} ur_platform_create_with_native_handle_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urPlatformGetOpaqueDataExt
/// @details Each entry is a pointer to the parameter passed to the function;
/// allowing the callback the ability to modify the parameter's value
typedef struct ur_platform_get_opaque_data_ext_params_t {
void **ppOpaqueDataParam;
void ***pppOpaqueDataReturn;
} ur_platform_get_opaque_data_ext_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urPlatformGetApiVersion
/// @details Each entry is a pointer to the parameter passed to the function;
Expand Down
7 changes: 7 additions & 0 deletions include/ur_ddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ typedef ur_result_t(UR_APICALL *ur_pfnPlatformCreateWithNativeHandle_t)(
ur_native_handle_t,
ur_platform_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urPlatformGetOpaqueDataExt
typedef ur_result_t(UR_APICALL *ur_pfnPlatformGetOpaqueDataExt_t)(
void *,
void **);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urPlatformGetApiVersion
typedef ur_result_t(UR_APICALL *ur_pfnPlatformGetApiVersion_t)(
Expand All @@ -67,6 +73,7 @@ typedef struct ur_platform_dditable_t {
ur_pfnPlatformGetInfo_t pfnGetInfo;
ur_pfnPlatformGetNativeHandle_t pfnGetNativeHandle;
ur_pfnPlatformCreateWithNativeHandle_t pfnCreateWithNativeHandle;
ur_pfnPlatformGetOpaqueDataExt_t pfnGetOpaqueDataExt;
ur_pfnPlatformGetApiVersion_t pfnGetApiVersion;
ur_pfnPlatformGetBackendOption_t pfnGetBackendOption;
} ur_platform_dditable_t;
Expand Down
117 changes: 117 additions & 0 deletions scripts/core/EXT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<%
import re
from templates import helper as th
%><%
OneApi=tags['$OneApi']
x=tags['$x']
X=x.upper()
%>
==============
Extensions
==============

Objective
=========

Extensions allow for additional functionality to be added to the Unified Runtime specification
without affecting the core specification. Extensions may in future be promoted to the core specification
in a later version of Unified Runtime, when agreed upon by the Working Group. All extensions are
optional and are not required to be implemented by any particular adapter, but are expected to
be widely available and possibly be required in a future version of the specification. Adapters
must report which extensions are supported through the ${X}_PLATFORM_INFO_EXTENSIONS platform info query.
Each extension may also impose additional restrictions on when it can be used - i.e. a platform
or device query.

There are two types of extensions defined by this specification:

1. **Standard** - extension will be included into the current and all future version of the specification.
2. **Experimental** - extensions require additional experimentation and development, before becoming a standard extension.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be implementation or coverage requirements for when an extension should move from experimental to standard?

Applications should not rely on experimental extensions in production.

Requirements
============

- Extensions must use globally unique names for macros, enums, structures and functions
- Extensions must have globally unique extension names reported from ${X}_PLATFORM_INFO_EXTENSIONS platform info query
- All extensions must be defined in this specification
- Extensions must not break backwards compatibility of the core APIs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also include semantic breaks as well as interface breaks in the core APIs, i.e. does this forbid an extension from altering the behavior of an existing API?

Copy link
Contributor Author

@veselypeta veselypeta May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an extension can alter the behavour of an existing API. For example you might want to chain an additional structure to the input or use extension specific enums, but default usage should remain the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure I'm so confortable with extensions that change semantics because we have no way to opt-out with this architecture. If we were able to enable extensions, like Vulkan, maybe I'd be more conformtable with that.

- Standard extension versions must be backwards compatible with prior versions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this from L0 extension scheme, but perhaps we could use semantic versioning with extensions with major/minor versions?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that experimental extensions are permitted to break backwards compatibility?

Copy link
Contributor Author

@veselypeta veselypeta May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think that makes sense. Experimental extensions should have no ABI or backwards compatibility requirements.



Naming Convention
-----------------

The following naming conventions must be followed for **standard** extensions:
## --validate=off
- The extension name must begin with `${x}_ext`
- All extension functions must be postfixed with `Ext`
- All macros must use all caps `${X}_<NAME>_EXT` convention
- All structures, enumerations and other types must follow `${x}_<name>_ext_t` snake case convention
- All enumerator values must use all caps `${X}_ENUM_EXT_ETOR_NAME` convention
- All handle types must end with `ext_handle_t`
- All descriptor structures must end with `ext_desc_t`
- All property structures must end with `ext_properties_t`
- All flag enumerations must end with `ext_flags_t`
## --validate=on

The following naming conventions must be followed for **experimental** extensions:

## --validate=off
- The extension name must begin with `${x}_exp`
- Experimental extensions may be added and removed from the driver at any time.
- Experimental extensions are not guaranteed to be forward- or backward-compatible between versions.
- Experimental extensions are not guaranteed to be supported in production driver releases; and may appear and disappear from release to release.
- All extension functions must be postfixed with `Exp`
- All macros must use all caps `${X}_<NAME>_EXP` convention
- All structures, enumerations and other types must follow `${x}_<name>_exp_t` snake case convention
- All enumerator values must use all caps `${X}_ENUM_EXP_ETOR_NAME` convention
- All handle types must end with `exp_handle_t`
- All descriptor structures must end with `exp_desc_t`
- All property structures must end with `exp_properties_t`
- All flag enumerations must end with `exp_flags_t`
## --validate=on

Extending Enumerations
----------------------

Any existing enumeration may be extended by adding new enumerators. Enumerators must use the extensions naming
convention and values should be assigned to avoid future compatibility issues.


Extending Structures
--------------------

Any structure derived from ``${x}_base_desc_t`` or ``${x}_base_properties_t`` can be extended using a structure chain
by adding a pointer to the extended structure in `pNext` member variable. No other method of extending structures is allowed.

A structure chain can contain more than one extension structure, in any order. Therefore, extensions should not
be dependent on their order relative to other extensions and the implementation must be order agnostic. In addition,
the implementation will ignore extended structures that it does not support.

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

Adding an extension
===================

* Extend the specification with the functions, enumerations, macros, and structures required by the extension, ensuring that
all additions fully comply with the naming and ABI requirements detailed above.

* Document the extension in `EXT_<ext-name>.rst` file based on the `EXT_Template.rst`, ensuring it is added to the list of
extensions below.

* The extension will only be accepted if all conditions are met and its addition is agreed upon by the Working Group.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this refer to an extension becoming a standard extension?



List of Standard Extensions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought, maybe these lists should also track the implementation status of the extensions, so whether they are implemented, and then which version of UR supports which version of the extension, particularly for the experimental extensions which may change, so high-level languages know what they can use when updating the UR interface.

===========================
%for name in meta['macro']:
%if name.endswith('EXT_NAME'):

- :ref:`${th.subt(namesapce, tags, meta['macro'][name]['values'][0])} <${th.subt(namesapce, tags, name)}>`

%endif
%endfor

List of Experimental Extensions
===============================
// TODO - list all experimental extensions
58 changes: 58 additions & 0 deletions scripts/core/EXT_OpaqueData.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<%
import re
from templates import helper as th
%><%
OneApi=tags['$OneApi']
x=tags['$x']
X=x.upper()
%>
:orphan:

.. _${X}_OPAQUE_DATA_EXT_NAME:

=====================
Opaque Data Extension
=====================

API
---

* Macros

* ${X}_OPAQUE_DATA_EXT_NAME


* Functions

* ${x}PlatformGetOpaqueDataExt


Opaque Data Extension
~~~~~~~~~~~~~~~~~~~~~

Some devices whose device code is compiled by the host compiler (e.g. CPU emulators) may use
this extension to access some device code functionality implemented in/behind the adapter.

Dependencies
~~~~~~~~~~~~

This extension has no dependencies and relies of v0.6 of the Unified Runtime specification.

Extension Changelog
~~~~~~~~~~~~~~~~~~~

v0.1
====
Document changes ...

v0.2
====
Document changes ...


Contributors
~~~~~~~~~~~~

* Contributor A, Company A, [email protected]
* Contributor B, Company B, [email protected]
* ...
Loading