Skip to content

Commit 7b85fb2

Browse files
committed
[SYCL][Graph] Fix queue recording barrier to different graphs
Recording barrier submissions to from the same queue to a different graph current produces the following error with added regression test: ``` Terminate called after throwing an instance of 'sycl::_V1::exception' what(): Graph nodes cannot depend on events from another graph. ``` This is because the queue implementation doesn't clear all the state around what the last queue submission was between graph recordings. Fixed by clearing all members of the barrier book keeping struct in the queue.
1 parent 57b8401 commit 7b85fb2

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

sycl/source/detail/queue_impl.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ class queue_impl {
732732
std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> Graph) {
733733
std::lock_guard<std::mutex> Lock(MMutex);
734734
MGraph = Graph;
735-
MExtGraphDeps.LastEventPtr = nullptr;
735+
MExtGraphDeps.reset();
736736
}
737737

738738
std::shared_ptr<ext::oneapi::experimental::detail::graph_impl>
@@ -938,6 +938,12 @@ class queue_impl {
938938
// ordering
939939
std::vector<EventImplPtr> UnenqueuedCmdEvents;
940940
EventImplPtr LastBarrier;
941+
942+
void reset() {
943+
LastEventPtr = nullptr;
944+
UnenqueuedCmdEvents.clear();
945+
LastBarrier = nullptr;
946+
}
941947
} MDefaultGraphDeps, MExtGraphDeps;
942948

943949
const bool MIsInorder;

sycl/unittests/Extensions/CommandGraph/Regressions.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,30 @@ TEST_F(CommandGraphTest, AccessorModeRegression) {
5858
EXPECT_EQ(NodeC.get_predecessors().size(), 0ul);
5959
EXPECT_EQ(NodeC.get_successors().size(), 0ul);
6060
}
61+
62+
TEST_F(CommandGraphTest, QueueRecordBarrierMultipleGraph) {
63+
// Test that using barriers recorded from the same queue to
64+
// different graphs.
65+
66+
Graph.begin_recording(Queue);
67+
auto NodeKernel = Queue.submit(
68+
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<>>([]() {}); });
69+
Queue.ext_oneapi_submit_barrier({NodeKernel});
70+
Graph.end_recording(Queue);
71+
72+
experimental::command_graph<experimental::graph_state::modifiable> GraphB{
73+
Queue};
74+
GraphB.begin_recording(Queue);
75+
auto NodeKernelB = Queue.submit(
76+
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<>>([]() {}); });
77+
Queue.ext_oneapi_submit_barrier({NodeKernelB});
78+
GraphB.end_recording(Queue);
79+
80+
experimental::command_graph<experimental::graph_state::modifiable> GraphC{
81+
Queue};
82+
GraphC.begin_recording(Queue);
83+
auto NodeKernelC = Queue.submit(
84+
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<>>([]() {}); });
85+
Queue.ext_oneapi_submit_barrier();
86+
GraphC.end_recording(Queue);
87+
}

0 commit comments

Comments
 (0)