Skip to content

Commit 4b1e561

Browse files
BensuoEwanC
authored andcommitted
[SYCL][Graph] Improve unsupported node update error
- Include node type in error message - Fix unit test triggering topology error instead of unsupported node type error
1 parent d9ba32d commit 4b1e561

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

sycl/source/detail/graph_impl.cpp

+36-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,36 @@ namespace experimental {
3232
namespace detail {
3333

3434
namespace {
35+
/// Return a string representation of a given node_type
36+
inline const char *nodeTypeToString(node_type NodeType) {
37+
switch (NodeType) {
38+
case node_type::empty:
39+
return "empty";
40+
case node_type::subgraph:
41+
return "subgraph";
42+
case node_type::kernel:
43+
return "kernel";
44+
case node_type::memcpy:
45+
return "memcpy";
46+
case node_type::memset:
47+
return "memset";
48+
case node_type::memfill:
49+
return "memfill";
50+
case node_type::prefetch:
51+
return "prefetch";
52+
case node_type::memadvise:
53+
return "memadvise";
54+
case node_type::ext_oneapi_barrier:
55+
return "ext_oneapi_barrier";
56+
case node_type::host_task:
57+
return "host_task";
58+
case node_type::native_command:
59+
return "native_command";
60+
}
61+
assert(false && "Unhandled node type");
62+
return {};
63+
}
64+
3565
/// Topologically sorts the graph in order to schedule nodes for execution.
3666
/// This implementation is based on Kahn's algorithm which uses a Breadth-first
3767
/// search approach.
@@ -1444,10 +1474,12 @@ bool exec_graph_impl::needsScheduledUpdate(
14441474
}
14451475

14461476
if (!Node->isUpdatable()) {
1447-
throw sycl::exception(
1448-
errc::invalid,
1449-
"Unsupported node type for update. Only kernel, host_task, "
1450-
"barrier and empty nodes are supported.");
1477+
std::string ErrorString = "node_type::";
1478+
ErrorString += nodeTypeToString(Node->MNodeType);
1479+
ErrorString +=
1480+
" nodes are not supported for update. Only kernel, host_task, "
1481+
"barrier and empty nodes are supported.";
1482+
throw sycl::exception(errc::invalid, ErrorString);
14511483
}
14521484

14531485
if (const auto &CG = Node->MCommandGroup;

sycl/unittests/Extensions/CommandGraph/Update.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ TEST_F(WholeGraphUpdateTest, UnsupportedNodeType) {
325325
EmptyKernel, experimental::property::node::depends_on(UpdateNodeA));
326326
auto UpdateNodeC = UpdateGraph.add(
327327
EmptyKernel, experimental::property::node::depends_on(UpdateNodeA));
328-
auto UpdateNodeD = Graph.add(
328+
auto UpdateNodeD = UpdateGraph.add(
329329
[&](handler &CGH) {
330330
auto Acc = Buffer.get_access(CGH);
331331
CGH.fill(Acc, 1);

0 commit comments

Comments
 (0)