Skip to content

Commit e826b83

Browse files
committed
Use recording queue if available for executable graph
1 parent e225e4a commit e826b83

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

sycl/source/detail/graph/graph_impl.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,13 @@ graph_impl::add(std::shared_ptr<dynamic_command_group_impl> &DynCGImpl,
549549
return NodeImpl;
550550
}
551551

552+
std::weak_ptr<sycl::detail::queue_impl> graph_impl::getQueue() const {
553+
std::weak_ptr<sycl::detail::queue_impl> Return{};
554+
if (!MRecordingQueues.empty())
555+
Return = *(MRecordingQueues.begin());
556+
return Return;
557+
}
558+
552559
void graph_impl::addQueue(sycl::detail::queue_impl &RecordingQueue) {
553560
MRecordingQueues.insert(RecordingQueue.weak_from_this());
554561
}
@@ -870,7 +877,7 @@ void exec_graph_impl::createCommandBuffers(
870877
exec_graph_impl::exec_graph_impl(sycl::context Context,
871878
const std::shared_ptr<graph_impl> &GraphImpl,
872879
const property_list &PropList)
873-
: MSchedule(), MGraphImpl(GraphImpl), MSyncPoints(), MQueueImpl(),
880+
: MSchedule(), MGraphImpl(GraphImpl), MSyncPoints(),
874881
MDevice(GraphImpl->getDevice()), MContext(Context), MRequirements(),
875882
MSchedulerDependencies(),
876883
MIsUpdatable(PropList.has_property<property::graph::updatable>()),
@@ -890,6 +897,15 @@ exec_graph_impl::exec_graph_impl(sycl::context Context,
890897
}
891898
// Copy nodes from GraphImpl and merge any subgraph nodes into this graph.
892899
duplicateNodes();
900+
901+
if (auto PlaceholderQueuePtr = GraphImpl->getQueue().lock()) {
902+
MQueueImpl = PlaceholderQueuePtr;
903+
} else {
904+
MQueueImpl = sycl::detail::queue_impl::create(
905+
*sycl::detail::getSyclObjImpl(GraphImpl->getDevice()),
906+
*sycl::detail::getSyclObjImpl(Context), sycl::async_handler{},
907+
sycl::property_list{});
908+
}
893909
}
894910

895911
exec_graph_impl::~exec_graph_impl() {

sycl/source/detail/graph/graph_impl.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
172172
node_impl &add(std::shared_ptr<dynamic_command_group_impl> &DynCGImpl,
173173
nodes_range Deps);
174174

175+
std::weak_ptr<sycl::detail::queue_impl> getQueue() const;
176+
175177
/// Add a queue to the set of queues which are currently recording to this
176178
/// graph.
177179
/// @param RecordingQueue Queue to add to set.

0 commit comments

Comments
 (0)