You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: interop_task/interop_task.md
+17-16Lines changed: 17 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,14 @@
12
12
13
13
## Motivation
14
14
15
-
OpenCL applications often build around a set of of fixed function operations which take OpenCL buffers in order to run a hard-coded OpenCL kernels. However, because SYCL does not allow a user to access cl_mem object out of an cl::sycl::accessor, it difficult/impossible to integrate such library into a SYCL application, as the only current way to do this is to create all OpenCL buffers up-front, which is not always possible.
15
+
SYCL does not allow a user to access cl_mem object out of an cl::sycl::accessor, it difficult/impossible to integrate OpenCL library to use them as is inside the data-flow execution model of SYCL, as the only current way to do this is to create all OpenCL buffers up-front, which is not always possible.
16
16
17
17
This proposal introduces a way for a user to retrieve the OpenCL buffer associate with a SYCL buffer and enqueue a host task that can execute an arbitrary portion of host code within the SYCL runtime, therefore taking advantage of SYCL dependency analysis and scheduling.
18
18
19
-
## Enqueuing host tasks on SYCL queues
19
+
## Accessing low-level API functionality on SYCL queues
20
20
21
21
We introduce a new type of handler, the **codeplay::handler**, which includes a new
22
-
**interop\_task** method that executes a task on the host.
22
+
**interop\_task** method that enables submission of low-level API code from the host.
23
23
By submitting this command group to the SYCL device queue, we guarantee it is
24
24
executed in-order w.r.t the other command groups on the same queue.
25
25
Simultaneously, we guarantee that this operation is performed
@@ -28,6 +28,7 @@ thread to continue submitting command groups).
28
28
Other command groups enqueued in the same or different queues
29
29
can be executed following the sequential consistency by guaranteeing the
30
30
satisfaction of the requisites of this command group.
31
+
It is the user's responsability to ensure the lambda submitted via interop_task does not create race conditions with other command groups or with the host.
31
32
32
33
The possibility of enqueuing host tasks on SYCL queues also enables the
33
34
runtime to perform further optimizations when available.
@@ -47,7 +48,7 @@ class handler : public cl::sycl::handler {
47
48
handler(__unspecified__);
48
49
49
50
public:
50
-
/*"Manually" enqueue a kernel*/
51
+
/*Submit a task with interoperability statements.*/
51
52
template <typenameFunctorT>
52
53
void interop_task(FunctorT hostFunction);
53
54
};
@@ -58,16 +59,17 @@ class handler : public cl::sycl::handler {
58
59
59
60
### codeplay::handler::interop_task
60
61
61
-
The `interop_task` allow the user to execute a task of the native host.
62
-
Unlike `single_task`, `parallel_for` and `parallel_for_work_group`, the `interop_task` do not enqueue a kernel on the device but allow the user to execute a custom action when the prerequisites are satisfied on the device associate with the queue.
63
-
The functor passed to the `interop_task` takes as input a const reference to a `cl::sycl::codeplay::interop_handle` which can be used to retrieve underlying OpenCL objects relative to the execution of the task.
62
+
The `interop_task` allows users to submit tasks containing C++ statements with low-level API call (e.g. OpenCL Host API entries).
63
+
The command group that encapsulates the task will execute following the usual SYCL dataflow execution rules.
64
+
The functor passed to the `interop_task` takes as input a const reference to a `cl::sycl::codeplay::interop_handle`. The handle can be used to retrieve underlying OpenCL objects relative to the execution of the task.
64
65
65
66
It is not allowed to allocate new SYCL object inside an `interop_task`.
66
-
It is the user responsibilities to ensure all asynchronous executions using SYCL provided resources finished before returning from the `interop_task`.
67
+
It is the user responsibilities to ensure all operations peroformed inside the `interop_task` finished before returning from it.
67
68
68
-
## Accessing Underlying OpenCL Object
69
+
## Accessing low-level API objects
69
70
70
71
We introduce the `interop_handle` class which provide access to underlying OpenCL objects during the execution of the `interop_task`.
72
+
`interop_handle` objects are immutable objects whose purpose is to enable users access to low-level API functionality.
71
73
72
74
The interface of the `interop_handle` is defined as follow:
73
75
```cpp
@@ -91,31 +93,30 @@ class interop_handle {
91
93
cl_command_queue get_queue() const;
92
94
93
95
/*
94
-
Returns the underlying cl_mem object associated with the accessor
96
+
Returns the underlying cl_mem object associated with a given accessor
95
97
*/
96
98
template <typename dataT, int dimensions, access::mode accessmode,
0 commit comments