Skip to content

Commit 3d86438

Browse files
[SYCL][Graph] Bugfix test e2e Graph/submission_while_executing.cpp (#11303)
The test behaviour was indeterministic. This PR improves the test to make it deterministic. The data size has also been reduced to avoid risk of an "out of memory" exception. Addresses Issue: #11277 #11277
1 parent 04fb7ec commit 3d86438

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

sycl/test-e2e/Graph/submission_while_executing.cpp

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// RUN: %{build} -o %t.out
33
// RUN: %{run} %t.out
44
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
5-
6-
// https://github.com/intel/llvm/issues/11277:
7-
// UNSUPPORTED: windows
85
//
96
// CHECK-NOT: LEAK
107

@@ -14,13 +11,19 @@
1411

1512
#include "graph_common.hpp"
1613

14+
inline bool
15+
isSubmittedOrRunningCommand(sycl::info::event_command_status Status) {
16+
return ((Status == sycl::info::event_command_status::submitted) ||
17+
(Status == sycl::info::event_command_status::running));
18+
}
19+
1720
int main() {
1821
queue Queue{{sycl::ext::intel::property::queue::no_immediate_command_list{}}};
1922

2023
using T = int;
2124

2225
size_t LargeSize =
23-
1000000; // we use large Size to increase the kernel execution time
26+
10000; // we use large Size to increase the kernel execution time
2427
size_t NumIterations = 10;
2528
size_t SuccessfulSubmissions = 0;
2629

@@ -56,26 +59,46 @@ int main() {
5659
}
5760

5861
// Concurrent Submissions
59-
sycl::event Event;
60-
sycl::info::event_command_status PreEventInfo =
62+
sycl::event PreEvent, Event;
63+
sycl::info::event_command_status PreEventInfoStateBefore =
64+
sycl::info::event_command_status::ext_oneapi_unknown;
65+
sycl::info::event_command_status PreEventInfoStateAfter =
6166
sycl::info::event_command_status::ext_oneapi_unknown;
62-
std::error_code ErrorCode = make_error_code(sycl::errc::success);
6367
for (unsigned i = 0; i < NumIterations; ++i) {
68+
std::error_code ErrorCode = make_error_code(sycl::errc::success);
69+
PreEventInfoStateBefore =
70+
PreEvent.get_info<sycl::info::event::command_execution_status>();
71+
72+
// Submit the kernel
6473
try {
6574
Event =
6675
Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
6776
} catch (const sycl::exception &e) {
6877
ErrorCode = e.code();
6978
}
70-
if ((PreEventInfo == sycl::info::event_command_status::submitted) ||
71-
(PreEventInfo == sycl::info::event_command_status::running)) {
79+
PreEventInfoStateAfter =
80+
PreEvent.get_info<sycl::info::event::command_execution_status>();
81+
82+
// Check submission status
83+
if (isSubmittedOrRunningCommand(PreEventInfoStateBefore) &&
84+
isSubmittedOrRunningCommand(PreEventInfoStateAfter)) {
7285
assert(ErrorCode == sycl::errc::invalid);
73-
} else {
86+
} else if (PreEventInfoStateBefore ==
87+
sycl::info::event_command_status::complete) {
7488
// Submission has succeeded
7589
SuccessfulSubmissions++;
90+
PreEvent = Event;
91+
} else {
92+
// We cannot be sure of the state of the previous task when the current
93+
// submission occurred because `PreEventInfoStateBefore` and
94+
// `PreEventInfoStateAfter` indicate different status We therefore only
95+
// read the submission status and increment the number of successful
96+
// submissions if the submission was successful
97+
if (ErrorCode == sycl::errc::success) {
98+
SuccessfulSubmissions++;
99+
PreEvent = Event;
100+
}
76101
}
77-
PreEventInfo =
78-
Event.get_info<sycl::info::event::command_execution_status>();
79102
}
80103
Queue.wait_and_throw();
81104

@@ -91,6 +114,7 @@ int main() {
91114
// Compute the reference based on the total number of successful executions
92115
calculate_reference_data(NumIterations + SuccessfulSubmissions, LargeSize,
93116
ReferenceA, ReferenceB, ReferenceC);
117+
94118
assert(ReferenceA == DataA);
95119
assert(ReferenceB == DataB);
96120
assert(ReferenceC == DataC);

0 commit comments

Comments
 (0)