|
1 |
| - |
2 | 1 | <%
|
3 | 2 | OneApi=tags['$OneApi']
|
4 | 3 | x=tags['$x']
|
5 | 4 | X=x.upper()
|
6 | 5 | %>
|
7 |
| -=================== |
| 6 | +==================== |
8 | 7 | Contribution Guide
|
9 |
| -=================== |
| 8 | +==================== |
10 | 9 |
|
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 |
13 | 12 | accepted into the project.
|
14 | 13 |
|
| 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. |
15 | 30 |
|
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. |
18 | 36 |
|
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>`_. |
27 | 41 |
|
28 |
| -Naming Conventions |
29 |
| -~~~~~~~~~~~~~~~~~~ |
| 42 | +Generating Source |
| 43 | +================= |
30 | 44 |
|
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): |
33 | 53 |
|
34 |
| - * Entry-Points use ``camelCase`` conventions i.e ``${x}DeviceGet``. |
| 54 | +.. code-block:: console |
35 | 55 |
|
36 |
| - * Argument names are also `camelCase` and are prefixed with a type |
37 |
| - indicator: |
| 56 | + $ cmake --build build --target generate |
38 | 57 |
|
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 |
41 | 62 |
|
42 |
| - * Handle arguments are prefixed with ``h`` i.e. ``hQueue``. |
| 63 | +Writing YAML |
| 64 | +============ |
43 | 65 |
|
| 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. |
44 | 69 |
|
| 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`_. |
45 | 73 |
|
| 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``. |
46 | 83 |
|
47 | 84 | Forks and Pull Requests
|
48 | 85 | =======================
|
49 | 86 |
|
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 | +------------------- |
55 | 158 |
|
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. |
58 | 163 |
|
| 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. |
59 | 168 |
|
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 |
0 commit comments