Skip to content

Commit 8ab1e3e

Browse files
authored
Merge pull request #546 from kbenzie/benie/experimental-features
[ur] Add experimental feature contribution docs
2 parents 218db5d + 8571ebe commit 8ab1e3e

File tree

4 files changed

+205
-56
lines changed

4 files changed

+205
-56
lines changed

scripts/core/CONTRIB.rst

Lines changed: 178 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,205 @@
1-
21
<%
32
OneApi=tags['$OneApi']
43
x=tags['$x']
54
X=x.upper()
65
%>
7-
===================
6+
====================
87
Contribution Guide
9-
===================
8+
====================
109

11-
This contribution guide explains how to contribute to the Unified Runtime
12-
project and what processes you must follow in order to have your changes
10+
This contribution guide explains how to contribute to the Unified Runtime
11+
project and what processes you *must* follow in order to have your changes
1312
accepted into the project.
1413

14+
.. important::
15+
16+
Before making a contribution you *should* determine if the change should be
17+
made directly to the core specification or introduced as an experimental
18+
feature. The criteria we use to make this distinction are as follows:
19+
20+
* The feature exists to enable an experimental feature in a parallel
21+
language runtime being built on top of Unified Runtime.
22+
23+
* The design phase of the feature is expected to span multiple oneAPI
24+
releases.
25+
26+
* A proof of concept implementation exists for a single adapter but
27+
multiple adapters are intended to be supported. It is important to
28+
consider as early as possible whether the feature is appropriate for
29+
other adapters to evaluate its portability.
1530

16-
Updating the Specification
17-
==========================
31+
If the feature in question matches any of these criteria, please refer to
32+
the `Experimental Features`_ section, otherwise refer to the `Core
33+
Features`_ section. If you are unsure how to proceed please `create an
34+
issue <https://github.com/oneapi-src/unified-runtime/issues/new>`_ asking
35+
for clarification.
1836

19-
The specification and many other components of Unified Runtime are generated
20-
from a set of ``*.yml`` files located in the ``scripts/core/`` directory of the
21-
project. To make a change to the specification you should modify only ``*.yml``
22-
files in this directory. To see the changes reflected in the specification you
23-
`must` build the ``generate`` target. When making changes to the specification
24-
you should commit all changes generated by the script as part of your change.
25-
Refer to ``scripts/YaML.md`` on the yaml syntax as well as detailed descriptions
26-
of required fields for each type of entity.
37+
If you are unsure whether a feature can be supported by certain adapters
38+
please seek the advice of an appropriate stakeholder or ask the Unified
39+
Runtime team via the `GitHub issue tracker
40+
<https://github.com/oneapi-src/unified-runtime/issues/new>`_.
2741

28-
Naming Conventions
29-
~~~~~~~~~~~~~~~~~~
42+
Generating Source
43+
=================
3044

31-
Additional to what is described in the Yaml syntax document. You should follow
32-
the following naming convention for argument names.
45+
The specification and many other components in the Unified Runtime repository
46+
are generated from a set of YAML_ files which are used as inputs to a Mako_
47+
based templating system. The YAML file syntax is defined in `YAML syntax`_. To
48+
generate the outputs of the Mako templates a build directory must be
49+
configured, instructions are available in the `README
50+
<https://github.com/oneapi-src/unified-runtime/blob/main/README.md>`_ file.
51+
Upon successfully configuring a build directory, generate the outputs with the
52+
following command (or suitable build system equivalent):
3353

34-
* Entry-Points use ``camelCase`` conventions i.e ``${x}DeviceGet``.
54+
.. code-block:: console
3555
36-
* Argument names are also `camelCase` and are prefixed with a type
37-
indicator:
56+
$ cmake --build build --target generate
3857
39-
* Pointer arguments are prefixed with ``p`` or ``pp`` for double pointer
40-
i.e. ``pEvent``.
58+
.. _YAML: https://yaml.org/
59+
.. _Mako: https://www.makotemplates.org/
60+
.. _YAML syntax:
61+
https://github.com/oneapi-src/unified-runtime/blob/main/scripts/YaML.md
4162

