Skip to content

Commit edf643c

Browse files
committed
Address review comments
1 parent a38ea7a commit edf643c

File tree

10 files changed

+48
-34
lines changed

10 files changed

+48
-34
lines changed

sycl/doc/design/CommandGraph.md

+4-15
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,7 @@ yet been implemented.
234234

235235
### Design Challenges
236236

237-
#### Explicit Update
238-
239-
Explicit updates of individual nodes faces significant design challenges in SYCL:
237+
Graph update faces significant design challenges in SYCL:
240238

241239
* Lambda capture order is explicitly undefined in C++, so the user cannot reason
242240
about the indices of arguments captured by kernel lambdas.
@@ -258,18 +256,9 @@ can be used:
258256
extension](../extensions/proposed/sycl_ext_oneapi_free_function_kernels.asciidoc)
259257
* OpenCL interop kernels created from SPIR-V source at runtime.
260258

261-
A workaround for the lambda capture issues is the "Whole-Graph Update" feature.
262-
Since the lambda capture order is the same across two different recordings, we
263-
can match the parameter order when updating.
264-
265-
#### Whole-Graph Update
266-
267-
The current implementation of the whole-graph update feature relies on the
268-
assumption that both graphs should have a similar topology. Currently, the
269-
implementation only checks that both graphs have an identical number of nodes
270-
and that each node contains the same number of edges. A possible design change
271-
could be to add more checks to the implementation. This would give the user
272-
better error messages but with possible performance penalties.
259+
A possible future workaround lambda capture issues could be "Whole-Graph Update"
260+
where if we can guarantee that lambda capture order is the same across two
261+
different recordings we can then match parameter order when updating.
273262

274263
### Scheduler Integration
275264

sycl/source/detail/graph_impl.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -1171,23 +1171,25 @@ void exec_graph_impl::update(std::shared_ptr<graph_impl> GraphImpl) {
11711171

11721172
if (MNodeStorage.size() != GraphImpl->MNodeStorage.size()) {
11731173
throw sycl::exception(sycl::make_error_code(errc::invalid),
1174-
"Mismatch found in the number of nodes. The graphs "
1175-
"must have a matching topology.");
1174+
"Cannot update using a graph with a different "
1175+
"topology. Mismatch found in the number of nodes.");
11761176
} else {
11771177
for (uint32_t i = 0; i < MNodeStorage.size(); ++i) {
11781178
if (MNodeStorage[i]->MSuccessors.size() !=
11791179
GraphImpl->MNodeStorage[i]->MSuccessors.size() ||
11801180
MNodeStorage[i]->MPredecessors.size() !=
11811181
GraphImpl->MNodeStorage[i]->MPredecessors.size()) {
1182-
throw sycl::exception(sycl::make_error_code(errc::invalid),
1183-
"Mismatch found in the number of edges. The "
1184-
"graphs must have a matching topology.");
1182+
throw sycl::exception(
1183+
sycl::make_error_code(errc::invalid),
1184+
"Cannot update using a graph with a different topology. Mismatch "
1185+
"found in the number of edges.");
11851186
}
11861187

11871188
if (MNodeStorage[i]->MCGType != GraphImpl->MNodeStorage[i]->MCGType) {
1188-
throw sycl::exception(sycl::make_error_code(errc::invalid),
1189-
"Mismatch found in the type of nodes. Each pair "
1190-
"of nodes being updated must have the same type");
1189+
throw sycl::exception(
1190+
sycl::make_error_code(errc::invalid),
1191+
"Cannot update using a graph with mismatched node types. Each pair "
1192+
"of nodes being updated must have the same type");
11911193
}
11921194
}
11931195
}

