Skip to content

Commit 13af31e

Browse files
committed
Addressing PR comments
1 parent 2cb1e05 commit 13af31e

File tree

1 file changed

+92
-19
lines changed

1 file changed

+92
-19
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc

+92-19
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,12 @@ dependencies in one of three ways. Firstly, through buffer accessors that
280280
represent data dependencies between two command groups captured as nodes.
281281
Secondly, by using the `handler::depends_on()` mechanism inside a command group
282282
captured as a node. However, for an event passed to `handler::depends_on()` to
283-
create an edge, it must be an event returned from a queue
284-
submission captured by the same graph. Passing events from other sources (other
285-
graph submissions, regular SYCL submissions) will not create edges in the graph,
286-
but will create runtime dependencies for a graph node on those other events.
287-
`handler::depends_on()` can be used to express edges when a user is working with
288-
USM memory rather than SYCL buffers. Thirdly, for a graph recorded with an
289-
in-order queue, an edge is added automatically between two sequential command
290-
groups submitted to the in-order queue.
283+
create an edge, it must be an event returned from a queue submission captured by
284+
the same graph. Passing events from other sources (other graph submissions,
285+
regular SYCL submissions) will not create edges in the graph, but will create
286+
runtime dependencies for a graph node on those other events. Thirdly, for a
287+
graph recorded with an in-order queue, an edge is added automatically between
288+
two sequential command groups submitted to the in-order queue.
291289

292290
|===
293291

@@ -478,7 +476,7 @@ Exceptions:
478476

479477
|===
480478

481-
==== Dynamic Parameters
479+
==== Dynamic Parameters [[dynamic-parameters]]
482480

483481
[source,c++]
484482
----
@@ -569,9 +567,9 @@ class depends_on {
569567
template<typename... NodeTN>
570568
depends_on(NodeTN... nodes);
571569
572-
depends_on(const event& ev);
570+
depends_on(const event& depEvent);
573571
574-
depends_on(const std::vector<event>& events);
572+
depends_on(const std::vector<event>& depEvents);
575573
};
576574
}
577575
----
@@ -580,7 +578,7 @@ The API for explicitly adding nodes to a `command_graph` includes a
580578
`property_list` parameter. This extension defines the `depends_on` property to
581579
be passed here. `depends_on` may be used in two ways:
582580

583-
* Passing nodes from the same command_graph which will create dependencies and
581+
* Passing nodes from the same `command_graph` which will create dependencies and
584582
graph edges between those nodes and the node being added.
585583

586584
* Passing SYCL events will create runtime dependencies for execution of the
@@ -723,14 +721,16 @@ Updates to a graph will be scheduled after any in-flight executions of the same
723721
graph and will not affect previous submissions of the same graph. The user is
724722
not required to wait on any previous submissions of a graph before updating it.
725723

726-
The only type of nodes that are currently supported for updating in a graph are
727-
kernel execution nodes.
728-
729724
The aspects of a kernel execution node that can be configured during update are:
730725

731726
* Parameters to the kernel.
732727
* Execution ND-Range of the kernel.
733728

729+
All node types may have the following aspects configured during update:
730+
731+
* Dependent events which were specified using <<dyanmic-events, Dynamic
732+
Events>>.
733+
734734
To update an executable graph, the `property::graph::updatable` property must
735735
have been set when the graph was created during finalization. Otherwise, an
736736
exception will be thrown if a user tries to update an executable graph. This
@@ -777,7 +777,7 @@ will maintain the graphs data dependencies.
777777
===== Node Event Dependency Update
778778

779779
Event dependencies for nodes can be updated using <<dynamic-events, Dynamic
780-
Events>> in a similar usage to Dynamic Parameters.
780+
Events>> in a similar usage to <<dynamic-parameters, Dynamic Parameters>>.
781781

782782
Event updates are performed using a `dynamic_event` instance and calling
783783
`dynamic_event::update()` to update all the associated event dependencies of
@@ -1125,6 +1125,20 @@ event get_event(const node& n);
11251125
only for the next execution of the graph. This event can be used as a dependency
11261126
in the same way as normal SYCL events.
11271127

