Skip to content

Commit 23412df

Browse files
ProGTXAerialMantis
authored andcommitted
CP28 Automatic placeholder requirements
1. Allow skipping `require` 2. Define convenience functions 3. Don't allow this on kernel enqueues
1 parent 2b5cca4 commit 23412df

File tree

2 files changed

+113
-1
lines changed

2 files changed

+113
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ from this registry in the future.
6363
| CP020 | [Interop Task](interop_task/interop_task.md) | SYCL 1.2.1 | 16 January 2019 | 16 January 2019 | _Available since CE 1.0.5_ |
6464
| CP021 | [Default-Constructed Buffers](default-constructed-buffers/default-constructed-buffers.md) | SYCL 1.2.1 | 27 August 2019 | 5 September 2019 | _Draft_ |
6565
| CP022 | [Host Task with Interop capabilities](host_task/host_task.md) | SYCL 1.2.1 | 16 January 2019 | 20 January 2020 | _Final Draft_ |
66-
| CP026 | [Generalized Error Handling For SYCL](error-handling/sycl-error-handling.md) | SYCL Next | 10 March 2020 | 10 March 2020 | _Under Review_ |
66+
| CP026 | [Generalized Error Handling For SYCL](error-handling/sycl-error-handling.md) | SYCL Next | 10 March 2020 | 10 March 2020 | _Under Review_ |
67+
| CP028 | [Automatic placeholder requirements](auto-require/index.md) | SYCL Next (after 1.2.1) | 17 April 2020 | 28 April 2020 | _Work in Progress_ |

auto-require/index.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Automatic placeholder requirements
2+
3+
| Proposal ID | CP028 |
4+
|-------------|--------|
5+
| Name | Automatic placeholder requirements |
6+
| Date of Creation | 17 April 2020 |
7+
| Revision | 0.1 |
8+
| Latest Update | 28 April 2020 |
9+
| Target | SYCL Next (after 1.2.1) |
10+
| Current Status | _Work in Progress_ |
11+
| Reply-to | Peter Žužek <[email protected]> |
12+
| Original author | Peter Žužek <[email protected]> |
13+
| Contributors | Gordon Brown <[email protected]>, Ruyman Reyes <[email protected]> |
14+
15+
## Overview
16+
17+
This proposal allows placeholders to be automatically registered
18+
when used in explicit memory functions.
19+
It also provides convenience versions of those functions on the `queue` class.
20+
21+
## Revisions
22+
23+
### 0.1
24+
25+
* Initial proposal
26+
27+
## Motivation
28+
29+
[A separate proposal](https://github.com/codeplaysoftware/standards-proposals/pull/122)
30+
deprecated `accessor::placeholder`,
31+
making it easier to construct placeholder accessors.
32+
33+
An example on how this can be used to copy data
34+
from an accessor to a host pointer:
35+
36+
```cpp
37+
// Assume buf of type buffer<int, 1>
38+
// Assume hostPtr of type int*
39+
40+
// Create the placeholder
41+
accessor<int, 1, access::mode::read> acc{buf};
42+
43+
queue q;
44+
q.submit([&](handler& cgh){
45+
// Register placeholder with the command group
46+
cgh.require(acc);
47+
48+
// Perform the copy
49+
cgh.copy(acc, hostPtr);
50+
});
51+
```
52+
53+
At the point of calling `cgh.copy` the SYCL runtime knows where data is requested.
54+
Calling `cgh.require` shouldn't really be necessary at that point
55+
because the `copy` function could just call `require` on its own.
56+
That would allow us to simplify the command group:
57+
58+
```cpp
59+
q.submit([&](handler& cgh){
60+
// Perform the copy
61+
cgh.copy(acc, hostPtr);
62+
});
63+
```
64+
65+
Everything is automatically handled by the SYCL runtime.
66+
However, we could go one step further,
67+
and provide convenience member functions on the queue,
68+
allowing us to skip the submission lambda
69+
(just like the new queue member functions in the
70+
[USM proposal](https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/USM/USM.adoc)):
71+
72+
```cpp
73+
// Perform the copy
74+
q.copy(acc, hostPtr);
75+
```
76+
77+
## Changes
78+
79+
In the accessor section,
80+
add the following paragraph:
81+
82+
```latex
83+
Any member function of the \codeinline{queue} or the \codeinline{handler}
84+
that accepts an \codeinline{accessor} automatically creates
85+
a \textbf{requirement} for the command group.
86+
This is not true for member functions that enqueue a kernel -
87+
\codeinline{single_task}, \codeinline{parallel_for}, \codeinline{parallel_for_work_group} -
88+
in those cases it is still required to manually register the placeholder
89+
with the command group.
90+
```
91+
92+
In the section on explicit memory,
93+
add the following paragraph:
94+
95+
```latex
96+
The same members functions listed in Table~\ref{table.members.handler.copy}
97+
are also available as member functions of the \codeinline{queue} class,
98+
but they can only accept \keyword{placeholder} accessors.
99+
```
100+
101+
## Limitations
102+
103+
There is a temptation to extend this automatic registration
104+
to member functions of the `handler` that perform kernel enqueues:
105+
`single_task`, `parallel_for`, `parallel_for_work_group`.
106+
However, that might prove a bit more difficult
107+
because the accessors are captured inside a function object
108+
and C++ doesn't yet provide proper facilities for inspecting that object -
109+
static reflection would be needed.
110+
Therefore it is our concern that extending the proposal to kernel enqueues
111+
may not be implementable on the SYCL host device.

0 commit comments

Comments
 (0)