Skip to content

Commit 09c1af5

Browse files
[SYCL][Graph] Fix memory leak multithreading Finalize test
'queue::submit' function is not thread-safe. Consequently, threads in Finalize test cannot safely submit their graph to the same queue (this generates sometimes memory leaks). This commit updates this test so that each thread submits its graph to a differentes queue.
1 parent 7292706 commit 09c1af5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sycl/test-e2e/Graph/Threading/finalize.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ int main() {
4646

4747
Barrier SyncPoint{NumThreads};
4848

49+
std::vector<queue> SubmissionQueues(NumThreads);
4950
auto FinalizeGraph = [&](int ThreadNum) {
5051
SyncPoint.wait();
5152
auto GraphExec = Graph.finalize();
52-
Queue.submit([&](sycl::handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
53+
SubmissionQueues[ThreadNum].submit(
54+
[&](sycl::handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
5355
};
5456

5557
std::vector<std::thread> Threads;
@@ -63,7 +65,9 @@ int main() {
6365
Threads[i].join();
6466
}
6567

66-
Queue.wait_and_throw();
68+
for (unsigned i = 0; i < NumThreads; ++i) {
69+
SubmissionQueues[i].wait_and_throw();
70+
}
6771

6872
Queue.copy(PtrA, DataA.data(), Size);
6973
Queue.copy(PtrB, DataB.data(), Size);

0 commit comments

Comments
 (0)