From 7f18714ba43711e18f95323159195fb53a6ea087 Mon Sep 17 00:00:00 2001 From: Adam Fidel Date: Tue, 12 May 2026 08:00:21 -0700 Subject: [PATCH 1/3] [SYCL][Graph] Add tests for pausing and resuming recording --- .../exception_pause_resume_recording.cpp | 57 +++++++++++++++++ .../RecordReplay/pause_resume_recording.cpp | 63 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 sycl/test-e2e/Graph/RecordReplay/NativeRecording/exception_pause_resume_recording.cpp create mode 100644 sycl/test-e2e/Graph/RecordReplay/pause_resume_recording.cpp diff --git a/sycl/test-e2e/Graph/RecordReplay/NativeRecording/exception_pause_resume_recording.cpp b/sycl/test-e2e/Graph/RecordReplay/NativeRecording/exception_pause_resume_recording.cpp new file mode 100644 index 0000000000000..d39604ae0307c --- /dev/null +++ b/sycl/test-e2e/Graph/RecordReplay/NativeRecording/exception_pause_resume_recording.cpp @@ -0,0 +1,57 @@ +// REQUIRES: level_zero_v2_adapter && arch-intel_gpu_bmg_g21 + +// RUN: %{build} -o %t.out +// RUN: %{run} %t.out +// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG +// RUN: %if level_zero %{%{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} + +// Tests that attempting to pause and resume recording is unsupported in native recording +// mode and throws an exception. + +#include "../../graph_common.hpp" + +#include + +int main() { + queue Queue{property::queue::in_order{}}; + + exp_ext::command_graph Graph{ + Queue.get_context(), + Queue.get_device(), + {exp_ext::property::graph::enable_native_recording{}}}; + + const size_t N = 1024; + int *Data = malloc_device(N, Queue); + + QueueStateVerifier Verifier(Queue); + Verifier.verify(EXECUTING); + + Graph.begin_recording(Queue); + Verifier.verify(RECORDING); + + Queue.parallel_for(range<1>{N}, + [=](id<1> idx) { Data[idx] = static_cast(idx); }); + + // Pause recording + Graph.end_recording(Queue); + Verifier.verify(EXECUTING); + + // Attempting to resume (begin_recording again on the same graph) must throw. + const bool Passed = + expectException([&]() { Graph.begin_recording(Queue); }, + "begin_recording after end_recording on native graph", + sycl::errc::runtime); + + assert(Queue.ext_oneapi_get_state() == exp_ext::queue_state::executing); + + free(Data, Queue); + + if (!Passed) { + std::cerr + << "Expected an exception when resuming recording on a native graph" + << std::endl; + return 1; + } + + return 0; +} diff --git a/sycl/test-e2e/Graph/RecordReplay/pause_resume_recording.cpp b/sycl/test-e2e/Graph/RecordReplay/pause_resume_recording.cpp new file mode 100644 index 0000000000000..66559d3245ad9 --- /dev/null +++ b/sycl/test-e2e/Graph/RecordReplay/pause_resume_recording.cpp @@ -0,0 +1,63 @@ +// RUN: %{build} -o %t.out +// RUN: %{run} %t.out +// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG +// RUN: %if level_zero %{%{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} + +// Tests that recording can be paused and resumed + +#include "../graph_common.hpp" + +int main() { + queue Queue{property::queue::in_order{}}; + + exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()}; + + const size_t N = 1024; + int *Data = malloc_device(N, Queue); + + QueueStateVerifier Verifier(Queue); + Verifier.verify(EXECUTING); + + Graph.begin_recording(Queue); + Verifier.verify(RECORDING); + + Queue.parallel_for(range<1>{N}, + [=](id<1> idx) { Data[idx] = static_cast(idx); }); + + // Pause recording + Graph.end_recording(Queue); + Verifier.verify(EXECUTING); + + // NOT recorded + Queue.parallel_for(range<1>{N}, [=](id<1> idx) { Data[idx] += 1000; }).wait(); + + // resume + Graph.begin_recording(Queue); + Verifier.verify(RECORDING); + + Queue.parallel_for(range<1>{N}, + [=](id<1> idx) { Data[idx] = Data[idx] * 2; }); + + Graph.end_recording(Queue); + Verifier.verify(EXECUTING); + + // Reset Data to known state before executing the graph + Queue.parallel_for(range<1>{N}, [=](id<1> idx) { Data[idx] = 0; }).wait(); + + auto ExecGraph = Graph.finalize(); + + Queue.ext_oneapi_graph(ExecGraph); + Queue.wait(); + + // Expected: don't run the eager +1000 kernel. + std::vector HostData(N); + Queue.memcpy(HostData.data(), Data, N * sizeof(int)).wait(); + + for (size_t i = 0; i < N; i++) { + int Expected = static_cast(i) * 2; + assert(check_value(i, Expected, HostData[i], "Data")); + } + + free(Data, Queue); + return 0; +} From 0b8e226dfa5e0c818d27db8b9455969b9b59a8e5 Mon Sep 17 00:00:00 2001 From: Adam Fidel Date: Tue, 12 May 2026 08:06:26 -0700 Subject: [PATCH 2/3] Code formatting --- .../NativeRecording/exception_pause_resume_recording.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/test-e2e/Graph/RecordReplay/NativeRecording/exception_pause_resume_recording.cpp b/sycl/test-e2e/Graph/RecordReplay/NativeRecording/exception_pause_resume_recording.cpp index d39604ae0307c..858cf0524d80d 100644 --- a/sycl/test-e2e/Graph/RecordReplay/NativeRecording/exception_pause_resume_recording.cpp +++ b/sycl/test-e2e/Graph/RecordReplay/NativeRecording/exception_pause_resume_recording.cpp @@ -5,8 +5,8 @@ // Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG // RUN: %if level_zero %{%{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} -// Tests that attempting to pause and resume recording is unsupported in native recording -// mode and throws an exception. +// Tests that attempting to pause and resume recording is unsupported in native +// recording mode and throws an exception. #include "../../graph_common.hpp" From 25db86a06f0fb4b4b498c4659b8419a7d8379535 Mon Sep 17 00:00:00 2001 From: Adam Fidel Date: Tue, 12 May 2026 13:52:02 -0700 Subject: [PATCH 3/3] [SYCL][Graph] Fix missing include in pause_resume_recording test Add the missing include needed for property::queue::in_order{}. Co-Authored-By: Claude Sonnet 4.6 --- sycl/test-e2e/Graph/RecordReplay/pause_resume_recording.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/test-e2e/Graph/RecordReplay/pause_resume_recording.cpp b/sycl/test-e2e/Graph/RecordReplay/pause_resume_recording.cpp index 66559d3245ad9..c9e6c77028d96 100644 --- a/sycl/test-e2e/Graph/RecordReplay/pause_resume_recording.cpp +++ b/sycl/test-e2e/Graph/RecordReplay/pause_resume_recording.cpp @@ -7,6 +7,8 @@ #include "../graph_common.hpp" +#include + int main() { queue Queue{property::queue::in_order{}};