Skip to content

Commit

Permalink
[UR][DeviceSanitizer] Update UR and add e2e tests for detecting memor…
Browse files Browse the repository at this point in the history
…y leaks (#14378)

UR Part: oneapi-src/unified-runtime#1808

---------

Co-authored-by: Piotr Balcer <[email protected]>
Co-authored-by: omarahmed1111 <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2024
1 parent 0985116 commit 9c3998c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sycl/cmake/modules/FetchUnifiedRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ if(SYCL_UR_USE_FETCH_CONTENT)
endfunction()

set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
# commit 4517290650a9938537666e6409fb8e0db73ff4d8
# Merge: 6298474e 3dbb7a2a
# Author: Omar Ahmed <omar.ahmed@codeplay.com>
# Date: Wed Sep 18 08:48:03 2024 +0100
# Merge pull request #1914 from AllanZyne/review/yang/dsan_nullpointer
# [DeviceSanitizer] Support nullpointer detection
set(UNIFIED_RUNTIME_TAG 4517290650a9938537666e6409fb8e0db73ff4d8)
# commit 185149248dd257bd37482aac43307a136204c051
# Merge: 2af159d4 d619bcd1
# Author: Piotr Balcer <piotr.balcer@intel.com>
# Date: Thu Sep 19 11:02:27 2024 +0200
# Merge pull request #1934 from yingcong-wu/yc/0806-exclude-shadow-from-coredump
# [DeviceSanitizer] Exclude shadow memory from coredump file for CPU device.
set(UNIFIED_RUNTIME_TAG 185149248dd257bd37482aac43307a136204c051)

set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
# Due to the use of dependentloadflag and no installer for UMF and hwloc we need
Expand Down
24 changes: 24 additions & 0 deletions sycl/test-e2e/AddressSanitizer/memory-leak/memory-leak.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// REQUIRES: linux, cpu
// RUN: %{build} %device_asan_flags -O0 -g -o %t
// RUN: %{run} %t 2>&1 | FileCheck %s

#include <sycl/detail/core.hpp>

#include <sycl/usm.hpp>

int main() {
sycl::queue Q;
constexpr std::size_t N = 12;
auto *array = sycl::malloc_device<char>(N, Q);

Q.submit([&](sycl::handler &h) {
h.parallel_for<class MyKernelR_4>(
sycl::nd_range<1>(N, 1),
[=](sycl::nd_item<1> item) { ++array[item.get_global_id(0)]; });
}).wait();
// CHECK: ERROR: DeviceSanitizer: detected memory leaks of Device USM
// CHECK: Direct leak of 12 byte(s) at {{0x.*}} allocated from:
// CHECK: in main {{.*memory-leak.cpp:}}[[@LINE-9]]

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ int main() {
// CHECK: {{READ of size 4 at kernel <.*Kernel4> LID\(0, 0, 0\) GID\(4, 0, 0\)}}
// CHECK: {{ #0 .* .*multiple_kernels.cpp:}}[[@LINE-4]]

sycl::free(array, Q);
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ int main() {
// CHECK: ====ERROR: DeviceSanitizer
// CHECK-NOT: ====ERROR: DeviceSanitizer

sycl::free(array, Q);
return 0;
}

0 comments on commit 9c3998c

Please sign in to comment.