Skip to content

Commit d1f1963

Browse files
zhaomaosukbenzie
andauthored
[DevMSAN] Propagate shadow memory in buffer related APIs (#16526)
UR Part: oneapi-src/unified-runtime#2520 --------- Co-authored-by: Kenneth Benzie (Benie) <[email protected]>
1 parent 0a6de23 commit d1f1963

File tree

5 files changed

+77
-42
lines changed

5 files changed

+77
-42
lines changed
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# commit ad88f0a1e3a22807866af4f6dad53e8986733abb
2-
# Merge: 68aed2d5 599a28e1
3-
# Author: Ross Brunton <[email protected]>
4-
# Date: Tue Jan 14 10:28:07 2025 +0000
5-
6-
# Merge pull request #2527 from RossBrunton/ross/wrapper
7-
#
8-
# Wrap urEventSetCallback when ran through loader
9-
set(UNIFIED_RUNTIME_TAG ad88f0a1e3a22807866af4f6dad53e8986733abb)
1+
# commit afbb289aa8d4f3b27b1536ba33ca618b0aba65c7
2+
# Merge: ef70004f d7c33f88
3+
# Author: Kenneth Benzie (Benie) <[email protected]>
4+
# Date: Wed Jan 15 11:54:25 2025 +0000
5+
# Merge pull request #2520 from zhaomaosu/fix-buffer-shadow
6+
# [DevMSAN] Propagate shadow memory in buffer related APIs
7+
set(UNIFIED_RUNTIME_TAG afbb289aa8d4f3b27b1536ba33ca618b0aba65c7)

sycl/test-e2e/AddressSanitizer/lit.local.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ config.substitutions.append(
88
("%force_device_asan_rt", "env UR_ENABLE_LAYERS=UR_LAYER_ASAN")
99
)
1010

11+
if "-fsanitize=memory" in config.cxx_flags:
12+
config.unsupported=True
13+
1114
# https://github.com/intel/llvm/issues/15953
1215
config.unsupported_features += ['gpu-intel-gen12']

sycl/test-e2e/MemorySanitizer/check_buffer_host_ptr.cpp

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// REQUIRES: linux, cpu || (gpu && level_zero)
2+
// RUN: %{build} %device_msan_flags -O0 -g -o %t1.out
3+
// RUN: %{run} %t1.out 2>&1 | FileCheck %s
4+
// RUN: %{build} %device_msan_flags -O2 -g -o %t2.out
5+
// RUN: %{run} %t2.out 2>&1 | FileCheck %s
6+
7+
#include <sycl/detail/core.hpp>
8+
9+
__attribute__((noinline)) int foo(int data1, int data2) {
10+
return data1 + data2;
11+
}
12+
13+
void check_memset(sycl::queue &q) {
14+
std::cout << "check_memset" << std::endl;
15+
sycl::buffer<int, 1> buf(sycl::range<1>(2));
16+
const int Pattern = 0;
17+
18+
q.submit([&](sycl::handler &h) {
19+
auto array = buf.get_access<sycl::access::mode::read_write>(h);
20+
h.fill(array, Pattern);
21+
}).wait();
22+
23+
q.submit([&](sycl::handler &h) {
24+
auto array = buf.get_access<sycl::access::mode::read_write>(h);
25+
h.single_task<class MyKernel1>(
26+
[=]() { array[0] = foo(array[0], array[1]); });
27+
}).wait();
28+
std::cout << "PASS" << std::endl;
29+
// CHECK-LABEL: check_memset
30+
// CHECK-NOT: use-of-uninitialized-value
31+
// CHECK: PASS
32+
}
33+
34+
void check_memcpy(sycl::queue &q) {
35+
std::cout << "check_memcpy" << std::endl;
36+
int host[2] = {1, 2};
37+
sycl::buffer<int, 1> buf1(sycl::range<1>(2));
38+
sycl::buffer<int, 1> buf2(host, sycl::range<1>(2));
39+
40+
q.submit([&](sycl::handler &h) {
41+
auto array1 = buf1.get_access<sycl::access::mode::read_write>(h);
42+
auto array2 = buf2.get_access<sycl::access::mode::read_write>(h);
43+
h.copy(array2, array1);
44+
}).wait();
45+
46+
q.submit([&](sycl::handler &h) {
47+
auto array = buf1.get_access<sycl::access::mode::read_write>(h);
48+
h.single_task<class MyKernel2>(
49+
[=]() { array[0] = foo(array[0], array[1]); });
50+
}).wait();
51+
std::cout << "PASS" << std::endl;
52+
// CHECK-LABEL: check_memcpy
53+
// CHECK-NOT: use-of-uninitialized-value
54+
// CHECK: PASS
55+
}
56+
57+
int main() {
58+
sycl::queue q;
59+
60+
check_memset(q);
61+
check_memcpy(q);
62+
63+
return 0;
64+
}

sycl/test-e2e/MemorySanitizer/lit.local.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ config.substitutions.append(
1212
config.substitutions.append(
1313
("%force_device_msan_rt", "env UR_ENABLE_LAYERS=UR_LAYER_MSAN")
1414
)
15+
16+
if "-fsanitize=address" in config.cxx_flags:
17+
config.unsupported=True

0 commit comments

Comments
 (0)