Skip to content

Commit b453dcc

Browse files
authored
[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.
1 parent 4e13d23 commit b453dcc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sycl/test-e2e/Graph/Update/dyn_cgf_accessor_spv.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ int main(int, char **argv) {
4444
auto AccA = BufA.get_access();
4545
auto AccB = BufB.get_access();
4646

47+
// Zero initialize buffers
48+
std::vector<int> HostDataA(Size, 0);
49+
std::vector<int> HostDataB(Size, 0);
50+
Queue.copy(HostDataA.data(), AccA);
51+
Queue.copy(HostDataB.data(), AccB);
52+
Queue.wait();
53+
4754
auto CGFA = [&](handler &CGH) {
4855
CGH.require(AccA);
4956
CGH.set_arg(0, AccA);
@@ -64,8 +71,6 @@ int main(int, char **argv) {
6471

6572
Queue.ext_oneapi_graph(ExecGraph).wait();
6673

67-
std::vector<int> HostDataA(Size, 0);
68-
std::vector<int> HostDataB(Size, 0);
6974
Queue.copy(BufA.get_access(), HostDataA.data()).wait();
7075
Queue.copy(BufB.get_access(), HostDataB.data()).wait();
7176
for (size_t i = 0; i < Size; i++) {

0 commit comments

Comments
 (0)