Skip to content

Commit 119ba28

Browse files
author
Ewan Crawford
committed
Refine based on implementation findings
1 parent 7858877 commit 119ba28

File tree

2 files changed

+47
-33
lines changed

2 files changed

+47
-33
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -425,23 +425,20 @@ Exceptions:
425425
template <int Dimensions>
426426
void update_nd_range(nd_range<Dimensions> executionRange);
427427
----
428-
| Updates the ND-Range for this node with a new value. This new value will not
428+
| Updates the ND-range for this node with a new value. This new value will not
429429
affect any executable graphs this node is part of until it is passed to the
430430
executable graph's update function.
431431
See <<executable-graph-update, Executable Graph Update>> for more information
432432
about updating kernel nodes.
433433

434434
Parameters:
435435

436-
* `executionRange` - The new value for the ND-Range.
436+
* `executionRange` - The new value for the ND-range.
437437

438438
Exceptions:
439439

440440
* Throws with error code `invalid` if `Dimensions` does not match the dimensions
441-
of the nd_range the kernel was originally created with.
442-
443-
* Throws with error code `invalid` if the kernel node was originally created
444-
with a `sycl::range`.
441+
of the existing kernel execution range.
445442

446443
* Throws with error code `invalid` if the type of the node is not a kernel
447444
execution.
@@ -452,23 +449,20 @@ Exceptions:
452449
template <int Dimensions>
453450
void update_range(range<Dimensions> executionRange);
454451
----
455-
| Updates the execution Range for this node with a new value. This new value
452+
| Updates the execution range for this node with a new value. This new value
456453
will not affect any executable graphs this node is part of until it is
457454
passed to the executable graph's update function.
458455
See <<executable-graph-update, Executable Graph Update>> for more information
459456
about updating kernel nodes.
460457

461458
Parameters:
462459

463-
* `executionRange` - The new value for the Range.
460+
* `executionRange` - The new value for the range.
464461

465462
Exceptions:
466463

467464
* Throws with error code `invalid` if `Dimensions` does not match the dimensions
468-
of the range the kernel was originally created with.
469-
470-
* Throws with error code `invalid` if the kernel node was originally created
471-
with a `sycl::nd_range`.
465+
of the existing kernel execution range.
472466

