Skip to content

Commit 300059b

Browse files
authored
[Device ASAN] Add aot tests (#16552)
Add aot tests for device address sanitizer.
1 parent 909c8e7 commit 300059b

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <sycl/detail/core.hpp>
2+
3+
#include <sycl/usm.hpp>
4+
5+
int main() {
6+
sycl::queue Q;
7+
constexpr std::size_t N = 12;
8+
auto *array = sycl::malloc_host<int>(N, Q);
9+
Q.submit([&](sycl::handler &h) {
10+
h.parallel_for<class MyKernelR_4>(
11+
sycl::nd_range<1>(N + 1, 1),
12+
[=](sycl::nd_item<1> item) { ++array[item.get_global_id(0)]; });
13+
});
14+
Q.wait();
15+
// CHECK: ERROR: DeviceSanitizer: out-of-bounds-access on Host USM
16+
// CHECK: {{READ of size 4 at kernel <.*MyKernelR_4> LID\(0, 0, 0\) GID\(12, 0, 0\)}}
17+
// CHECK: {{#0 .*}}[[@LINE-5]]
18+
19+
sycl::free(array, Q);
20+
return 0;
21+
}

Diff for: sycl/test-e2e/AddressSanitizer/aot/cpu.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: linux, opencl-aot, cpu
2+
// REQUIRES: build-and-run-mode
3+
4+
// RUN: %{build} %device_asan_aot_flags -O0 -g %S/Inputs/host-usm-oob.cpp -o %t.out
5+
// RUN: %{run} not %t.out 2>&1 | FileCheck %S/Inputs/host-usm-oob.cpp
6+
7+
// RUN: %{build} %device_asan_aot_flags -O1 -g %S/Inputs/host-usm-oob.cpp -o %t.out
8+
// RUN: %{run} not %t.out 2>&1 | FileCheck %S/Inputs/host-usm-oob.cpp
9+
10+
// RUN: %{build} %device_asan_aot_flags -O2 -g %S/Inputs/host-usm-oob.cpp -o %t.out
11+
// RUN: %{run} not %t.out 2>&1 | FileCheck %S/Inputs/host-usm-oob.cpp
12+
13+
// RUN: %{build} %device_asan_aot_flags -O3 -g %S/Inputs/host-usm-oob.cpp -o %t.out
14+
// RUN: %{run} not %t.out 2>&1 | FileCheck %S/Inputs/host-usm-oob.cpp

Diff for: sycl/test-e2e/AddressSanitizer/aot/gpu.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: linux, ocloc, gpu && level_zero
2+
// REQUIRES: build-and-run-mode
3+
4+
// RUN: %{build} %device_asan_aot_flags -O0 -g %S/Inputs/host-usm-oob.cpp -o %t.out
5+
// RUN: %{run} not %t.out 2>&1 | FileCheck %S/Inputs/host-usm-oob.cpp
6+
7+
// RUN: %{build} %device_asan_aot_flags -O1 -g %S/Inputs/host-usm-oob.cpp -o %t.out
8+
// RUN: %{run} not %t.out 2>&1 | FileCheck %S/Inputs/host-usm-oob.cpp
9+
10+
// RUN: %{build} %device_asan_aot_flags -O2 -g %S/Inputs/host-usm-oob.cpp -o %t.out
11+
// RUN: %{run} not %t.out 2>&1 | FileCheck %S/Inputs/host-usm-oob.cpp
12+
13+
// RUN: %{build} %device_asan_aot_flags -O3 -g %S/Inputs/host-usm-oob.cpp -o %t.out
14+
// RUN: %{run} not %t.out 2>&1 | FileCheck %S/Inputs/host-usm-oob.cpp

0 commit comments

Comments
 (0)