Skip to content

Commit a60221a

Browse files
committed
enhance kernel-fitler.cpp test
1 parent 039cf38 commit a60221a

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fun:*MyKernel*
1+
fun:*NoSanitized*

sycl/test-e2e/AddressSanitizer/common/kernel-filter.cpp

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,51 @@
1-
// REQUIRES: linux
2-
// RUN: %{build} %device_asan_flags -O2 -fsanitize-ignorelist=%p/ignorelist.txt -o %t
3-
// RUN: %{run} %t 2>&1 | FileCheck %s
4-
// RUN: %{build} %device_asan_flags %if cpu %{ -fsycl-targets=spir64_x86_64 %} %if gpu %{ -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %} -O2 -fsanitize-ignorelist=%p/ignorelist.txt -o %t2
1+
// REQUIRES: linux, cpu || (gpu && level_zero)
2+
// RUN: %{build} %device_asan_flags -O2 -fsanitize-ignorelist=%p/ignorelist.txt -o %t1
3+
// RUN: %{run} %t1 2>&1 | FileCheck %s
4+
// RUN: %{build} %device_asan_aot_flags -O2 -fsanitize-ignorelist=%p/ignorelist.txt -o %t2
55
// RUN: %{run} %t2 2>&1 | FileCheck %s
66

77
#include <sycl/detail/core.hpp>
88
#include <sycl/usm.hpp>
99

1010
int main() {
11+
constexpr std::size_t N = 8;
12+
constexpr std::size_t group_size = 4;
13+
1114
sycl::queue Q;
12-
constexpr std::size_t N = 16;
15+
1316
auto *array = sycl::malloc_device<int>(N, Q);
1417

18+
std::vector<int> v(N);
19+
sycl::buffer<int, 1> buf(v.data(), v.size());
20+
1521
Q.submit([&](sycl::handler &h) {
16-
h.parallel_for<class MyKernel>(
17-
sycl::nd_range<1>(N + 1, 1),
18-
[=](sycl::nd_item<1> item) { ++array[item.get_global_id(0)]; });
22+
auto buf_acc = buf.get_access<sycl::access::mode::read_write>(h);
23+
auto loc_acc = sycl::local_accessor<int>(group_size, h);
24+
h.parallel_for<class NoSanitized>(
25+
sycl::nd_range<1>(N, group_size), [=](sycl::nd_item<1> item) {
26+
auto gid = item.get_global_id(0);
27+
auto lid = item.get_local_id(0);
28+
array[gid] = buf_acc[gid] + loc_acc[lid];
29+
});
30+
});
31+
Q.wait();
32+
// CHECK-NOT: ERROR: DeviceSanitizer: out-of-bounds-access
33+
34+
Q.submit([&](sycl::handler &h) {
35+
auto buf_acc = buf.get_access<sycl::access::mode::read_write>(h);
36+
auto loc_acc = sycl::local_accessor<int>(group_size, h);
37+
h.parallel_for<class Sanitized>(sycl::nd_range<1>(N, group_size),
38+
[=](sycl::nd_item<1> item) {
39+
auto gid = item.get_global_id(0);
40+
auto lid = item.get_local_id(0);
41+
array[gid] = buf_acc[gid] + loc_acc[lid];
42+
});
1943
});
2044
Q.wait();
2145

2246
sycl::free(array, Q);
2347
std::cout << "PASS" << std::endl;
48+
// CHECK: PASS
49+
2450
return 0;
2551
}
26-
27-
// CHECK: PASS
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# This test assumes it can only run in CPU/PVC/DG2 devices, which support usm_device_allocations aspect
2-
31
config.substitutions.append(
42
("%device_asan_flags", "-Xarch_device -fsanitize=address")
53
)
6-
4+
config.substitutions.append(
5+
("%device_asan_aot_flags", "-Xarch_device -fsanitize=address %if cpu %{ -fsycl-targets=spir64_x86_64 %} %if gpu %{ -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %}")
6+
)
77
config.substitutions.append(
88
("%force_device_asan_rt", "env UR_ENABLE_LAYERS=UR_LAYER_ASAN")
99
)
1010

11-
config.unsupported_features += ['cuda', 'hip']
12-
1311
# https://github.com/intel/llvm/issues/15953
1412
config.unsupported_features += ['gpu-intel-gen12']

0 commit comments

Comments
 (0)