sycl/test-e2e/Graph/Inputs/whole_update_double_buffer.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ int main() {
6161
event Event;
6262
for (size_t i = 0; i < Iterations; i++) {
6363
Event = Queue.submit([&](handler &CGH) {
64-
CGH.depends_on(Event);
6564
CGH.ext_oneapi_graph(ExecGraph);
6665
});
6766
// Update to second set of buffers
6867
ExecGraph.update(GraphUpdate);
6968
Event = Queue.submit([&](handler &CGH) {
70-
CGH.depends_on(Event);
7169
CGH.ext_oneapi_graph(ExecGraph);
7270
});
7371
// Reset back to original buffers

sycl/test-e2e/Graph/Explicit/whole_update_double_buffer.cpp sycl/test-e2e/Graph/Update/Explicit/whole_update_double_buffer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
#define GRAPH_E2E_EXPLICIT
99

10-
#include "../Inputs/whole_update_double_buffer.cpp"
10+
#include "../../Inputs/whole_update_double_buffer.cpp"

sycl/test-e2e/Graph/Explicit/whole_update_subgraph.cpp sycl/test-e2e/Graph/Update/Explicit/whole_update_subgraph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
#define GRAPH_E2E_EXPLICIT
1111

12-
#include "../Inputs/whole_update_subgraph.cpp"
12+
#include "../../Inputs/whole_update_subgraph.cpp"

sycl/test-e2e/Graph/Explicit/whole_update_usm.cpp sycl/test-e2e/Graph/Update/Explicit/whole_update_usm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
#define GRAPH_E2E_EXPLICIT
99

10-
#include "../Inputs/whole_update_usm.cpp"
10+
#include "../../Inputs/whole_update_usm.cpp"

sycl/test-e2e/Graph/RecordReplay/whole_update_double_buffer.cpp sycl/test-e2e/Graph/Update/RecordReplay/whole_update_double_buffer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
#define GRAPH_E2E_RECORD_REPLAY
99

10-
#include "../Inputs/whole_update_double_buffer.cpp"
10+
#include "../../Inputs/whole_update_double_buffer.cpp"

sycl/test-e2e/Graph/RecordReplay/whole_update_subgraph.cpp sycl/test-e2e/Graph/Update/RecordReplay/whole_update_subgraph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
#define GRAPH_E2E_RECORD_REPLAY
1111

12-
#include "../Inputs/whole_update_subgraph.cpp"
12+
#include "../../Inputs/whole_update_subgraph.cpp"

sycl/test-e2e/Graph/RecordReplay/whole_update_usm.cpp sycl/test-e2e/Graph/Update/RecordReplay/whole_update_usm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
#define GRAPH_E2E_RECORD_REPLAY
1111

12-
#include "../Inputs/whole_update_usm.cpp"
12+
#include "../../Inputs/whole_update_usm.cpp"

sycl/unittests/Extensions/CommandGraph/Update.cpp

+28-3
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,34 @@ TEST_F(WholeGraphUpdateTest, MissingEdges) {
290290
EXPECT_THROW(GraphExec.update(UpdateGraph), sycl::exception);
291291
}
292292

293-
TEST_F(WholeGraphUpdateTest, WrongOrderEdges) {
293+
TEST_F(WholeGraphUpdateTest, DISABLED_WrongOrderNodes) {
294+
// Test that using an update graph with nodes added in a different order
295+
// results in an error.
296+
297+
auto NodeA = Graph.add(EmptyKernel);
298+
auto NodeB =
299+
Graph.add(EmptyKernel, experimental::property::node::depends_on(NodeA));
300+
auto NodeC =
301+
Graph.add(EmptyKernel, experimental::property::node::depends_on(NodeA));
302+
auto NodeD = Graph.add(
303+
EmptyKernel, experimental::property::node::depends_on(NodeB, NodeC));
304+
305+
auto UpdateNodeA = UpdateGraph.add(EmptyKernel);
306+
auto UpdateNodeC = UpdateGraph.add(
307+
EmptyKernel, experimental::property::node::depends_on(UpdateNodeA));
308+
auto UpdateNodeB = UpdateGraph.add(
309+
EmptyKernel, experimental::property::node::depends_on(UpdateNodeA));
310+
auto UpdateNodeD = UpdateGraph.add(
311+
EmptyKernel,
312+
experimental::property::node::depends_on(UpdateNodeB, UpdateNodeC));
313+
314+
auto GraphExec = Graph.finalize(experimental::property::graph::updatable{});
315+
EXPECT_THROW(GraphExec.update(UpdateGraph), sycl::exception);
316+
}
317+
318+
TEST_F(WholeGraphUpdateTest, DISABLED_WrongOrderEdges) {
294319
// Test that using an update graph with edges added in a different order
295-
// does not result in an error.
320+
// results in an error.
296321

297322
auto NodeA = Graph.add(EmptyKernel);
298323
auto NodeB = Graph.add(EmptyKernel);
@@ -316,7 +341,7 @@ TEST_F(WholeGraphUpdateTest, WrongOrderEdges) {
316341
UpdateGraph.make_edge(UpdateNodeB, UpdateNodeD);
317342

318343
auto GraphExec = Graph.finalize(experimental::property::graph::updatable{});
319-
EXPECT_NO_THROW(GraphExec.update(UpdateGraph));
344+
EXPECT_THROW(GraphExec.update(UpdateGraph), sycl::exception);
320345
}
321346

322347
TEST_F(WholeGraphUpdateTest, UnsupportedNodeType) {

0 commit comments

Comments
 (0)