Skip to content

Commit d489c62

Browse files
Victor LomullerNaghasan
authored andcommitted
Apply review feedback
1 parent c66a9a7 commit d489c62

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

interop_task/interop_task.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
## Motivation
1414

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.
1616

1717
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.
1818

19-
## Enqueuing host tasks on SYCL queues
19+
## Accessing low-level API functionality on SYCL queues
2020

2121
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.
2323
By submitting this command group to the SYCL device queue, we guarantee it is
2424
executed in-order w.r.t the other command groups on the same queue.
2525
Simultaneously, we guarantee that this operation is performed
@@ -28,6 +28,7 @@ thread to continue submitting command groups).
2828
Other command groups enqueued in the same or different queues
2929
can be executed following the sequential consistency by guaranteeing the
3030
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.
3132

3233
The possibility of enqueuing host tasks on SYCL queues also enables the
3334
runtime to perform further optimizations when available.
@@ -47,7 +48,7 @@ class handler : public cl::sycl::handler {
4748
handler(__unspecified__);
4849

4950
public:
50-
/* "Manually" enqueue a kernel */
51+
/* Submit a task with interoperability statements. */
5152
template <typename FunctorT>
5253
void interop_task(FunctorT hostFunction);
5354
};
@@ -58,16 +59,17 @@ class handler : public cl::sycl::handler {
5859
5960
### codeplay::handler::interop_task
6061
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.
6465
6566
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.
6768
68-
## Accessing Underlying OpenCL Object
69+
## Accessing low-level API objects
6970
7071
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.
7173
7274
The interface of the `interop_handle` is defined as follow:
7375
```cpp
@@ -91,31 +93,30 @@ class interop_handle {
9193
cl_command_queue get_queue() const;
9294
9395
/*
94-
Returns the underlying cl_mem object associated with the accessor
96+
Returns the underlying cl_mem object associated with a given accessor
9597
*/
9698
template <typename dataT, int dimensions, access::mode accessmode,
9799
access::target accessTarget,
98100
access::placeholder isPlaceholder>
99-
cl_mem get(const accessor<dataT, dimensions, accessmode, access::target accessTarget, access::placeholder isPlaceholder>&) const;
101+
cl_mem get_buffer(const accessor<dataT, dimensions, accessmode, access::target accessTarget, access::placeholder isPlaceholder>&) const;
100102
};
101103
} // namespace codeplay
102104
} // namespace sycl
103105
} // namespace cl
104106
```
105107

106-
`interop_handle` objects are immutable object whose purpose is to allow the user to access objects relevant to the context.
107-
108108
## Example using regular accessor
109109

110110
```cpp
111111
auto cgH = [=] (codeplay::handler& cgh) {
112-
auto accA = bufA.get_access<access::mode::read>(cgh); // Get device accessor to SYCL buffer (cannot be dereference directly in interop_task).
112+
// Get device accessor to SYCL buffer (cannot be dereferenced directly in interop_task).
113+
auto accA = bufA.get_access<access::mode::read>(cgh);
113114
auto accB = bufB.get_access<access::mode::read_write>(cgh);
114115

115116
h.interop_task([=](codeplay::interop_handle &handle) {
116117
third_party_api(handle.get_queue(), // Get the OpenCL command queue to use, can be the fallback
117-
handle.get(accA), // Get the OpenCL mem object behind accA
118-
handle.get(accB)); // Get the OpenCL mem object behind accB
118+
handle.get_buffer(accA), // Get the OpenCL mem object behind accA
119+
handle.get_buffer(accB)); // Get the OpenCL mem object behind accB
119120
// Assumes call has finish when exiting the task
120121
});
121122
};

0 commit comments

Comments
 (0)