42-
* Handle arguments are prefixed with ``h`` i.e. ``hQueue``.
63+
Writing YAML
64+
============
4365

66+
Please read the :ref:`core/INTRO:Naming Convention` section prior to making a
67+
contribution and refer to the `YAML syntax`_ for specifics of how to define the
68+
required constructs.
4469

70+
When writing ``*.yml`` files and ``ur`` or ``UR`` should exist in the output
71+
use ``$${'x'}`` or ``$${'X'}`` respectively. These will be replaced while
72+
`Generating Source`_.
4573

74+
Additionally, the following conventions *must* be followed for function
75+
arguments:
76+
77+
* Argument names are ``camelCase``.
78+
* Arguments with pointer types are prefixed with ``p`` for each pointer in
79+
the type i.e. ``char *pMessage``, ``char **ppMessage``, etc.
80+
* Handle arguments are prefixed with ``h`` i.e. ``hQueue``.
81+
* Pointer to handle arguments, such as out parameters, are prefixed with
82+
``ph`` i.e. ``phQueue``.
4683

4784
Forks and Pull Requests
4885
=======================
4986

50-
To submit a pull request to Unified Runtime, you must first create your own
51-
personal fork of the project and submit your changes to a branch. By convention
52-
we name our branches ``<your_name>/<short_description>``, where the description
53-
indicates the intent of your change. You can then raise a pull request targeting
54-
``oneapi-src/unified-runtime:main``.
87+
To submit a pull request to Unified Runtime, you must first create your own
88+
personal fork of the project and submit your changes to a branch. By convention
89+
we name our branches ``<your_name>/<short_description>``, where the description
90+
indicates the intent of your change. You can then raise a pull request
91+
targeting ``oneapi-src/unified-runtime:main``.
92+
93+
When making changes to the specification you *must* commit all changes to files
94+
in the repository as a result of `Generating Source`_.
95+
96+
Before your pull request is merged it *must* pass all jobs in the GitHub
97+
Actions workflow and *must* be reviewed by no less than two code owners.
98+
99+
.. hint::
100+
101+
When rebasing a branch on top of ``main`` results in merged conflicts it is
102+
recommended to resolve conflicts in the ``*.yml`` files then `Generating
103+
Source`_. This will automatically resolve conflicts in the generated source
104+
files, leaving only conflicts in non-generated source files to be resolved,
105+
if any.
106+
107+
Core Features
108+
=============
109+
110+
A core feature *must* have a stable API/ABI and *should* strive to be supported
111+
across all adapters. However, core features *may* be optional and thus only
112+
supported in one or more adapters. A core feature *should* also strive to
113+
enable similar functionality in parallel language runtimes (such as SYCL,
114+
OpenMP, ...) where possible although this is a secondary concern.
115+
116+
.. hint::
117+
118+
Optional features should be avoided as much as possible to maximize
119+
portability across adapters and reduce the overhead required to make use of
120+
features in parallel language runtimes.
121+
122+
Core features are defined in the ``*.yml`` files in the `scripts/core
123+
<https://github.com/oneapi-src/unified-runtime/tree/main/scripts/core>`_
124+
directory. Most of the files are named after the API object who's interface is
125+
defined within them, with the following exceptions:
126+
127+
* `scripts/core/common.yml`_ defines symbols which are used by multiple
128+
interfaces through the specification, e.g. macros, object handles, result
129+
enumerations, and structure type enumerations.
130+
* `scripts/core/enqueue.yml`_ defines commands which can be enqueued on a
131+
queue object.
132+
* `scripts/core/runtime.yml`_ defines global symbols pertaining to
133+
initialization and tear down of the entire runtime.
134+
* `scripts/core/registry.yml`_ contains an enumeration of all entry-points,
135+
past and present, for use in the XPTI tracing framework. It is
136+
automatically updated so shouldn't require manual editing.
137+
* ``scripts/core/exp-<feature>.yml`` see `Experimental Features`_.
138+
139+
.. _scripts/core/common.yml:
140+
https://github.com/oneapi-src/unified-runtime/blob/main/scripts/core/common.yml
141+
.. _scripts/core/enqueue.yml:
142+
https://github.com/oneapi-src/unified-runtime/blob/main/scripts/core/enqueue.yml
143+
.. _scripts/core/runtime.yml:
144+
https://github.com/oneapi-src/unified-runtime/blob/main/scripts/core/runtime.yml
145+
.. _scripts/core/registry.yml:
146+
https://github.com/oneapi-src/unified-runtime/blob/main/scripts/core/registry.yml
147+
148+
Core Optional Features
149+
----------------------
150+
151+
Optional core features *must* be supported in at least one adapter. Support for
152+
an optional core feature *must* be programmatically exposed to the user via
153+
boolean query call to ${x}DeviceGetInfo and a new enumerator of the form
154+
``UR_DEVICE_INFO_<FEATURE_NAME>_SUPPORT`` in ${x}_device_info_t.
155+
156+
Conformance Testing
157+
-------------------
55158

