Skip to content

Commit 5c53acd

Browse files
[SYCL][Graph] Improve multithread e2e tests (#11361)
Multihtread `finalize.cpp` e2e was written to test both finalize and submit processes. This test was based on strong assumptions about backend's kernel ordering, and was unstable. Since the behaviour of the finalize process in multi-threaded environment is already tested by a unitest, we (re)focused this test to verify concurrent submissions only. The test is therefore renamed submit.cpp
1 parent 7e2ca27 commit 5c53acd

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

sycl/test-e2e/Graph/Threading/finalize.cpp renamed to sycl/test-e2e/Graph/Threading/submit.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55
//
66
// CHECK-NOT: LEAK
77

8-
// Test finalizing and submitting a graph in a threaded situation.
8+
// Test submitting a graph in a threaded situation.
99
// The second run is to check that there are no leaks reported with the embedded
1010
// ZE_DEBUG=4 testing capability.
1111

12+
// Note that we do not check the outputs becuse multiple concurrent executions
13+
// is indeterministic (and depends on the backend command management).
14+
// However, this test verifies that concurrent graph submissions do not trigger
15+
// errors nor memory leaks.
16+
1217
#include "../graph_common.hpp"
1318

1419
#include <thread>
@@ -44,19 +49,26 @@ int main() {
4449
run_kernels_usm(Queue, Size, PtrA, PtrB, PtrC);
4550
Graph.end_recording();
4651

52+
std::vector<exp_ext::command_graph<exp_ext::graph_state::executable>>
53+
GraphExecs;
54+
for (unsigned i = 0; i < NumThreads; ++i) {
55+
GraphExecs.push_back(Graph.finalize());
56+
}
57+
4758
Barrier SyncPoint{NumThreads};
4859

49-
auto FinalizeGraph = [&](int ThreadNum) {
60+
auto SubmitGraph = [&](int ThreadNum) {
5061
SyncPoint.wait();
51-
auto GraphExec = Graph.finalize();
52-
Queue.submit([&](sycl::handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
62+
Queue.submit([&](sycl::handler &CGH) {
63+
CGH.ext_oneapi_graph(GraphExecs[ThreadNum]);
64+
});
5365
};
5466

5567
std::vector<std::thread> Threads;
5668
Threads.reserve(NumThreads);
5769

5870
for (unsigned i = 0; i < NumThreads; ++i) {
59-
Threads.emplace_back(FinalizeGraph, i);
71+
Threads.emplace_back(SubmitGraph, i);
6072
}
6173

6274
for (unsigned i = 0; i < NumThreads; ++i) {
@@ -65,18 +77,9 @@ int main() {
6577

6678
Queue.wait_and_throw();
6779

68-
Queue.copy(PtrA, DataA.data(), Size);
69-
Queue.copy(PtrB, DataB.data(), Size);
70-
Queue.copy(PtrC, DataC.data(), Size);
71-
Queue.wait_and_throw();
72-
7380
free(PtrA, Queue);
7481
free(PtrB, Queue);
7582
free(PtrC, Queue);
7683

77-
assert(ReferenceA == DataA);
78-
assert(ReferenceB == DataB);
79-
assert(ReferenceC == DataC);
80-
8184
return 0;
8285
}

0 commit comments

Comments
 (0)