Skip to content

Commit d196c73

Browse files
EwanCBensuo
authored andcommitted
[SYCL][Graph] Regression Test for in-order queue submission
1 parent c9b9b56 commit d196c73

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// RUN: %{build} -o %t.out
2+
// RUN: %{run} %t.out
3+
// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG
4+
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
5+
// Extra run to check for immediate-command-list in Level Zero
6+
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
7+
8+
#include "../graph_common.hpp"
9+
10+
#include <sycl/properties/all_properties.hpp>
11+
12+
int main() {
13+
queue Queue1{sycl::property::queue::in_order{}};
14+
queue Queue2(Queue1.get_context(), Queue1.get_device(),
15+
sycl::property::queue::in_order());
16+
exp_ext::command_graph Graph{Queue1};
17+
18+
std::vector<float> Data(Size, 0.0f);
19+
20+
float *DevicePtr = sycl::malloc_device<float>(Size, Queue1);
21+
22+
Graph.begin_recording(Queue1);
23+
24+
Queue1.submit([&](handler &CGH) {
25+
CGH.memcpy(DevicePtr, Data.data(), Size * sizeof(float));
26+
});
27+
28+
Queue1.submit([&](handler &CGH) {
29+
CGH.parallel_for(sycl::range<1>(Size),
30+
[=](sycl::id<1> Id) { DevicePtr[Id] += 1.0f; });
31+
});
32+
33+
Graph.end_recording(Queue1);
34+
35+
auto GraphExec = Graph.finalize();
36+
37+
auto Event = Queue1.ext_oneapi_graph(GraphExec);
38+
39+
Queue2.submit([&](sycl::handler &CGH) {
40+
#if 1 // Setting to zero hides the fail
41+
CGH.depends_on({Event});
42+
#endif
43+
44+
#if 1 // Fail only appears with host-task
45+
CGH.host_task([=]() { volatile float b = 3.0; });
46+
#else
47+
CGH.parallel_for(sycl::range<1>(Size),
48+
[=](sycl::id<1> Id) { DevicePtr[Id] += 0.0f; });
49+
#endif
50+
});
51+
52+
std::vector<float> HostData(Size, 0.0f);
53+
Queue1.memcpy(HostData.data(), DevicePtr, Size * sizeof(float)).wait();
54+
for (size_t i = 0; i < Size; ++i) {
55+
assert(HostData[i] == 1.0f);
56+
}
57+
58+
sycl::free(DevicePtr, Queue1);
59+
60+
return 0;
61+
}

0 commit comments

Comments
 (0)