1128+
Constraints:
1129+
1130+
* This member function is only available when the `command_graph` state is
1131+
`graph_state::executable`.
1132+
1133+
Parameters:
1134+
1135+
* `n` - The node to get the associated event for.
1136+
1137+
Exceptions:
1138+
1139+
* Throws synchronously with error code `invalid` if `n` is not a node within the
1140+
graph.
1141+
11281142
|===
11291143

11301144
Table {counter: tableNumber}. Member functions of the `command_graph` class for
@@ -1608,8 +1622,8 @@ different from the one with which the dynamic_parameter was created.
16081622

16091623
[source,c++]
16101624
----
1611-
namespace ext::oneapi::experimental{
1612-
class dynamic_event{
1625+
namespace ext::oneapi::experimental {
1626+
class dynamic_event {
16131627
dynamic_event();
16141628
dynamic_event(const event& ev);
16151629
@@ -1620,7 +1634,7 @@ namespace ext::oneapi::experimental{
16201634

16211635
Dynamic events represent SYCL events from outside of a given `command_graph`
16221636
(either obtained from normal SYCL operations or from another `command_graph`)
1623-
that nodes in that graph may depend on. Dynamic events also allow for these
1637+
that nodes in that graph may depend on. The `dynamic_event` object enables these
16241638
dependent events to be updated between graph executions.
16251639

16261640
Dynamic events can be used to add dependencies to a graph node in the same way
@@ -2219,6 +2233,65 @@ node nodeA = myGraph.add([&](handler& cgh) {
22192233
dynParamAccessor.update(bufferB.get_access());
22202234
----
22212235

2236+
=== Dynamic Event Update
2237+
2238+
Example which shows create a dependency between two graphs using dynamic events
2239+
which are then updated between executions.
2240+
2241+
[source,c++]
2242+
----
2243+
...
2244+
2245+
using namespace sycl;
2246+
namespace sycl_ext = sycl::ext::oneapi::experimental;
2247+
2248+
queue myQueue;
2249+
auto myContext = myQueue.get_context();
2250+
auto myDevice = myQueue.get_device();
2251+
2252+
// Create the first graph
2253+
sycl_ext::command_graph graphA(myContext, myDevice);
2254+
2255+
// Add a node to graphA
2256+
sycl_ext::node nodeA = graphA.add(...);
2257+
2258+
sycl_ext::command_graph<sycl_ext::graph_state::executable> execGraphA =
2259+
graphA.finalize();
2260+
2261+
// Get an event for the next execution of nodeA in execGraphA
2262+
event eventA = execGraph.get_event(nodeA);
2263+
2264+
// Create the second graph
2265+
sycl_ext::command_graph graphB(myContext, myDevice);
2266+
2267+
// Create the dynamic event which will wrap eventA and use it as a dependency
2268+
// for a node in graphB
2269+
sycl_ext::dynamic_event dynEvent{eventA};
2270+
2271+
auto nodeB = graphB.add([&](handler& CGH){
2272+
CGH.depends_on(dynEvent);
2273+
CGH.parallel_for(...);
2274+
});
2275+
2276+
auto execGraphB = graphB.finalize({sycl_ext::property::graph::updatable});
2277+
2278+
// Submit both graphs for execution
2279+
myQueue.submit(execGraphA);
2280+
myQueue.submit(execGraphB);
2281+
myQueue.wait_and_throw();
2282+
2283+
// Update the dynamic event with a new event frome execGraphA to reflect the
2284+
// next execution
2285+
dynEvent.update(execGraphA.get_event(nodeA));
2286+
// Update execGraphB with the affected node to reflect those changes
2287+
execGraphB.update(nodeB);
2288+
2289+
// Both graphs can now be executed again with updated dependencies between them.
2290+
myQueue.submit(execGraphA);
2291+
myQueue.submit(execGraphB);
2292+
myQueue.wait_and_throw();
2293+
----
2294+
22222295
== Future Direction [[future-direction]]
22232296

22242297
This section contains both features of the specification which have been

0 commit comments

Comments
 (0)