Skip to content

Commit

Permalink
[SYCL][Graph] Fix dyn_cgf_accessor_spv.cpp Test (#16295)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EwanC authored Dec 9, 2024
1 parent 4e13d23 commit b453dcc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sycl/test-e2e/Graph/Update/dyn_cgf_accessor_spv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ int main(int, char **argv) {
auto AccA = BufA.get_access();
auto AccB = BufB.get_access();

// Zero initialize buffers
std::vector<int> HostDataA(Size, 0);
std::vector<int> 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);
Expand All @@ -64,8 +71,6 @@ int main(int, char **argv) {

Queue.ext_oneapi_graph(ExecGraph).wait();

std::vector<int> HostDataA(Size, 0);
std::vector<int> 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++) {
Expand Down

0 comments on commit b453dcc

Please sign in to comment.