Skip to content

Commit 5750eaf

Browse files
AllanZynekbenzie
andauthored
[SYCL][E2E][DeviceSanitizer] Memory overhead statistics (#14592)
UR: oneapi-src/unified-runtime#1869 Statistic memory overhead (usm redzone + shadow memory) on each context, enabled by exporting asan flag UR_LAYER_ASAN_OPTIONS=print_stats:1. --------- Co-authored-by: Kenneth Benzie (Benie) <[email protected]>
1 parent 1dfc3d7 commit 5750eaf

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// REQUIRES: linux
2+
// RUN: %{build} %device_asan_flags -O2 -g -o %t
3+
// RUN: %{run} %t 2>&1 | FileCheck %s
4+
// RUN: env UR_LAYER_ASAN_OPTIONS=print_stats:1 %{run} %t 2>&1 | FileCheck --check-prefixes CHECK-STATS %s
5+
#include <sycl/usm.hpp>
6+
7+
/// This test is used to check enabling/disabling memory overhead statistics
8+
/// We always use "Stats" prefix in statistics message like asan
9+
10+
constexpr std::size_t N = 4;
11+
constexpr std::size_t group_size = 1;
12+
13+
int main() {
14+
sycl::queue Q;
15+
int *array = sycl::malloc_device<int>(1024 * 1024, Q);
16+
17+
Q.submit([&](sycl::handler &cgh) {
18+
auto acc = sycl::local_accessor<int>(group_size, cgh);
19+
cgh.parallel_for<class MyKernel>(
20+
sycl::nd_range<1>(N, group_size), [=](sycl::nd_item<1> item) {
21+
array[item.get_global_id()] = acc[item.get_local_id()];
22+
});
23+
});
24+
Q.wait();
25+
// CHECK-STATS: Stats
26+
// CHECK-NOT: Stats
27+
28+
sycl::free(array, Q);
29+
std::cout << "PASS" << std::endl;
30+
return 0;
31+
}

0 commit comments

Comments
 (0)