Skip to content

Commit 0629c6c

Browse files
jbrodmanPennycook
andauthored
[SYCL][DOC] Add initial spec draft for new default device (intel#15382)
This is a draft for a new extension to add the notion of a default device. It adds a method to query the current device from the calling thread as well as a method to change it. --------- Signed-off-by: James Brodman <james.brodman@intel.com> Co-authored-by: John Pennycook <john.pennycook@intel.com>
1 parent e3e3b78 commit 0629c6c

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
= sycl_ext_oneapi_current_device
2+
3+
4+
:source-highlighter: coderay
5+
:coderay-linenums-mode: table
6+
7+
// This section needs to be after the document title.
8+
:doctype: book
9+
:toc2:
10+
:toc: left
11+
:encoding: utf-8
12+
:lang: en
13+
:dpcpp: pass:[DPC++]
14+
15+
// Set the default source code type in this document to C++,
16+
// for syntax highlighting purposes. This is needed because
17+
// docbook uses c++ and html5 uses cpp.
18+
:language: {basebackend@docbook:c++:cpp}
19+
20+
21+
== Notice
22+
23+
[%hardbreaks]
24+
Copyright (C) 2024 Intel Corporation. All rights reserved.
25+
26+
Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks
27+
of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by
28+
permission by Khronos.
29+
30+
31+
== Contact
32+
33+
To report problems with this extension, please open a new issue at:
34+
35+
https://github.com/intel/llvm/issues
36+
37+
38+
== Dependencies
39+
40+
This extension is written against the SYCL 2020 revision 9 specification. All
41+
references below to the "core SYCL specification" or to section numbers in the
42+
SYCL specification refer to that revision.
43+
44+
== Status
45+
46+
This is a proposed extension specification, intended to gather community
47+
feedback. Interfaces defined in this specification may not be implemented yet
48+
or may be in a preliminary state. The specification itself may also change in
49+
incompatible ways before it is finalized. *Shipping software products should
50+
not rely on APIs defined in this specification.*
51+
52+
== Overview
53+
54+
This extension introduces additional state into SYCL in order to simplify
55+
programming for developers. The extension provides a mechanism to both set and
56+
query the 'current' per-thread `sycl::device`. By adding the notion of a 'current'
57+
device, this can simplify interfaces and reduce the amount of boilerplate code
58+
required to write a SYCL application.
59+
60+
Since this function relates to the environment of the calling thread,
61+
it is the user's responsibility to ensure that it is called by the correct thread.
62+
For example, it is unsafe to call this function inside of a host task, within an
63+
asynchronous error handler, or within other functions that may be executed
64+
asynchronously, since these operations are not guaranteed to execute on any
65+
specific thread.
66+
67+
== Specification
68+
69+
=== Feature test macro
70+
71+
This extension provides a feature-test macro as described in the core SYCL
72+
specification. An implementation supporting this extension must predefine the
73+
macro `SYCL_EXT_ONEAPI_CURRENT_DEVICE` to one of the values defined in the table
74+
below. Applications can test for the existence of this macro to determine if
75+
the implementation supports this feature, or applications can test the macro's
76+
value to determine which of the extension's features the implementation
77+
supports.
78+
79+
[%header,cols="1,5"]
80+
|===
81+
|Value
82+
|Description
83+
84+
|1
85+
|Initial version of this extension.
86+
|===
87+
88+
=== New free functions
89+
90+
This extension adds the following new free functions:
91+
92+
93+
'''
94+
95+
[frame=all,grid=none,separator="@"]
96+
!====
97+
a@
98+
[source,c++]
99+
----
100+
namespace sycl::ext::oneapi::experimental::this_thread {
101+
102+
sycl::device get_current_device();
103+
104+
} // namespace sycl::ext::oneapi::experimental::this_thread
105+
----
106+
!====
107+
108+
_Returns:_ The current default device for the calling host thread. If
109+
`set_current_device()` has not been called by this thread, returns the
110+
device selected by the default device selector.
111+
112+
_Preconditions:_ The function is called from a host thread, executing
113+
outside of a host task or an asynchronous error handler.
114+
115+
'''
116+
117+
[frame=all,grid=none,separator="@"]
118+
!====
119+
a@
120+
[source,c++]
121+
----
122+
namespace sycl::ext::oneapi::experimental::this_thread {
123+
124+
void set_current_device(sycl::device dev);
125+
126+
} // namespace sycl::ext::oneapi::experimental::this_thread
127+
----
128+
!====
129+
130+
_Effects:_ Sets the current default device to `dev` for the calling host thread.
131+
132+
_Preconditions:_ The function is called from a host thread, executing outside
133+
of a host task or an asynchronous error handler.
134+
135+
== Issues
136+
. [RESOLVED] Should the current device be global or should we also support a per-thread
137+
device? Answer: It should be per-thread to align with the behavior of other programming
138+
models.
139+
. [OPEN] We want to add a default queue per device. Should this queue be in-order or out-of-order?
140+
Do we want to allow the user to specify this?

0 commit comments

Comments
 (0)