56-
Before your pull request is merged it `must` be reviewed by no less than two
57-
code owners of the project `and` be passing all required CI jobs.
159+
For contributions to the core specification conformance tests *should* be
160+
included as part of your change. The conformance tests can be found
161+
under ``test/conformance/<component>``, where component refers to the API
162+
object an entry-point belongs to i.e. platform, enqueue, device.
58163

164+
The conformance tests *should* ideally include end-to-end testing of all the
165+
changes to the specification if possible. At minimum, they *must* cover at
166+
least one test for each of the possible error codes returned, excluding any
167+
disaster cases like ${X}_RESULT_ERROR_OUT_OF_HOST_MEMORY or similar.
59168

60-
Conformance Testing
61-
===================
62-
63-
For contributions to the specification you should include appropriate
64-
conformance tests as part of your change. The conformance tests can be found
65-
under ``test/conformance/<component>``, where component refers to a set of
66-
entry-points i.e. platform, enqueue, device. The conformance tests, at a
67-
minimum, should cover at least one test for each of the possible error codes
68-
returned, excluding any disaster cases like
69-
``${X}_RESULT_ERROR_OUT_OF_HOST_MEMORY`` or similar. Conformance tests should not
70-
assume anything about the underlying adapter on which they are run against and
71-
should pass on any conformant adapter.
169+
Conformance tests *must* not make assumptions about the adapter under test.
170+
Tests fixtures or cases *must* query for support of optional features and skip
171+
testing if unsupported by the adapter.
172+
173+
Experimental Features
174+
=====================
175+
176+
.. warning::
177+
178+
Experimental features:
179+
180+
* May be replaced, updated, or removed at any time.
181+
* Do not require maintaining API/ABI stability of their own additions
182+
over time.
183+
* Do not require conformance testing of their own additions.
184+
185+
Experimental features *must* be defined in two new files, where
186+
``<FEATURE>``/``<feature>`` are replaced with an appropriate name:
187+
188+
* ``scripts/core/EXP-<FEATURE>.rst`` document specifying the experimental
189+
feature in natural language.
190+
* ``scripts/core/exp-<feature>.yml`` defines the interface as an input to
191+
`Generating Source`_.
192+
193+
Naming Convention
194+
-----------------
195+
196+
In addition to the requirements referred to in the `Writing YAML`_ section, and
197+
to easily differentiate experimental feature symbols, the following conventions
198+
*must* be adhered to when defining experimental features:
199+
200+
## --validate=off
201+
* All functions must use camel case ``${x}ObjectActionExp`` convention.
202+
* All macros must use all caps ``${X}_NAME_EXP`` convention.
203+
* All structures, enumerations, and other types must follow
204+
``${x}_exp_name_t`` name case convention.
205+
## --validate=on

