|
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 | +contribuition and refer to the `YAML syntax`_ for specifics of how to define |
| 68 | +the required contructs. |
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 prefix with ``ph`` |
| 82 | + 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 runtime (such as SYCL, |
| 114 | +OpenMP, ...) where possible although this is a secondary concern. |
| 115 | + |
| 116 | +.. hint:: |
| 117 | + Optional features should be avoided as much as possible to maximize |
| 118 | + portability across adapters and reducing the overhead required to use make |
| 119 | + use of features in parallel language runtimes. |
| 120 | + |
| 121 | +Core features are defined in the ``*.yml`` files in the `scripts/core |
| 122 | +<https://github.com/oneapi-src/unified-runtime/tree/main/scripts/core>`_ |
| 123 | +directory. Most of the files are named after the API object who's interface is |
| 124 | +defined within them, with the following exceptions: |
| 125 | + |
| 126 | +* `scripts/core/common.yml`_ defines symbols which are used by multiple |
| 127 | + interfaces through the specification, e.g. macros, object handles, result |
| 128 | + enumerations, and structure type enumerations. |
| 129 | +* `scripts/core/enqueue.yml`_ defines commands which can be enqueued on a |
| 130 | + queue object. |
| 131 | +* `scripts/core/runtime.yml`_ defines global symbols pertaining to |
| 132 | + initialization and tear down of the entire runtime. |
| 133 | +* `scripts/core/registry.yml`_ contains an enumeration of all entry-points, |
| 134 | + past and present, for use in the XPTI tracing framework. It is |
| 135 | + automatically updated so shouldn't require manual editing. |
| 136 | +* ``scripts/core/exp-<feature>.yml`` see `Experimental Features`_. |
| 137 | + |
| 138 | +.. _scripts/core/common.yml: |
| 139 | + https://github.com/oneapi-src/unified-runtime/blob/main/scripts/core/common.yml |
| 140 | +.. _scripts/core/enqueue.yml: |
| 141 | + https://github.com/oneapi-src/unified-runtime/blob/main/scripts/core/enqueue.yml |
| 142 | +.. _scripts/core/runtime.yml: |
| 143 | + https://github.com/oneapi-src/unified-runtime/blob/main/scripts/core/runtime.yml |
| 144 | +.. _scripts/core/registry.yml: |
| 145 | + https://github.com/oneapi-src/unified-runtime/blob/main/scripts/core/registry.yml |
| 146 | + |
| 147 | +Core Optional Features |
| 148 | +---------------------- |
| 149 | + |
| 150 | +Optional core features *must* be supported in at least one adapter. Support for |
| 151 | +an optional core feature *must* be programmatically exposed to the user via |
| 152 | +boolean query call to ${x}DeviceGetInfo and a new enumerator of the form |
| 153 | +``UR_DEVICE_INFO_<FEATURE_NAME>_SUPPORT`` in ${x}_device_info_t. |
| 154 | + |
| 155 | +Conformance Testing |
| 156 | +------------------- |
55 | 157 |
|
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. |
| 158 | +For contributions to the core specification conformance tests *should* be |
| 159 | +included as part of your change. The conformance tests can be found |
| 160 | +under ``test/conformance/<component>``, where component refers to the API |
| 161 | +object an entry-point belongs to i.e. platform, enqueue, device. |
58 | 162 |
|
| 163 | +The conformance tests *should* ideally include end-to-end testing of all the |
| 164 | +changes to the specification if possible. At minimum, they *must* cover at |
| 165 | +least one test for each of the possible error codes returned, excluding any |
| 166 | +disaster cases like ${X}_RESULT_ERROR_OUT_OF_HOST_MEMORY or similar. |
59 | 167 |
|
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. |
| 168 | +Conformance tests *must* not make assumptions about the adapter under test. |
| 169 | +Tests fixtures or cases *must* query for support of optional features and skip |
| 170 | +testing if unsupported by the adapter. |
| 171 | + |
| 172 | +Experimental Features |
| 173 | +===================== |
| 174 | + |
| 175 | +.. warning:: |
| 176 | + |
| 177 | + Experimental features: |
| 178 | + |
| 179 | + * May be replaced, updated, or removed at any time. |
| 180 | + * Do not require maintaining API/ABI stability of their own additions |
| 181 | + over time. |
| 182 | + * Do not require conformance testing of their own additions. |
| 183 | + |
| 184 | +Experimental features *must* be defined in two new files, where |
| 185 | +``<FEATURE>``/``<feature>`` are replaced with an appropriate name: |
| 186 | + |
| 187 | +* ``scripts/core/EXP-<FEATURE>.rst`` document specifying the experimental |
| 188 | + feature in natural language. |
| 189 | +* ``scripts/core/exp-<feature>.yml`` defines the interface as an input to |
| 190 | + `Generating Source`_. |
| 191 | + |
| 192 | +Naming Convention |
| 193 | +----------------- |
| 194 | + |
| 195 | +In addition to the requirements referred to in the `Writing YAML`_ section, and |
| 196 | +to easily differentiate experimental feature symbols, the following conventions |
| 197 | +*must* be adhered to when defining experimental features: |
| 198 | + |
| 199 | +## --validate=off |
| 200 | +* All functions must use camel case ``${x}ObjectActionExp`` convention. |
| 201 | +* All macros must use all caps ``${X}_NAME_EXP`` convention. |
| 202 | +* All structures, enumerations, and other types must follow |
| 203 | + ``${x}_exp_name_t`` name case convention. |
| 204 | +## --validate=on |
0 commit comments