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

[SYCL] Tests for events caching mode in the L0 plugin #1121

Merged
merged 2 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
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
27 changes: 27 additions & 0 deletions SYCL/Plugin/level_zero_events_caching.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// REQUIRES: gpu, level_zero
// TODO: There is a known issue that ZE_DEBUG=4 produces flaky output on
// Windows.
// UNSUPPORTED: windows

// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
// RUN: env SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS=0 ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out 2>&1 | FileCheck --check-prefixes=CACHING-ENABLED %s
// RUN: env SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS=0 SYCL_PI_LEVEL_ZERO_DISABLE_EVENTS_CACHING=1 ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out 2>&1 | FileCheck --check-prefixes=CACHING-DISABLED %s

// CACHING-ENABLED: zeEventCreate = 1
// CACHING-DISABLED: zeEventCreate = 256

// Check event caching modes in the L0 plugin.

#include <CL/sycl.hpp>

int main() {
cl::sycl::queue deviceQueue;

for (int i = 0; i < 256; i++) {
auto Event = deviceQueue.submit([&](cl::sycl::handler &cgh) {
cgh.single_task<class SimpleKernel>([=]() {});
});
Event.wait();
}
return 0;
}
41 changes: 41 additions & 0 deletions SYCL/Plugin/level_zero_events_caching_leak.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// REQUIRES: gpu, level_zero
// TODO: There is a known issue that ZE_DEBUG=4 produces flaky output on
// Windows.
// UNSUPPORTED: windows

// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
// RUN: env ZE_MAX_NUMBER_OF_EVENTS_PER_EVENT_POOL=4 ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out
// RUN: env SYCL_PI_LEVEL_ZERO_DISABLE_EVENTS_CACHING=1 ZE_MAX_NUMBER_OF_EVENTS_PER_EVENT_POOL=4 ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out

// Check that events and pools are not leaked when event caching is
// enabled/disabled.

#include <CL/sycl.hpp>
#include <array>

constexpr cl::sycl::access::mode sycl_read = cl::sycl::access::mode::read;
constexpr cl::sycl::access::mode sycl_write = cl::sycl::access::mode::write;

int main() {
cl::sycl::queue deviceQueue;

const size_t array_size = 4;
std::array<int, array_size> A = {{1, 2, 3, 4}}, B = {{1, 2, 3, 4}}, C;
cl::sycl::range<1> numOfItems{array_size};
cl::sycl::buffer<int, 1> bufferA(A.data(), numOfItems);
cl::sycl::buffer<int, 1> bufferB(B.data(), numOfItems);
cl::sycl::buffer<int, 1> bufferC(C.data(), numOfItems);

for (int i = 0; i < 256; i++) {
deviceQueue.submit([&](cl::sycl::handler &cgh) {
auto accessorA = bufferA.get_access<sycl_read>(cgh);
auto accessorB = bufferB.get_access<sycl_read>(cgh);
auto accessorC = bufferC.get_access<sycl_write>(cgh);

cgh.parallel_for<class SimpleVadd>(numOfItems, [=](cl::sycl::id<1> wiID) {
accessorC[wiID] = accessorA[wiID] + accessorB[wiID];
});
});
}
return 0;
}