Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit c8eaa9b

Browse files
[SYCL][L0] check for no event leaks (#329)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent f91e684 commit c8eaa9b

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

SYCL/Plugin/level-zero-event-leak.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// REQUIRES: level_zero, level_zero_dev_kit
2+
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
3+
// RUN: env SYCL_DEVICE_FILTER=level_zero ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out
4+
//
5+
// CHECK-NOT: ---> LEAK
6+
7+
// The test is to check that there are no leaks reported with the embedded
8+
// ZE_DEBUG=4 testing capability. Example of a leak reported is this:
9+
//
10+
// clang-format off
11+
// ZE_DEBUG=4: check balance of create/destroy calls
12+
// ----------------------------------------------------------
13+
// zeContextCreate = 1 \---> zeContextDestroy = 1
14+
// zeCommandQueueCreate = 1 \---> zeCommandQueueDestroy = 0 ---> LEAK = 1
15+
// zeModuleCreate = 1 \---> zeModuleDestroy = 0 ---> LEAK = 1
16+
// zeKernelCreate = 1 \---> zeKernelDestroy = 0 ---> LEAK = 1
17+
// zeEventPoolCreate = 1 \---> zeEventPoolDestroy = 1
18+
// zeCommandListCreateImmediate = 1 |
19+
// zeCommandListCreate = 2 \---> zeCommandListDestroy = 2 ---> LEAK = 1
20+
// zeEventCreate = 129 \---> zeEventDestroy = 1 ---> LEAK = 128
21+
// zeFenceCreate = 2 \---> zeFenceDestroy = 0 ---> LEAK = 2
22+
// zeImageCreate = 0 \---> zeImageDestroy = 0
23+
// zeSamplerCreate = 0 \---> zeSamplerDestroy = 0
24+
// zeMemAllocDevice = 0 |
25+
// zeMemAllocHost = 0 |
26+
// zeMemAllocShared = 0 \---> zeMemFree = 0
27+
//
28+
// clang-format on
29+
//
30+
// NOTE: The 1000 value below is to be larger than the "128" heuristic in
31+
// queue_impl::addSharedEvent.
32+
33+
#include <CL/sycl.hpp>
34+
using namespace cl;
35+
int main(int argc, char **argv) {
36+
sycl::queue Q;
37+
const unsigned n_chunk = 1000;
38+
for (int i = 0; i < n_chunk; i++)
39+
Q.single_task([=]() {});
40+
Q.wait();
41+
return 0;
42+
}

0 commit comments

Comments
 (0)