Skip to content

Commit 4ddb952

Browse files
[SYCL][Graph] Fix unit test multithread finalize bug (#11006)
Adds a mutex to prevent races when inserting data into the STL map. This PR addresses issue #10985 (i.e. it fixes the post-commit CI fail of PR #10964 (https://github.com/intel/llvm/actions/runs/6001360490/job/16275376437)
1 parent d5c094f commit 4ddb952

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sycl/unittests/Extensions/CommandGraph.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1899,18 +1899,21 @@ TEST_F(MultiThreadGraphTest, RecordAddNodesInOrderQueue) {
18991899
TEST_F(MultiThreadGraphTest, Finalize) {
19001900
addKernels(Graph);
19011901

1902+
std::mutex MutexMap;
1903+
19021904
std::map<int,
19031905
experimental::command_graph<experimental::graph_state::executable>>
19041906
GraphsExecMap;
19051907
auto FinalizeGraph = [&](int ThreadNum) {
19061908
SyncPoint.wait();
19071909
auto GraphExec = Graph.finalize();
1910+
Queue.submit([&](sycl::handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
19081911

1912+
std::lock_guard<std::mutex> Guard(MutexMap);
19091913
GraphsExecMap.insert(
19101914
std::map<int, experimental::command_graph<
19111915
experimental::graph_state::executable>>::
19121916
value_type(ThreadNum, GraphExec));
1913-
Queue.submit([&](sycl::handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
19141917
};
19151918

19161919
for (unsigned i = 0; i < NumThreads; ++i) {

0 commit comments

Comments
 (0)