-
Notifications
You must be signed in to change notification settings - Fork 776
[DeviceSanitizer] Add e2e tests for detecting out-of-bounds errors on sycl::buffer #13504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cc1bb2e
[DeviceSanitizer] Add e2e tests for detecting out-of-bounds errors on…
zhaomaosu 0636463
Fix lit test failures
zhaomaosu 21dad13
Merge branch 'sycl' into sanitizer-buffer
zhaomaosu cfb84d9
Merge branch 'sycl' into sanitizer-buffer
zhaomaosu d8b73ef
use fine grained includes
zhaomaosu a53b4a2
Merge branch 'sycl' into sanitizer-buffer
zhaomaosu 8ce281f
Fix lit test failures
zhaomaosu a6aefd9
Merge branch 'sycl' into sanitizer-buffer
zhaomaosu 417c6bf
Remove force_device_asan_rt flag
zhaomaosu 4ca7e44
Merge branch 'sycl' into sanitizer-buffer
zhaomaosu f175e41
Update per suggestions
zhaomaosu 590144e
Merge branch 'sycl' into sanitizer-buffer
zhaomaosu 5de6b7c
Add more comments
zhaomaosu c288fe1
Merge remote-tracking branch 'origin/sycl' into sanitizer-buffer
kbenzie 54764b1
[UR] Bump main tag to 9f783837
kbenzie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
sycl/test-e2e/AddressSanitizer/out-of-bounds/buffer/buffer.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// REQUIRES: linux, cpu | ||
// RUN: %{build} %device_asan_flags -O0 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O1 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O2 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
|
||
#include <sycl/detail/core.hpp> | ||
|
||
static const int N = 16; | ||
|
||
int main() { | ||
sycl::queue q; | ||
|
||
std::vector<int> v(N); | ||
|
||
{ | ||
// We intentionally test sycl::buffer uses host ptr and trigger data write | ||
// back here because in unified runtime we intercept sycl::buffer with usm, | ||
// we need to cover that pattern here. | ||
sycl::buffer<int, 1> buf(v.data(), v.size()); | ||
aelovikov-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
q.submit([&](sycl::handler &h) { | ||
auto A = buf.get_access<sycl::access::mode::read_write>(h); | ||
h.parallel_for<class Test>( | ||
sycl::nd_range<1>(N + 1, 1), | ||
[=](sycl::nd_item<1> item) { A[item.get_global_id()] *= 2; }); | ||
}).wait(); | ||
// CHECK: ERROR: DeviceSanitizer: out-of-bounds-access on Memory Buffer | ||
// CHECK: {{READ of size 4 at kernel <.*Test> LID\(0, 0, 0\) GID\(16, 0, 0\)}} | ||
// CHECK: {{#0 .* .*buffer.cpp:}}[[@LINE-4]] | ||
} | ||
|
||
return 0; | ||
} |
35 changes: 35 additions & 0 deletions
35
sycl/test-e2e/AddressSanitizer/out-of-bounds/buffer/buffer_2d.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// REQUIRES: linux, cpu | ||
// RUN: %{build} %device_asan_flags -O0 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O1 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
|
||
#include <sycl/detail/core.hpp> | ||
|
||
int main() { | ||
constexpr size_t size_x = 5; | ||
constexpr size_t size_y = 6; | ||
|
||
std::vector<int> v(size_x * size_y); | ||
|
||
// We intentionally test sycl::buffer uses host ptr here because in unified | ||
// runtime we intercept sycl::buffer with usm, we need to cover that pattern | ||
// here. | ||
sycl::buffer<int, 2> buf(v.data(), sycl::range<2>(size_x, size_y)); | ||
|
||
sycl::queue q; | ||
|
||
q.submit([&](sycl::handler &cgh) { | ||
auto accessor = buf.get_access<sycl::access::mode::read_write>(cgh); | ||
cgh.parallel_for<class Test>( | ||
sycl::nd_range<2>({size_x, size_y + 1}, {1, 1}), | ||
[=](sycl::nd_item<2> item) { | ||
accessor[item.get_global_id()] = item.get_global_linear_id(); | ||
}); | ||
}).wait(); | ||
// CHECK: ERROR: DeviceSanitizer: out-of-bounds-access on Memory Buffer | ||
// CHECK: {{WRITE of size 4 at kernel <.*Test> LID\(0, 0, 0\) GID\(6, 4, 0\)}} | ||
// CHECK: {{#0 .* .*buffer_2d.cpp:}}[[@LINE-5]] | ||
|
||
return 0; | ||
} |
37 changes: 37 additions & 0 deletions
37
sycl/test-e2e/AddressSanitizer/out-of-bounds/buffer/buffer_3d.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// REQUIRES: linux, cpu | ||
// RUN: %{build} %device_asan_flags -O0 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O1 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
|
||
#include <sycl/detail/core.hpp> | ||
|
||
int main() { | ||
constexpr size_t size_x = 5; | ||
constexpr size_t size_y = 6; | ||
constexpr size_t size_z = 7; | ||
|
||
std::vector<int> v(size_x * size_y * size_z); | ||
|
||
// We intentionally test sycl::buffer uses host ptr here because in unified | ||
// runtime we intercept sycl::buffer with usm, we need to cover that pattern | ||
// here. | ||
sycl::buffer<int, 3> buf(v.data(), sycl::range<3>(size_x, size_y, size_z)); | ||
|
||
sycl::queue q; | ||
|
||
q.submit([&](sycl::handler &cgh) { | ||
auto accessor = buf.get_access<sycl::access::mode::read_write>(cgh); | ||
|
||
cgh.parallel_for<class Test>( | ||
sycl::nd_range<3>({size_x, size_y, size_z + 1}, {1, 1, 1}), | ||
[=](sycl::nd_item<3> item) { | ||
accessor[item.get_global_id()] = item.get_global_linear_id(); | ||
}); | ||
}).wait(); | ||
// CHECK: ERROR: DeviceSanitizer: out-of-bounds-access on Memory Buffer | ||
// CHECK: {{WRITE of size 4 at kernel <.*Test> LID\(0, 0, 0\) GID\(7, 5, 4\)}} | ||
// CHECK: {{#0 .* .*buffer_3d.cpp:}}[[@LINE-5]] | ||
|
||
return 0; | ||
} |
46 changes: 46 additions & 0 deletions
46
sycl/test-e2e/AddressSanitizer/out-of-bounds/buffer/buffer_copy_fill.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// REQUIRES: linux, cpu | ||
// RUN: %{build} %device_asan_flags -O0 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O1 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O2 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
|
||
#include <sycl/detail/core.hpp> | ||
|
||
#include <numeric> | ||
|
||
static const int N = 16; | ||
|
||
int main() { | ||
sycl::queue q; | ||
|
||
std::vector<int> v(N); | ||
std::iota(v.begin(), v.end(), 0); | ||
|
||
{ | ||
sycl::buffer<int, 1> buf(v.size()); | ||
|
||
q.submit([&](sycl::handler &h) { | ||
auto A = buf.get_access<sycl::access::mode::write>(h); | ||
h.copy(&v[0], A); | ||
}).wait(); | ||
|
||
q.submit([&](sycl::handler &h) { | ||
auto A = buf.get_access<sycl::access::mode::write>(h); | ||
h.fill(A, 1); | ||
}).wait(); | ||
|
||
q.submit([&](sycl::handler &h) { | ||
auto A = buf.get_access<sycl::access::mode::read_write>(h); | ||
h.parallel_for<class Test>( | ||
sycl::nd_range<1>(N + 1, 1), | ||
[=](sycl::nd_item<1> item) { A[item.get_global_id()] *= 2; }); | ||
}).wait(); | ||
// CHECK: ERROR: DeviceSanitizer: out-of-bounds-access on Memory Buffer | ||
// CHECK: {{READ of size 4 at kernel <.*Test> LID\(0, 0, 0\) GID\(16, 0, 0\)}} | ||
// CHECK: {{#0 .* .*buffer_copy_fill.cpp:}}[[@LINE-4]] | ||
} | ||
|
||
return 0; | ||
} |
35 changes: 35 additions & 0 deletions
35
sycl/test-e2e/AddressSanitizer/out-of-bounds/buffer/subbuffer.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// REQUIRES: linux, cpu | ||
// RUN: %{build} %device_asan_flags -O0 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O1 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O2 -g -o %t.out | ||
// RUN: env SYCL_PREFER_UR=1 %{run} not %t.out 2>&1 | FileCheck %s | ||
|
||
#include <sycl/detail/core.hpp> | ||
|
||
int main() { | ||
constexpr size_t size_x = 16; | ||
|
||
std::vector<int> v(size_x); | ||
for (size_t i = 0; i < size_x; i++) | ||
v[i] = i; | ||
|
||
{ | ||
sycl::queue q; | ||
sycl::buffer<int> buf(v.data(), v.size()); | ||
sycl::buffer<int> sub_buf(buf, {size_x / 2}, {size_x / 2}); | ||
|
||
q.submit([&](sycl::handler &cgh) { | ||
auto accessor = sub_buf.get_access<sycl::access::mode::read_write>(cgh); | ||
cgh.parallel_for<class Test>( | ||
sycl::nd_range<1>(size_x / 2 + 1, 1), | ||
[=](sycl::nd_item<1> item) { accessor[item.get_global_id()] *= 2; }); | ||
}).wait(); | ||
// CHECK: ERROR: DeviceSanitizer: out-of-bounds-access on Memory Buffer | ||
// CHECK: {{READ of size 4 at kernel <.*Test> LID\(0, 0, 0\) GID\(8, 0, 0\)}} | ||
// CHECK: {{#0 .* .*subbuffer.cpp:}}[[@LINE-4]] | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think merging all these tests into a single
.cpp
file might be beneficial for CI load, but we can address it separately for the entire E2E suite at once.