Skip to content

Commit f5bbf33

Browse files
BensuoreblejulianmiEwanC
authored
[SYCL][Graph] E2E tests for SYCL Graphs (4/4) (#10216)
# E2E Tests for SYCL Graphs This is the fourth patch of a series that adds support for an [experimental command graph extension](#5626) A snapshot of the complete work can be seen in draft PR #9375 which has support all the specification defined ways of adding nodes and edges to the graph, including both Explicit and Record & Replay graph construction. The two types of nodes currently implemented are kernel execution and memcpy commands. See https://github.com/reble/llvm#implementation-status for the status of our total work. ## Scope This fourth patch focuses on adding E2E tests for SYCL Graphs, covering the following: * Record and Replay API based tests. * Explicit API based tests. * Thread safety tests. * A small amount of miscellaneous tests. ## Following Split PRs Future follow-up PRs with the remainder of our work on the extension will include: * NFC changes - Design doc. ## Authors Co-authored-by: Pablo Reble <[email protected]> Co-authored-by: Julian Miller <[email protected]> Co-authored-by: Ben Tracy <[email protected]> Co-authored-by: Ewan Crawford <[email protected]> Co-authored-by: Maxime France-Pillois <[email protected]>
1 parent 6b67874 commit f5bbf33

File tree

148 files changed

+5653
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+5653
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
// Expected Fail as exception not implemented yet
10+
// XFAIL: *
11+
12+
// Tests attempting to add a node to a command_graph while it is being
13+
// recorded to by a queue is an error.
14+
15+
#include "../graph_common.hpp"
16+
17+
int main() {
18+
queue Queue;
19+
20+
bool Success = false;
21+
22+
exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()};
23+
Graph.begin_recording(Queue);
24+
25+
try {
26+
Graph.add([&](handler &CGH) {});
27+
} catch (sycl::exception &E) {
28+
auto StdErrc = E.code().value();
29+
if (StdErrc == static_cast<int>(errc::invalid)) {
30+
Success = true;
31+
}
32+
}
33+
34+
Graph.end_recording();
35+
assert(Success);
36+
return 0;
37+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/add_nodes_after_finalize.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/basic_buffer.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/basic_usm.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/basic_usm_host.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/basic_usm_mixed.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/basic_usm_shared.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/basic_usm_system.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_copy.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_copy_2d.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_copy_host2target.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_copy_host2target_2d.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_copy_host2target_offset.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_copy_offsets.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_copy_target2host.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_copy_target2host_2d.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_copy_target2host_offset.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/buffer_ordering.cpp"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
// Tests that an event returned from adding a graph node using the queue
10+
// recording API can be passed to `handler::depends_on` inside a node
11+
// added using the explicit API. This should create a graph edge.
12+
13+
#include "../graph_common.hpp"
14+
15+
int main() {
16+
17+
queue Queue;
18+
19+
exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()};
20+
21+
const size_t N = 10;
22+
float *Arr = malloc_device<float>(N, Queue);
23+
24+
Graph.begin_recording(Queue);
25+
// `Event` corresponds to a graph node
26+
event Event = Queue.submit([&](handler &CGH) {
27+
CGH.parallel_for(range<1>{N}, [=](id<1> idx) { Arr[idx] = 42.0f; });
28+
});
29+
Graph.end_recording(Queue);
30+
31+
Graph.add([&](handler &CGH) {
32+
CGH.depends_on(Event); // creates edge to recorded graph node
33+
CGH.parallel_for(range<1>{N}, [=](id<1> idx) { Arr[idx] *= 2.0f; });
34+
});
35+
36+
auto ExecGraph = Graph.finalize();
37+
38+
Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }).wait();
39+
40+
constexpr float ref = 42.0f * 2.0f;
41+
std::vector<float> Output(N);
42+
Queue.memcpy(Output.data(), Arr, N * sizeof(float)).wait();
43+
for (int i = 0; i < N; i++)
44+
assert(Output[i] == ref);
45+
46+
sycl::free(Arr, Queue);
47+
48+
return 0;
49+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
// Expected fail as reduction support is not complete.
10+
// XFAIL: *
11+
12+
#define GRAPH_E2E_EXPLICIT
13+
14+
#include "../Inputs/dotp_buffer_reduction.cpp"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
// Expected fail as reduction support is not complete.
10+
// XFAIL: *
11+
12+
#define GRAPH_E2E_EXPLICIT
13+
14+
#include "../Inputs/dotp_usm_reduction.cpp"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
// Expected fail as executable graph update isn't implemented yet
10+
// XFAIL: *
11+
12+
#define GRAPH_E2E_EXPLICIT
13+
14+
#include "../Inputs/double_buffer.cpp"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: level_zero, gpu
2+
// RUN: %{build} -o %t.out
3+
// RUN: %{run} %t.out
4+
// Extra run to check for leaks in Level Zero using ZE_DEBUG
5+
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
6+
//
7+
// CHECK-NOT: LEAK
8+
9+
#define GRAPH_E2E_EXPLICIT
10+
11+
#include "../Inputs/empty_node.cpp"

0 commit comments

Comments
 (0)