Skip to content

[SYCL][Graph] Improve unsupported node update error #17637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions sycl/source/detail/graph_impl.cpp
Original file line number Diff line number Diff line change
@@ -32,6 +32,36 @@ namespace experimental {
namespace detail {

namespace {
/// Return a string representation of a given node_type
inline const char *nodeTypeToString(node_type NodeType) {
switch (NodeType) {
case node_type::empty:
return "empty";
case node_type::subgraph:
return "subgraph";
case node_type::kernel:
return "kernel";
case node_type::memcpy:
return "memcpy";
case node_type::memset:
return "memset";
case node_type::memfill:
return "memfill";
case node_type::prefetch:
return "prefetch";
case node_type::memadvise:
return "memadvise";
case node_type::ext_oneapi_barrier:
return "ext_oneapi_barrier";
case node_type::host_task:
return "host_task";
case node_type::native_command:
return "native_command";
}
assert(false && "Unhandled node type");
return {};
}

/// Topologically sorts the graph in order to schedule nodes for execution.
/// This implementation is based on Kahn's algorithm which uses a Breadth-first
/// search approach.
@@ -1444,10 +1474,12 @@ bool exec_graph_impl::needsScheduledUpdate(
}

if (!Node->isUpdatable()) {
throw sycl::exception(
errc::invalid,
"Unsupported node type for update. Only kernel, host_task, "
"barrier and empty nodes are supported.");
std::string ErrorString = "node_type::";
ErrorString += nodeTypeToString(Node->MNodeType);
ErrorString +=
" nodes are not supported for update. Only kernel, host_task, "
"barrier and empty nodes are supported.";
throw sycl::exception(errc::invalid, ErrorString);
}

if (const auto &CG = Node->MCommandGroup;
2 changes: 1 addition & 1 deletion sycl/unittests/Extensions/CommandGraph/Update.cpp
Original file line number Diff line number Diff line change
@@ -325,7 +325,7 @@ TEST_F(WholeGraphUpdateTest, UnsupportedNodeType) {
EmptyKernel, experimental::property::node::depends_on(UpdateNodeA));
auto UpdateNodeC = UpdateGraph.add(
EmptyKernel, experimental::property::node::depends_on(UpdateNodeA));
auto UpdateNodeD = Graph.add(
auto UpdateNodeD = UpdateGraph.add(
[&](handler &CGH) {
auto Acc = Buffer.get_access(CGH);
CGH.fill(Acc, 1);