Skip to content

Commit

Permalink
[SYCL][Graph] E2E tests for SYCL Graphs (4/4) (#10216)
Browse files Browse the repository at this point in the history
# 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]>
  • Loading branch information
Bensuo authored Jul 28, 2023
1 parent 6b67874 commit f5bbf33
Show file tree
Hide file tree
Showing 148 changed files with 5,653 additions and 0 deletions.
37 changes: 37 additions & 0 deletions sycl/test-e2e/Graph/Explicit/add_node_while_recording.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

// Expected Fail as exception not implemented yet
// XFAIL: *

// Tests attempting to add a node to a command_graph while it is being
// recorded to by a queue is an error.

#include "../graph_common.hpp"

int main() {
queue Queue;

bool Success = false;

exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()};
Graph.begin_recording(Queue);

try {
Graph.add([&](handler &CGH) {});
} catch (sycl::exception &E) {
auto StdErrc = E.code().value();
if (StdErrc == static_cast<int>(errc::invalid)) {
Success = true;
}
}

Graph.end_recording();
assert(Success);
return 0;
}
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/add_nodes_after_finalize.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/add_nodes_after_finalize.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/basic_buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/basic_buffer.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/basic_usm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/basic_usm.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/basic_usm_host.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/basic_usm_host.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/basic_usm_mixed.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/basic_usm_mixed.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/basic_usm_shared.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/basic_usm_shared.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/basic_usm_system.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/basic_usm_system.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_copy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_copy.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_copy_2d.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_copy_2d.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_copy_host2target.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_copy_host2target.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_copy_host2target_2d.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_copy_host2target_2d.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_copy_host2target_offset.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_copy_host2target_offset.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_copy_offsets.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_copy_offsets.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_copy_target2host.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_copy_target2host.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_copy_target2host_2d.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_copy_target2host_2d.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_copy_target2host_offset.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_copy_target2host_offset.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/buffer_ordering.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/buffer_ordering.cpp"
49 changes: 49 additions & 0 deletions sycl/test-e2e/Graph/Explicit/depends_on.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

// Tests that an event returned from adding a graph node using the queue
// recording API can be passed to `handler::depends_on` inside a node
// added using the explicit API. This should create a graph edge.

#include "../graph_common.hpp"

int main() {

queue Queue;

exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()};

const size_t N = 10;
float *Arr = malloc_device<float>(N, Queue);

Graph.begin_recording(Queue);
// `Event` corresponds to a graph node
event Event = Queue.submit([&](handler &CGH) {
CGH.parallel_for(range<1>{N}, [=](id<1> idx) { Arr[idx] = 42.0f; });
});
Graph.end_recording(Queue);

Graph.add([&](handler &CGH) {
CGH.depends_on(Event); // creates edge to recorded graph node
CGH.parallel_for(range<1>{N}, [=](id<1> idx) { Arr[idx] *= 2.0f; });
});

auto ExecGraph = Graph.finalize();

Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }).wait();

constexpr float ref = 42.0f * 2.0f;
std::vector<float> Output(N);
Queue.memcpy(Output.data(), Arr, N * sizeof(float)).wait();
for (int i = 0; i < N; i++)
assert(Output[i] == ref);

sycl::free(Arr, Queue);

return 0;
}
14 changes: 14 additions & 0 deletions sycl/test-e2e/Graph/Explicit/dotp_buffer_reduction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

// Expected fail as reduction support is not complete.
// XFAIL: *

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/dotp_buffer_reduction.cpp"
14 changes: 14 additions & 0 deletions sycl/test-e2e/Graph/Explicit/dotp_usm_reduction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

// Expected fail as reduction support is not complete.
// XFAIL: *

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/dotp_usm_reduction.cpp"
14 changes: 14 additions & 0 deletions sycl/test-e2e/Graph/Explicit/double_buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

// Expected fail as executable graph update isn't implemented yet
// XFAIL: *

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/double_buffer.cpp"
11 changes: 11 additions & 0 deletions sycl/test-e2e/Graph/Explicit/empty_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: level_zero, gpu
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using ZE_DEBUG
// RUN: %if ext_oneapi_level_zero %{env ZE_DEBUG=4 %{run} %t.out 2>&1 | FileCheck %s %}
//
// CHECK-NOT: LEAK

#define GRAPH_E2E_EXPLICIT

#include "../Inputs/empty_node.cpp"
Loading

0 comments on commit f5bbf33

Please sign in to comment.