Skip to content

Commit c410b9a

Browse files
BensuoEwanC
andauthored
[SYCL][Graph] Improve unsupported node update error (#17637)
- Include node type in error message - Fix unit test triggering topology error instead of unsupported node type error Example output of new error: ``` terminate called after throwing an instance of 'sycl::_V1::exception' what(): node_type::memfill nodes are not supported for update. Only kernel, host_task, barrier and empty nodes are supported. ``` Co-authored-by: Ewan Crawford <ewan@codeplay.com>
1 parent 2a09e49 commit c410b9a

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

sycl/source/detail/graph_impl.cpp

Lines changed: 36 additions & 4 deletions
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.
@@ -1452,10 +1482,12 @@ bool exec_graph_impl::needsScheduledUpdate(
14521482
}
14531483

14541484
if (!Node->isUpdatable()) {
1455-
throw sycl::exception(
1456-
errc::invalid,
1457-
"Unsupported node type for update. Only kernel, host_task, "
1458-
"barrier and empty nodes are supported.");
1485+
std::string ErrorString = "node_type::";
1486+
ErrorString += nodeTypeToString(Node->MNodeType);
1487+
ErrorString +=
1488+
" nodes are not supported for update. Only kernel, host_task, "
1489+
"barrier and empty nodes are supported.";
1490+
throw sycl::exception(errc::invalid, ErrorString);
14591491
}
14601492

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

sycl/unittests/Extensions/CommandGraph/Update.cpp

Lines changed: 1 addition & 1 deletion
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)