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

[SYCL][L0] check for no event leaks #329

Merged
merged 5 commits into from
Jun 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions SYCL/Plugin/level-zero-event-leak.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// REQUIRES: level_zero, level_zero_dev_kit
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=level_zero ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out
//
// CHECK-NOT: ---> LEAK

// The test is to check that there are no leaks reported with the embedded
// ZE_DEBUG=4 testing capability. Example of a leak reported is this:
//
// clang-format off
// ZE_DEBUG=4: check balance of create/destroy calls
// ----------------------------------------------------------
// zeContextCreate = 1 \---> zeContextDestroy = 1
// zeCommandQueueCreate = 1 \---> zeCommandQueueDestroy = 0 ---> LEAK = 1
// zeModuleCreate = 1 \---> zeModuleDestroy = 0 ---> LEAK = 1
// zeKernelCreate = 1 \---> zeKernelDestroy = 0 ---> LEAK = 1
// zeEventPoolCreate = 1 \---> zeEventPoolDestroy = 1
// zeCommandListCreateImmediate = 1 |
// zeCommandListCreate = 2 \---> zeCommandListDestroy = 2 ---> LEAK = 1
// zeEventCreate = 129 \---> zeEventDestroy = 1 ---> LEAK = 128
// zeFenceCreate = 2 \---> zeFenceDestroy = 0 ---> LEAK = 2
// zeImageCreate = 0 \---> zeImageDestroy = 0
// zeSamplerCreate = 0 \---> zeSamplerDestroy = 0
// zeMemAllocDevice = 0 |
// zeMemAllocHost = 0 |
// zeMemAllocShared = 0 \---> zeMemFree = 0
//
// clang-format on
//
// NOTE: The 1000 value below is to be larger than the "128" heuristic in
// queue_impl::addSharedEvent.

#include <CL/sycl.hpp>
using namespace cl;
int main(int argc, char **argv) {
sycl::queue Q;
const unsigned n_chunk = 1000;
for (int i = 0; i < n_chunk; i++)
Q.single_task([=]() {});
Q.wait();
return 0;
}