From f2c20126aead1391c147a723d6badd055da44cef Mon Sep 17 00:00:00 2001 From: Pablo Reble Date: Tue, 16 Sep 2025 11:35:56 -0700 Subject: [PATCH 1/4] Do not create placeholder queue with exec graph. --- sycl/source/detail/graph/graph_impl.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sycl/source/detail/graph/graph_impl.cpp b/sycl/source/detail/graph/graph_impl.cpp index 07e8994df57f6..665e6d26361f9 100644 --- a/sycl/source/detail/graph/graph_impl.cpp +++ b/sycl/source/detail/graph/graph_impl.cpp @@ -869,11 +869,7 @@ void exec_graph_impl::createCommandBuffers( exec_graph_impl::exec_graph_impl(sycl::context Context, const std::shared_ptr &GraphImpl, const property_list &PropList) - : MSchedule(), MGraphImpl(GraphImpl), MSyncPoints(), - MQueueImpl(sycl::detail::queue_impl::create( - *sycl::detail::getSyclObjImpl(GraphImpl->getDevice()), - *sycl::detail::getSyclObjImpl(Context), sycl::async_handler{}, - sycl::property_list{})), + : MSchedule(), MGraphImpl(GraphImpl), MSyncPoints(), MQueueImpl(), MDevice(GraphImpl->getDevice()), MContext(Context), MRequirements(), MSchedulerDependencies(), MIsUpdatable(PropList.has_property()), From 82b56636044a6fc4e1ff60b302ae9936dffcbfa4 Mon Sep 17 00:00:00 2001 From: Pablo Reble Date: Tue, 16 Sep 2025 13:03:02 -0700 Subject: [PATCH 2/4] Disable get_native_queue for graphs --- sycl/source/interop_handle.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sycl/source/interop_handle.cpp b/sycl/source/interop_handle.cpp index 77bf655e9c12d..91cd9526e8498 100644 --- a/sycl/source/interop_handle.cpp +++ b/sycl/source/interop_handle.cpp @@ -60,7 +60,9 @@ ur_native_handle_t interop_handle::getNativeContext() const { ur_native_handle_t interop_handle::getNativeQueue(int32_t &NativeHandleDesc) const { - return MQueue->getNative(NativeHandleDesc); + if (MQueue != nullptr) + return MQueue->getNative(NativeHandleDesc); + return 0; } ur_native_handle_t interop_handle::getNativeGraph() const { From d85728220082b5ba64fe0edbd2a6ecf78e547894 Mon Sep 17 00:00:00 2001 From: Pablo Reble Date: Thu, 18 Sep 2025 11:28:01 -0700 Subject: [PATCH 3/4] Use recording queue if available for executable graph --- sycl/source/detail/graph/graph_impl.cpp | 18 +++++++++++++++++- sycl/source/detail/graph/graph_impl.hpp | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sycl/source/detail/graph/graph_impl.cpp b/sycl/source/detail/graph/graph_impl.cpp index 665e6d26361f9..443dee6f439a7 100644 --- a/sycl/source/detail/graph/graph_impl.cpp +++ b/sycl/source/detail/graph/graph_impl.cpp @@ -549,6 +549,13 @@ graph_impl::add(std::shared_ptr &DynCGImpl, return NodeImpl; } +std::weak_ptr graph_impl::getQueue() const { + std::weak_ptr Return{}; + if (!MRecordingQueues.empty()) + Return = *(MRecordingQueues.begin()); + return Return; +} + void graph_impl::addQueue(sycl::detail::queue_impl &RecordingQueue) { MRecordingQueues.insert(RecordingQueue.weak_from_this()); } @@ -869,7 +876,7 @@ void exec_graph_impl::createCommandBuffers( exec_graph_impl::exec_graph_impl(sycl::context Context, const std::shared_ptr &GraphImpl, const property_list &PropList) - : MSchedule(), MGraphImpl(GraphImpl), MSyncPoints(), MQueueImpl(), + : MSchedule(), MGraphImpl(GraphImpl), MSyncPoints(), MDevice(GraphImpl->getDevice()), MContext(Context), MRequirements(), MSchedulerDependencies(), MIsUpdatable(PropList.has_property()), @@ -889,6 +896,15 @@ exec_graph_impl::exec_graph_impl(sycl::context Context, } // Copy nodes from GraphImpl and merge any subgraph nodes into this graph. duplicateNodes(); + + if (auto PlaceholderQueuePtr = GraphImpl->getQueue().lock()) { + MQueueImpl = PlaceholderQueuePtr; + } else { + MQueueImpl = sycl::detail::queue_impl::create( + *sycl::detail::getSyclObjImpl(GraphImpl->getDevice()), + *sycl::detail::getSyclObjImpl(Context), sycl::async_handler{}, + sycl::property_list{}); + } } exec_graph_impl::~exec_graph_impl() { diff --git a/sycl/source/detail/graph/graph_impl.hpp b/sycl/source/detail/graph/graph_impl.hpp index eedfcf0506bf3..9075aade8e877 100644 --- a/sycl/source/detail/graph/graph_impl.hpp +++ b/sycl/source/detail/graph/graph_impl.hpp @@ -172,6 +172,8 @@ class graph_impl : public std::enable_shared_from_this { node_impl &add(std::shared_ptr &DynCGImpl, nodes_range Deps); + std::weak_ptr getQueue() const; + /// Add a queue to the set of queues which are currently recording to this /// graph. /// @param RecordingQueue Queue to add to set. From 7cfd0dd88b586a50b8ffcc9c68f22bd4f9d16eda Mon Sep 17 00:00:00 2001 From: Pablo Reble Date: Mon, 6 Oct 2025 12:21:56 -0700 Subject: [PATCH 4/4] Addressing reviewers feedback --- sycl/source/detail/graph/graph_impl.cpp | 8 ++++---- sycl/source/detail/graph/graph_impl.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sycl/source/detail/graph/graph_impl.cpp b/sycl/source/detail/graph/graph_impl.cpp index 443dee6f439a7..19e8364876df4 100644 --- a/sycl/source/detail/graph/graph_impl.cpp +++ b/sycl/source/detail/graph/graph_impl.cpp @@ -549,10 +549,10 @@ graph_impl::add(std::shared_ptr &DynCGImpl, return NodeImpl; } -std::weak_ptr graph_impl::getQueue() const { - std::weak_ptr Return{}; +std::shared_ptr graph_impl::getQueue() const { + std::shared_ptr Return{}; if (!MRecordingQueues.empty()) - Return = *(MRecordingQueues.begin()); + Return = MRecordingQueues.begin()->lock(); return Return; } @@ -897,7 +897,7 @@ exec_graph_impl::exec_graph_impl(sycl::context Context, // Copy nodes from GraphImpl and merge any subgraph nodes into this graph. duplicateNodes(); - if (auto PlaceholderQueuePtr = GraphImpl->getQueue().lock()) { + if (auto PlaceholderQueuePtr = GraphImpl->getQueue()) { MQueueImpl = PlaceholderQueuePtr; } else { MQueueImpl = sycl::detail::queue_impl::create( diff --git a/sycl/source/detail/graph/graph_impl.hpp b/sycl/source/detail/graph/graph_impl.hpp index 9075aade8e877..cabca62958e19 100644 --- a/sycl/source/detail/graph/graph_impl.hpp +++ b/sycl/source/detail/graph/graph_impl.hpp @@ -172,7 +172,7 @@ class graph_impl : public std::enable_shared_from_this { node_impl &add(std::shared_ptr &DynCGImpl, nodes_range Deps); - std::weak_ptr getQueue() const; + std::shared_ptr getQueue() const; /// Add a queue to the set of queues which are currently recording to this /// graph.