From b453dcc18380f0bf1c0c110bc9dbe5804b3f1d00 Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Mon, 9 Dec 2024 08:31:20 +0000 Subject: [PATCH] [SYCL][Graph] Fix dyn_cgf_accessor_spv.cpp Test (#16295) The E2E SYCL-Graph test `Update/dyn_cgf_accessor_spv.cpp` checks that after the first execution of the graph, the accessor referencing `bufferB` has not been written to. This is done by checking for zero on the line ```cpp assert(check_value(i, 0, HostDataB[i], "HostDataB")); ``` However, we never explicitly initialize `bufferB` to zero in the test, it is still uninitialized at the point of this assert. Therefore this check against zero is based on UB. This patch fixes the test by initializing the buffers to zero at the beginning of the test. --- sycl/test-e2e/Graph/Update/dyn_cgf_accessor_spv.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sycl/test-e2e/Graph/Update/dyn_cgf_accessor_spv.cpp b/sycl/test-e2e/Graph/Update/dyn_cgf_accessor_spv.cpp index aaaced3e7ce21..f7237d8f18182 100644 --- a/sycl/test-e2e/Graph/Update/dyn_cgf_accessor_spv.cpp +++ b/sycl/test-e2e/Graph/Update/dyn_cgf_accessor_spv.cpp @@ -44,6 +44,13 @@ int main(int, char **argv) { auto AccA = BufA.get_access(); auto AccB = BufB.get_access(); + // Zero initialize buffers + std::vector HostDataA(Size, 0); + std::vector HostDataB(Size, 0); + Queue.copy(HostDataA.data(), AccA); + Queue.copy(HostDataB.data(), AccB); + Queue.wait(); + auto CGFA = [&](handler &CGH) { CGH.require(AccA); CGH.set_arg(0, AccA); @@ -64,8 +71,6 @@ int main(int, char **argv) { Queue.ext_oneapi_graph(ExecGraph).wait(); - std::vector HostDataA(Size, 0); - std::vector HostDataB(Size, 0); Queue.copy(BufA.get_access(), HostDataA.data()).wait(); Queue.copy(BufB.get_access(), HostDataB.data()).wait(); for (size_t i = 0; i < Size; i++) {