File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
sycl/test-e2e/AddressSanitizer/memory-leak Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ // REQUIRES: linux, cpu
2+ // RUN: %{build} %device_asan_flags -O0 -g -fPIC -shared -DSHARED_LIB -o %t.so
3+ // RUN: %{build} %device_asan_flags -O0 -g -fPIC -Wl,-rpath,. %t.so -o %t
4+ // RUN: %{run} %t 2>&1 | FileCheck %s
5+ #include < sycl/detail/core.hpp>
6+
7+ #include < sycl/usm.hpp>
8+
9+ #if defined(SHARED_LIB)
10+ void test (sycl::queue &Q, size_t N) {
11+ auto *array = sycl::malloc_device<char >(N, Q);
12+
13+ Q.submit ([&](sycl::handler &h) {
14+ h.parallel_for <class MyKernelR_4 >(
15+ sycl::nd_range<1 >(N, 1 ),
16+ [=](sycl::nd_item<1 > item) { ++array[item.get_global_id (0 )]; });
17+ }).wait ();
18+ }
19+
20+ #else
21+
22+ void test (sycl::queue &Q, size_t N);
23+
24+ int main () {
25+ sycl::queue Q;
26+ constexpr std::size_t N = 12 ;
27+
28+ test (Q, N);
29+
30+ // CHECK: ERROR: DeviceSanitizer: detected memory leaks of Device USM
31+ // CHECK: Direct leak of 12 byte(s) at {{0x.*}} allocated from:
32+ // CHECK: in test{{.*memory-leak-shared-lib.cpp:}}[[@LINE-21]]
33+
34+ return 0 ;
35+ }
36+
37+ #endif
You can’t perform that action at this time.
0 commit comments