From 4b1e56154c27d300c1d034da44a0ab66b6360273 Mon Sep 17 00:00:00 2001 From: Ben Tracy Date: Tue, 25 Mar 2025 13:29:05 +0000 Subject: [PATCH] [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 --- sycl/source/detail/graph_impl.cpp | 40 +++++++++++++++++-- .../Extensions/CommandGraph/Update.cpp | 2 +- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/sycl/source/detail/graph_impl.cpp b/sycl/source/detail/graph_impl.cpp index 1bb649e2b9459..6dfa8335115f8 100644 --- a/sycl/source/detail/graph_impl.cpp +++ b/sycl/source/detail/graph_impl.cpp @@ -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; diff --git a/sycl/unittests/Extensions/CommandGraph/Update.cpp b/sycl/unittests/Extensions/CommandGraph/Update.cpp index b943b9c43dd98..dc2bd0bb3e1ca 100644 --- a/sycl/unittests/Extensions/CommandGraph/Update.cpp +++ b/sycl/unittests/Extensions/CommandGraph/Update.cpp @@ -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);