scripts/core/INTRO.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ Naming Convention
4747
The following naming conventions must be followed:
4848

4949
## --validate=off
50-
- All functions must be prefixed with `${x}`
51-
- All functions must use camel case `${x}ObjectAction` convention
52-
- All macros must use all caps `${X}_NAME` convention
53-
- All structures, enumerations and other types must follow `${x}_name_t` snake case convention
50+
- All functions must be prefixed with ``${x}``
51+
- All functions must use camel case ``${x}ObjectAction`` convention
52+
- All macros must use all caps ``${X}_NAME`` convention
53+
- All structures, enumerations and other types must follow ``${x}_name_t`` snake case convention
5454
- All structure members and function parameters must use camel case convention
55-
- All enumerator values must use all caps `${X}_ENUM_ETOR_NAME` convention
56-
- All handle types must end with `handle_t`
57-
- All descriptor structures must end with `desc_t`
58-
- All property structures must end with `properties_t`
59-
- All flag enumerations must end with `flags_t`
55+
- All enumerator values must use all caps ``${X}_ENUM_ETOR_NAME`` convention
56+
- All handle types must end with ``handle_t``
57+
- All descriptor structures must end with ``desc_t``
58+
- All property structures must end with ``properties_t``
59+
- All flag enumerations must end with ``flags_t``
6060
## --validate=on
6161

6262
The following coding conventions must be followed:
6363

64-
- All descriptor structures must be derived from `${x}_base_desc_t`
65-
- All property structures must be derived from `${x}_base_properties_t`
64+
- All descriptor structures must be derived from ${x}_base_desc_t
65+
- All property structures must be derived from ${x}_base_properties_t
6666
- All function input parameters must precede output parameters
6767
- All functions must return ${x}_result_t
6868

scripts/parse_specs.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ def parse(section, version, tags, meta, ref):
816816
line_nums = _get_line_nums(f)
817817

818818
header = None
819+
name = None
819820
objects = []
820821

821822
for i, d in enumerate(docs):
@@ -833,14 +834,23 @@ def parse(section, version, tags, meta, ref):
833834
header['ordinal'] = int(int(header.get('ordinal',"1000")) * float(header.get('version',"1.0")))
834835
header['ordinal'] *= 1000 if re.match(r"extension", header.get('desc',"").lower()) else 1
835836
header['ordinal'] *= 1000 if re.match(r"experimental", header.get('desc',"").lower()) else 1
837+
basename = os.path.splitext(os.path.basename(f))[0]
838+
if 'name' in header:
839+
name = header['name']
840+
elif basename.startswith('exp-'):
841+
name = f'{basename[len("exp-"):]} (experimental)'
842+
else:
843+
name = basename
844+
for c in '_-':
845+
name = name.replace(c, ' ')
836846
elif header:
837847
# for d in _make_versions(d, float(version)):
838848
objects.append(d)
839849
meta = _generate_meta(d, header['ordinal'], meta)
840850

841851
if header:
842852
specs.append({
843-
'name' : os.path.splitext(os.path.basename(f))[0],
853+
'name' : name,
844854
'header' : header,
845855
'objects' : objects,
846856
})

scripts/templates/conf.py.mako

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ needs_sphinx = '1.8'
4141
# ones.
4242
extensions = [
4343
'sphinx.ext.autodoc',
44+
'sphinx.ext.autosectionlabel',
4445
'sphinx.ext.doctest',
4546
'sphinx.ext.todo',
4647
'sphinx.ext.coverage',
@@ -52,6 +53,10 @@ extensions = [
5253
'breathe'
5354
]
5455

56+
# Configure sphinx.ext.autosectionlabel to require the document prefix when
57+
# cross-referencing document sections.
58+
autosectionlabel_prefix_document = True
59+
5560
# Add any paths that contain templates here, relative to this directory.
5661
templates_path = ['_templates']
5762

0 commit comments

Comments
 (0)