Skip to content

Commit

Permalink
[DeviceMSAN] Fix "urEnqueueUSM" APIs (intel#16511)
Browse files Browse the repository at this point in the history
UR: oneapi-src/unified-runtime#2513

Support USM related memory operations like "memset" and "memcpy"

---------

Co-authored-by: Kenneth Benzie (Benie) <[email protected]>
  • Loading branch information
AllanZyne and kbenzie authored Jan 6, 2025
1 parent b9cdbc0 commit 69da088
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sycl/cmake/modules/UnifiedRuntimeTag.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# commit 75745a910cb7197de6e214c1f23c544895afbbb7
# Merge: 0eb08b67 5a7d8fa0
# commit 533ab9b08dfbf061585eb3487aed94ca45d0b331
# Merge: e7366f94 3eeb2a17
# Author: Kenneth Benzie (Benie) <[email protected]>
# Date: Mon Jan 6 11:21:29 2025 +0000
# Merge pull request #2508 from AllanZyne/review/yang/fix_msan_empty_kernel
# [DeviceMSAN] Fix empty kernel
set(UNIFIED_RUNTIME_TAG 75745a910cb7197de6e214c1f23c544895afbbb7)
# Date: Mon Jan 6 15:24:08 2025 +0000
# Merge pull request #2513 from AllanZyne/review/yang/fix_msan_usm
# [DeviceMSAN] Fix "urEnqueueUSM" APIs
set(UNIFIED_RUNTIME_TAG 533ab9b08dfbf061585eb3487aed94ca45d0b331)
68 changes: 68 additions & 0 deletions sycl/test-e2e/MemorySanitizer/check_usm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// REQUIRES: linux, cpu || (gpu && level_zero)
// RUN: %{build} %device_msan_flags -O0 -g -o %t2.out
// RUN: %{run} not %t2.out 2>&1 | FileCheck %s
// RUN: %{build} %device_msan_flags -O2 -g -o %t3.out
// RUN: %{run} not %t3.out 2>&1 | FileCheck %s

// UNSUPPORTED: cpu
// UNSUPPORTED-TRACKER: CMPLRLLVM-64618

#include <sycl/detail/core.hpp>
#include <sycl/usm.hpp>

__attribute__((noinline)) long long foo(int data1, long long data2) {
return data1 + data2;
}

void check_memset(sycl::queue &Q) {
std::cout << "check_memset" << std::endl;
auto *array = sycl::malloc_device<int>(2, Q);
auto ev1 = Q.memset(array, 0, 2 * sizeof(int));
auto ev2 = Q.single_task(ev1, [=]() { array[0] = foo(array[0], array[1]); });
Q.wait();
sycl::free(array, Q);
std::cout << "PASS" << std::endl;
}
// CHECK-LABEL: check_memset
// CHECK-NOT: use-of-uninitialized-value
// CHECK: PASS

void check_memcpy1(sycl::queue &Q) {
std::cout << "check_memcpy1" << std::endl;
auto *source = sycl::malloc_host<int>(2, Q);
auto *array = sycl::malloc_device<int>(2, Q);
// FIXME: We don't support shadow propagation on host/shared usm
auto ev1 = Q.memcpy(array, source, 2 * sizeof(int));
auto ev2 = Q.single_task(ev1, [=]() { array[0] = foo(array[0], array[1]); });
Q.wait();
sycl::free(array, Q);
sycl::free(source, Q);
std::cout << "PASS" << std::endl;
}
// CHECK-LABEL: check_memcpy1
// CHECK-NOT: use-of-uninitialized-value
// CHECK: PASS

void check_memcpy2(sycl::queue &Q) {
std::cout << "check_memcpy2" << std::endl;
auto *source = sycl::malloc_device<int>(2, Q);
auto *array = sycl::malloc_device<int>(2, Q);
// FIXME: We don't support shadow propagation on host/shared usm
auto ev1 = Q.memcpy(array, source, 2 * sizeof(int));
auto ev2 = Q.single_task(ev1, [=]() { array[0] = foo(array[0], array[1]); });
Q.wait();
sycl::free(array, Q);
sycl::free(source, Q);
std::cout << "PASS" << std::endl;
}
// CHECK-LABEL: check_memcpy2
// CHECK: use-of-uninitialized-value
// CHECK-NOT: PASS

int main() {
sycl::queue Q;
check_memset(Q);
check_memcpy1(Q);
check_memcpy2(Q);
return 0;
}

0 comments on commit 69da088

Please sign in to comment.