Skip to content

Commit 4bd6d20

Browse files
authored
[SYCL][DOC] Add extension template (#5663)
Add a template document to use when creating new SYCL extension specifications. We will change our existing specifications to follow this template over time. Also add a README describing the process we follow to create, modify, and maintain these specifications.
1 parent 08b14da commit 4bd6d20

File tree

2 files changed

+407
-0
lines changed

2 files changed

+407
-0
lines changed

sycl/doc/extensions/README-process.md

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Lifetime of an Extension
2+
3+
This document describes the process for creating and maintaining SYCL extension
4+
documents over their lifetime.
5+
6+
7+
## Creating a new extension
8+
9+
Start by making a copy of the [template][1] extension specification document,
10+
and follow the instructions in that document. Your extension should also
11+
follow the rules in [chapter 6][2] of the SYCL specification, including the
12+
"Guidelines for portable extensions". These rules require you to choose a
13+
`<vendorstring>`. For DPC++, we use the string "oneapi" unless the extension
14+
is very specific to Intel hardware in which case we use the string "intel".
15+
The template uses the string "oneapi", so you must change occurrences of that
16+
string if your extension is specific to Intel hardware.
17+
18+
[1]: <template.asciidoc>
19+
[2]: <https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#chapter.extensions>
20+
21+
Some sections in the template are optional. Remove these sections if they are
22+
not needed. You should also remove any of the explanatory text (generally in
23+
italics).
24+
25+
Each extension must have a name. The template uses
26+
"sycl\_ext\_oneapi\_myextension", but you must change the "myextension" to
27+
something appropriate. Use lower case, and separate words with underbars.
28+
Each extension also has a feature-test macro, which is the same as the
29+
extension's name, except it uses all upper case. Finally, the name of the
30+
specification file should match the name of the extension, for example
31+
"sycl\_ext\_oneapi\_myextension.asciidoc".
32+
33+
Usually new extensions are first created in the "proposed" state, so the
34+
document should be added to that directory. However, it is also possible to
35+
add a new extension at the same time as its implementation, in which case the
36+
specification should be added to either the "supported" or "experimental"
37+
directories.
38+
39+
While an extension is in the "proposed" state, it is perfectly OK to make
40+
further modifications to its specification. There is no need to change the
41+
version of the extension's feature-test macro when this occurs.
42+
43+
44+
## Implementing an extension
45+
46+
Often, an extension is implemented sometime after it is proposed. When this
47+
happens, the PR that implements the extension should also move the
48+
specification to either the "supported" or "experimental" directory, as
49+
appropriate. It is common to make small change to the specification when it is
50+
implemented, so the PR that implements the extension may also make
51+
modifications to the specification document.
52+
53+
Be sure to change the text in the "Status" section when the extension is
54+
implemented. See the [template][1] for the proper text.
55+
56+
Sometimes an extension is implemented with multiple PRs. When this happens,
57+
the last PR that implements the extension should also move the specification
58+
document. We want the specification document to reflect the features that are
59+
implemented in DPC++, so a specification should not be moved to "supported" or
60+
"experimental" before the final PR that implements it.
61+
62+
Ideally, all APIs in an extension should be implemented by the time we announce
63+
support. If this is not possible, something must be done to ensure that the
64+
specification is an accurate description of what is implemented. Following are
65+
some techniques to accomplish this.
66+
67+
### Split the specification into versions
68+
69+
This is the preferred technique if the first release of an extension implements
70+
some APIs but not others. In this case, the extension document should be
71+
copied to the "supported" (or "experimental") directory, but the description of
72+
the unimplemented APIs should be removed from this copy. Thus, the document in
73+
that directory is an accurate description of the implementation.
74+
75+
The original version of the specification in the "proposed" folder should
76+
remain. In addition, a new "version" row should be added to the table that
77+
describes the feature-test macro, and all the unimplemented APIs become part of
78+
"version 2" of the specification. These APIs can be implemented later,
79+
following the normal process of [adding a new version to an existing
80+
extension][3].
81+
82+
[3]: <#adding-a-new-version-to-an-existing-extension>
83+
84+
### Add NOTEs describing what is not implemented
85+
86+
Sometimes all of the APIs in an extension are implemented, but they are not yet
87+
implemented for all devices or backends. When this happens, we prefer to add
88+
non-normative "notes" to the extension specification indicating what is not
89+
yet implemented. The placement of these notes depends on the nature of the
90+
unimplemented thing. For example, if the entire extension is unimplemented on
91+
a certain backend, a note should be added in the "Status" section of the
92+
document, as demonstrated in the [template][1]. If there are restrictions with
93+
certain APIs, a note should be added near the description of each such API.
94+
95+
96+
## Adding a new version to an existing extension
97+
98+
It is common to add new APIs to an extension after it is first released. When
99+
this happens, the new APIs should be protected by a new version of the
100+
extension's feature-test macro. This allows an application to test the value
101+
of the macro to know whether the implementation supports the API.
102+
103+
Assuming the extension document is currently in the "supported" directory, make
104+
a copy of that document in the "proposed" directory. Update the "Status"
105+
section as shown in the [template][1], and add a new "version" row to the table
106+
that describes the feature-test macro with a short summary of the new APIs
107+
enabled in that version. The description of each new API should contain a
108+
statement saying which version adds the API. For example,
109+
110+
> This API is available starting in version 2 of this specification.
111+
112+
Avoid unnecessary reformatting of the extension after it is copied. It should
113+
be possible to see the new APIs that are proposed in the new version by using a
114+
command like:
115+
116+
```
117+
$ git diff {supported,proposed}/sycl_ext_oneapi_myextension.asciidoc
118+
```
119+
120+
When the new version of the extension is implemented, the "proposed" version of
121+
the specification should be moved back to the "supported" directory,
122+
overwriting the previous version.
123+
124+
Note that a new version of a supported extension should never remove any
125+
functionality from the previous version. We expect existing code that uses the
126+
old version to still work with the new version.
127+
128+
129+
## Deprecating an extension
130+
131+
Occasionally, we may decide to deprecate a supported extension. For example,
132+
this might happen if an extension is adopted into a new version of the core
133+
SYCL specification. When this happens, the specification is moved from the
134+
"supported" directory to the "deprecated" directory, and the "Status" section
135+
is changed as shown in the [template][1]. A signpost file is also added to
136+
the "supported" directory with the same name as the original file and content
137+
that looks like:
138+
139+
```
140+
This extension has been deprecated, but the specification is still available
141+
link:../deprecated/sycl_ext_oneapi_myextension.asciidoc[here].
142+
```
143+
144+
The purpose of the signpost file is to ensure that external links to the
145+
extension are not broken, while still making it obvious that the extension is
146+
now deprecated.
147+
148+
Note that a deprecated extension is still supported, so the implementation is
149+
not removed.
150+
151+
We usually do not deprecate experimental extensions since there is no guarantee
152+
that these extension remain supported from one DPC++ release to the next.
153+
Instead, these extensions can be removed without a deprecation period.
154+
155+
156+
## Removing support for an extension
157+
158+
Eventually, we typically remove an extension some time after it is deprecated.
159+
When this happens, we move the specification file to the "removed" directory
160+
and update the "Status" section as shown in the [template][1]. We also remove
161+
the signpost file. This typically happens in the same PR that removes the
162+
implementation of the extension.
163+
164+
165+
## Experimental extensions
166+
167+
The process of creating and implementing an "experimental" extension has mostly
168+
been described already, but there are some additional things to keep in mind.
169+
Even though an extension may be experimental, we still want the specification
170+
to accurately describe the API. Usually, the extension document is the main
171+
user-facing description of the API, so it must be accurate in order for
172+
customers to use the extension. Therefore, even an experimental extension
173+
specification must contain [NOTEs][4] describing any APIs that are not yet
174+
implemented.
175+
176+
[4]: <#add-notes-describing-what-is-not-implemented>
177+
178+
Since experimental extensions have no guaranteed compatibility from one DPC++
179+
release to another, we typically do not bother to add versions to the
180+
feature-test macro. This is still allowed, of course, but it is also OK to
181+
add, remove, or modify APIs without changing the version.

0 commit comments

Comments
 (0)