Skip to content

Commit 9d3c26e

Browse files
JackAKirkJackAKirkgmlueck
authored
[SYCL][DOC] Add section on backend support and portability to ext template/README (#7656)
Added a new section in the extension template and simple recommendations for considering cross backend support when adding new oneapi extensions. Signed-off-by: JackAKirk <[email protected]> Co-authored-by: JackAKirk <[email protected]> Co-authored-by: Greg Lueck <[email protected]>
1 parent 98c5488 commit 9d3c26e

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

sycl/doc/extensions/README-process.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ While an extension is in the "proposed" state, it is perfectly OK to make
4040
further modifications to its specification. There is no need to change the
4141
version of the extension's feature-test macro when this occurs.
4242

43+
When proposing a new extension targeting a particular backend, consider
44+
which other backends may be likely to use similar architecture features
45+
and may be able to support the extension. Some types of devices, such as
46+
GPU accelerators (e.g. devices using `level_zero`, `ext_oneapi_cuda`, and
47+
`ext_oneapi_hip` backends) are often designed to target similar sets of
48+
programming patterns. For example, a common set of applications and
49+
patterns that are targeted by gpu accelerators includes AI algorithms and
50+
data analytics, quantum or classical particle based simulations, and quantum
51+
or classical field based simulations. This is important to consider
52+
early on in order to make sure that the extension design takes account of
53+
the requirements of all supportable backends. If unsure about the
54+
applicability of an extension to a backend, it is recommended to seek advice
55+
from one of the developers responsible for that backend. When an extension
56+
API is not supported on some backends or devices, one option is to treat the
57+
API as an "optional kernel feature" and tie it to a device
58+
aspect (or to one of the architecture enums).
59+
In this case, the application must do one of two things:
60+
61+
- The host code can test the device and only submit the kernel to the
62+
device if it has the required aspect, or
63+
- The device code can use the experimental `if_architecture_is` function to
64+
call the API conditionally based on the device architecture. (This only
65+
works for AOT compilation currently.)
66+
4367

4468
## Implementing an extension
4569

sycl/doc/extensions/template.asciidoc

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,32 @@ This extension is no longer implemented in {dpcpp}. This specification is
9696
being archived only for historical purposes. *The APIs defined in this
9797
specification no longer exist and cannot be used.*
9898

99-
_This is an example of a note which can be added if your extension is
100-
implemented only for certain backends. A note like this is appropriate if the
101-
extension is implemented only on certain devices or backends._
10299

103-
[NOTE]
104-
====
100+
== Backend support status
101+
102+
_Sometimes an extension can be used only on certain backends. Your
103+
extension document should include this section when this is the case._
104+
105+
_Our preference is to tie the extension to a device aspect when it is
106+
available only on certain backends because it results in a clear error
107+
if the application mistakenly tries to use it on an unsupported backend.
108+
When this is the case, include a paragraph like this:_
109+
110+
The APIs in this extension may be used only on a device that has
111+
`aspect::ext_oneapi_foo`. The application must check that the device has
112+
this aspect before submitting a kernel using any of the APIs in this
113+
extension. If the application fails to do this, the implementation throws
114+
a synchronous exception with the `errc::kernel_not_supported` error code
115+
when the kernel is submitted to the queue.
116+
117+
_Occasionally, an extension is limited to certain backends and there is no
118+
related device aspect. When this is the case, include a paragraph like:_
119+
105120
This extension is currently implemented in {dpcpp} only for GPU devices and
106121
only when using the Level Zero backend. Attempting to use this extension in
107-
kernels that run on other devices or backends may result in undefined behavior.
108-
Be aware that the compiler is not able to issue a diagnostic to warn you if
109-
this happens.
110-
====
111-
122+
kernels that run on other devices or backends may result in undefined
123+
behavior. Be aware that the compiler is not able to issue a diagnostic to
124+
warn you if this happens.
112125

113126
== Overview
114127

0 commit comments

Comments
 (0)