473467
* Throws with error code `invalid` if the type of the node is not a kernel
474468
execution.
@@ -523,7 +517,7 @@ Table {counter: tableNumber}. Member functions of the `dynamic_parameter` class.
523517
|
524518
[source,c++]
525519
----
526-
dynamic_parameter(command_graph<graph_state::modifiable> graph,
520+
dynamic_parameter(command_graph<graph_state::modifiable> graph,
527521
const ValueT &initialValue);
528522
----
529523
|Constructs a dynamic parameter object that can be registered with command graph
@@ -564,10 +558,10 @@ namespace ext::oneapi::experimental {
564558
class dynamic_command_group {
565559
public:
566560
dynamic_command_group(
567-
command_graph<graph_state::modifiable> graph,
561+
command_graph<graph_state::modifiable> &graph,
568562
const std::vector<std::function<void(handler &)>>& cgfList);
569563
570-
size_t get_active_cgf();
564+
size_t get_active_cgf() const;
571565
void set_active_cgf(size_t cgfIndex);
572566
};
573567
----
@@ -579,6 +573,8 @@ as active. When a dynamic command-group node is executed, the kernel of the acti
579573
command-group function will be run and all the other command-group functions in
580574
`cgfList` will be ignored.
581575

576+
The `dynamic_command_group` class provides the {crs}[common reference semantics].
577+
582578
See <<executable-graph-update, Executable Graph Update>> for more information
583579
about updating command-groups.
584580

@@ -591,7 +587,8 @@ All the command-group functions in a dynamic command-group must have identical d
591587
It is not allowed for a dynamic command-group to have command-group functions that would
592588
result in a change to the graph topology when set to active. In practice, this means that
593589
any calls to `handler.depends_on()` must be identical for all the command-group functions
594-
in a dynamic command-group.
590+
in a dynamic command-group. The dependencies created by buffer accessors must also create
591+
identical node dependencies across all of the command-group functions.
595592

596593
Table {counter: tableNumber}. Member functions of the `dynamic_command_group` class.
597594
[cols="2a,a"]
@@ -602,7 +599,7 @@ Table {counter: tableNumber}. Member functions of the `dynamic_command_group` cl
602599
[source,c++]
603600
----
604601
dynamic_command_group(
605-
command_graph<graph_state::modifiable> graph,
602+
command_graph<graph_state::modifiable> &graph,
606603
const std::vector<std::function<void(handler &)>>& cgfList);
607604
----
608605

@@ -618,21 +615,19 @@ Exceptions:
618615

619616
* Throws synchronously with error code `invalid` if the graph wasn't created with
620617
the `property::graph::assume_buffer_outlives_graph` property and the `dynamic_command_group`
621-
is created with command-group functions that use buffers. See the
618+
is created with any command-group function that uses buffers. See the
622619
<<assume-buffer-outlives-graph-property, Assume-Buffer-Outlives-Graph>>
623620
property for more information.
624621

625622
* Throws with error code `invalid` if the `dynamic_command_group` is created with
626623
command-group functions that are not kernel executions.
627624

628-
* Throws with error code `invalid` if the command-group functions in `cgfList` have
629-
event dependencies that are incompatible with each other and would result in
630-
different graph topologies when set to active.
625+
* Throws with error code `invalid` if `cgfList` is empty.
631626

632627
|
633628
[source,c++]
634629
----
635-
size_t get_active_cgf();
630+
size_t get_active_cgf() const;
636631
----
637632
|Returns the index of the currently active command-group function in this
638633
`dynamic_command_group`.
@@ -844,9 +839,9 @@ The aspects of a kernel execution node that can be changed during update are
844839
different depending on the API used to perform the update:
845840

846841
* For the <<individual-node-update, Individual Node Update>> API it's possible to update
847-
the kernel function, the parameters to the kernel, and the ND-Range.
842+
the kernel function, the parameters to the kernel, and the ND-range.
848843
* For the <<whole-graph-update, Whole Graph Update>> API, only the parameters of the kernel
849-
and the ND-Range can be updated.
844+
and the ND-range can be updated.
850845

851846
===== Individual Node Update [[individual-node-update]]
852847

@@ -889,7 +884,11 @@ kernel, this can be set through `node::update_nd_range()` or
889884
`node::update_range()` but does not require any prior registration.
890885

891886
An alternative way to update the execution range of a node is to do so while
892-
updating command groups as described in the next section.
887+
updating command groups as described in the next section. Using this mechanism
888+
lifts the restriction from `node::update_nd_range()` / `node::update_range()`
889+
of only being to update the execution range in the same dimension. As the
890+
update being tied to a change in command-group means that the updated kernel
891+
code may be defined as operating in a different dimension.
893892

894893
====== Command Group Updates
895894

@@ -909,6 +908,14 @@ dynamic parameters can be used in command-group functions that are part of
909908
dynamic command-groups. Updates to such dynamic parameters will be reflected
910909
in the command-group functions once they are activated.
911910

911+
Note that the execution range is tied to the command-group, therefore updating
912+
the range of a node which uses a dynamic command-group shared by another node
913+
will also update the execution range of the nodes sharing the dynamic
914+
command-group. Activating a command-group with `set_active_cgf` to a
915+
command-group that previously had its execution range updated with
916+
`node::update_range()` or `node::update_nd_range()` will not reset the execution
917+
range to the original, but instead use the most recently updated value.
918+
912919
====== Committing Updates
913920

914921
Updating a node using the methods mentioned above will take effect immediately
@@ -1230,6 +1237,14 @@ Exceptions:
12301237

12311238
* Throws synchronously with error code `invalid` if a queue is recording
12321239
commands to the graph.
1240+
1241+
* Throws synchronously with error code `invalid` if the graph does not match
1242+
the graph used on construction of `dynamicCG`.
1243+
1244+
* Throws with error code `invalid` if the command-group functions in `cgfList` have
1245+
event or accessor dependencies that are incompatible with each other and
1246+
would result in different graph topologies when set to active.
1247+
12331248
|
12341249
[source,c++]
12351250
----
@@ -2381,8 +2396,8 @@ if used in application code.
23812396

23822397
. Using reductions in a graph node.
23832398
. Using sycl streams in a graph node.
2384-
. Synchronization between multiple executions of the same command-buffer
2385-
must be handled in the host for level-zero backend, which may involve
2399+
. Synchronization between multiple executions of the same command-buffer
2400+
must be handled in the host for level-zero backend, which may involve
23862401
extra latency for subsequent submissions.
23872402

23882403
== Revision History

sycl/doc/syclgraph/SYCLGraphUsageGuide.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,12 @@ sycl_ext::command_graph myGraph(myContext, myDevice);
394394
395395
int myScalar = 42;
396396
// Create graph dynamic parameters
397-
dynamic_parameter dynParamInput(myGraph, ptrX);
398-
dynamic_parameter dynParamScalar(myGraph, myScalar);
397+
sycl_ext::dynamic_parameter dynParamInput(myGraph, ptrX);
398+
sycl_ext::dynamic_parameter dynParamScalar(myGraph, myScalar);
399399
400400
// The node uses ptrX as an input & output parameter, with operand
401401
// mySclar as another argument.
402-
node kernelNode = myGraph.add([&](handler& cgh) {
402+
sycl_ext::node kernelNode = myGraph.add([&](handler& cgh) {
403403
cgh.set_args(dynParamInput, ptrY, dynParamScalar);
404404
cgh.parallel_for(range {n}, builtinKernel);
405405
});
@@ -438,9 +438,9 @@ sycl::buffer bufferB{...};
438438

439439
// Create graph dynamic parameter using a placeholder accessor, since the
440440
// sycl::handler is not available here outside of the command-group scope.
441-
dynamic_parameter dynParamAccessor(myGraph, bufferA.get_access());
441+
sycl_ext::dynamic_parameter dynParamAccessor(myGraph, bufferA.get_access());
442442

443-
node kernelNode = myGraph.add([&](handler& cgh) {
443+
sycl_ext::node kernelNode = myGraph.add([&](handler& cgh) {
444444
// Require the accessor contained in the dynamic paramter
445445
cgh.require(dynParamAccessor);
446446
// Set the arg on the kernel using the dynamic parameter directly
@@ -497,7 +497,6 @@ ExecGraph.update(DynamicCGNode);
497497
Queue.ext_oneapi_graph(ExecGraph).wait();
498498
```
499499
500-
501500
### Whole Graph Update
502501
503502
Example that shows recording and updating several nodes with different

0 commit comments

Comments
 (0)