Skip to content

Commit 69da088

Browse files
AllanZynekbenzie
andauthored
[DeviceMSAN] Fix "urEnqueueUSM" APIs (#16511)
UR: oneapi-src/unified-runtime#2513 Support USM related memory operations like "memset" and "memcpy" --------- Co-authored-by: Kenneth Benzie (Benie) <[email protected]>
1 parent b9cdbc0 commit 69da088

File tree

2 files changed

+74
-6
lines changed

2 files changed

+74
-6
lines changed
+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# commit 75745a910cb7197de6e214c1f23c544895afbbb7
2-
# Merge: 0eb08b67 5a7d8fa0
1+
# commit 533ab9b08dfbf061585eb3487aed94ca45d0b331
2+
# Merge: e7366f94 3eeb2a17
33
# Author: Kenneth Benzie (Benie) <[email protected]>
4-
# Date: Mon Jan 6 11:21:29 2025 +0000
5-
# Merge pull request #2508 from AllanZyne/review/yang/fix_msan_empty_kernel
6-
# [DeviceMSAN] Fix empty kernel
7-
set(UNIFIED_RUNTIME_TAG 75745a910cb7197de6e214c1f23c544895afbbb7)
4+
# Date: Mon Jan 6 15:24:08 2025 +0000
5+
# Merge pull request #2513 from AllanZyne/review/yang/fix_msan_usm
6+
# [DeviceMSAN] Fix "urEnqueueUSM" APIs
7+
set(UNIFIED_RUNTIME_TAG 533ab9b08dfbf061585eb3487aed94ca45d0b331)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// REQUIRES: linux, cpu || (gpu && level_zero)
2+
// RUN: %{build} %device_msan_flags -O0 -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+
// UNSUPPORTED: cpu
8+
// UNSUPPORTED-TRACKER: CMPLRLLVM-64618
9+
10+
#include <sycl/detail/core.hpp>
11+
#include <sycl/usm.hpp>
12+
13+
__attribute__((noinline)) long long foo(int data1, long long data2) {
14+
return data1 + data2;
15+
}
16+
17+
void check_memset(sycl::queue &Q) {
18+
std::cout << "check_memset" << std::endl;
19+
auto *array = sycl::malloc_device<int>(2, Q);
20+
auto ev1 = Q.memset(array, 0, 2 * sizeof(int));
21+
auto ev2 = Q.single_task(ev1, [=]() { array[0] = foo(array[0], array[1]); });
22+
Q.wait();
23+
sycl::free(array, Q);
24+
std::cout << "PASS" << std::endl;
25+
}
26+
// CHECK-LABEL: check_memset
27+
// CHECK-NOT: use-of-uninitialized-value
28+
// CHECK: PASS
29+
30+
void check_memcpy1(sycl::queue &Q) {
31+
std::cout << "check_memcpy1" << std::endl;
32+
auto *source = sycl::malloc_host<int>(2, Q);
33+
auto *array = sycl::malloc_device<int>(2, Q);
34+
// FIXME: We don't support shadow propagation on host/shared usm
35+
auto ev1 = Q.memcpy(array, source, 2 * sizeof(int));
36+
auto ev2 = Q.single_task(ev1, [=]() { array[0] = foo(array[0], array[1]); });
37+
Q.wait();
38+
sycl::free(array, Q);
39+
sycl::free(source, Q);
40+
std::cout << "PASS" << std::endl;
41+
}
42+
// CHECK-LABEL: check_memcpy1
43+
// CHECK-NOT: use-of-uninitialized-value
44+
// CHECK: PASS
45+
46+
void check_memcpy2(sycl::queue &Q) {
47+
std::cout << "check_memcpy2" << std::endl;
48+
auto *source = sycl::malloc_device<int>(2, Q);
49+
auto *array = sycl::malloc_device<int>(2, Q);
50+
// FIXME: We don't support shadow propagation on host/shared usm
51+
auto ev1 = Q.memcpy(array, source, 2 * sizeof(int));
52+
auto ev2 = Q.single_task(ev1, [=]() { array[0] = foo(array[0], array[1]); });
53+
Q.wait();
54+
sycl::free(array, Q);
55+
sycl::free(source, Q);
56+
std::cout << "PASS" << std::endl;
57+
}
58+
// CHECK-LABEL: check_memcpy2
59+
// CHECK: use-of-uninitialized-value
60+
// CHECK-NOT: PASS
61+
62+
int main() {
63+
sycl::queue Q;
64+
check_memset(Q);
65+
check_memcpy1(Q);
66+
check_memcpy2(Q);
67+
return 0;
68+
}

0 commit comments

Comments
 (0)