Skip to content

Commit eb8d2ae

Browse files
zhaomaosuKornevNikita
authored andcommitted
[DevMSAN] Add test to check sycl::buffer use host ptr (#16474)
1 parent 98d50a1 commit eb8d2ae

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// REQUIRES: linux, cpu || (gpu && level_zero)
2+
// RUN: %{build} %device_msan_flags -O1 -g -o %t2.out
3+
// RUN: %{run} not %t2.out 2>&1 | FileCheck %s
4+
// RUN: %{build} %device_msan_flags -O2 -g -o %t3.out
5+
// RUN: %{run} not %t3.out 2>&1 | FileCheck %s
6+
7+
#include <sycl/detail/core.hpp>
8+
9+
__attribute__((noinline)) long long foo(int data1, long long data2) {
10+
return data1 + data2;
11+
}
12+
13+
int main() {
14+
sycl::queue q;
15+
int data1[1];
16+
long long data2[1];
17+
18+
{
19+
sycl::buffer<int, 1> buf1(data1, sycl::range<1>(1));
20+
sycl::buffer<long long, 1> buf2(data2, sycl::range<1>(1));
21+
q.submit([&](sycl::handler &h) {
22+
auto array1 = buf1.get_access<sycl::access::mode::read_write>(h);
23+
auto array2 = buf2.get_access<sycl::access::mode::read_write>(h);
24+
h.single_task<class MyKernel>(
25+
[=]() { array1[0] = foo(array1[0], array2[0]); });
26+
}).wait();
27+
// CHECK: use-of-uninitialized-value
28+
// CHECK: kernel <{{.*MyKernel}}>
29+
// CHECK: #0 {{.*}} {{.*check_buffer_host_ptr.cpp}}:[[@LINE-4]]
30+
}
31+
32+
return 0;
33+
}

sycl/test-e2e/MemorySanitizer/check_call.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ int main() {
2323
[=]() { array[0] = foo(array[0], array[1]); });
2424
});
2525
Q.wait();
26+
// CHECK-NOT: [kernel]
2627
// CHECK: use-of-uninitialized-value
2728
// CHECK: kernel <{{.*MyKernel}}>
28-
// CHECK: #0 {{.*}} {{.*check_call.cpp}}:[[@LINE-5]]
29+
// CHECK: #0 {{.*}} {{.*check_call.cpp}}:[[@LINE-6]]
2930

3031
sycl::free(array, Q);
3132
return 0;

0 commit comments

Comments
 (0)