Skip to content

Commit f8828aa

Browse files
againullbb-sycl
authored andcommitted
[SYCL] Tests for events caching mode in the L0 plugin (intel#1121)
1 parent ac171d5 commit f8828aa

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// REQUIRES: gpu, level_zero
2+
// TODO: There is a known issue that ZE_DEBUG=4 produces flaky output on
3+
// Windows.
4+
// UNSUPPORTED: windows
5+
6+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
7+
// 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
8+
// 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
9+
10+
// CACHING-ENABLED: zeEventCreate = 1
11+
// CACHING-DISABLED: zeEventCreate = 256
12+
13+
// Check event caching modes in the L0 plugin.
14+
15+
#include <CL/sycl.hpp>
16+
17+
int main() {
18+
cl::sycl::queue deviceQueue;
19+
20+
for (int i = 0; i < 256; i++) {
21+
auto Event = deviceQueue.submit([&](cl::sycl::handler &cgh) {
22+
cgh.single_task<class SimpleKernel>([=]() {});
23+
});
24+
Event.wait();
25+
}
26+
return 0;
27+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// REQUIRES: gpu, level_zero
2+
// TODO: There is a known issue that ZE_DEBUG=4 produces flaky output on
3+
// Windows.
4+
// UNSUPPORTED: windows
5+
6+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
7+
// RUN: env ZE_MAX_NUMBER_OF_EVENTS_PER_EVENT_POOL=4 ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out
8+
// 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
9+
10+
// Check that events and pools are not leaked when event caching is
11+
// enabled/disabled.
12+
13+
#include <CL/sycl.hpp>
14+
#include <array>
15+
16+
constexpr cl::sycl::access::mode sycl_read = cl::sycl::access::mode::read;
17+
constexpr cl::sycl::access::mode sycl_write = cl::sycl::access::mode::write;
18+
19+
int main() {
20+
cl::sycl::queue deviceQueue;
21+
22+
const size_t array_size = 4;
23+
std::array<int, array_size> A = {{1, 2, 3, 4}}, B = {{1, 2, 3, 4}}, C;
24+
cl::sycl::range<1> numOfItems{array_size};
25+
cl::sycl::buffer<int, 1> bufferA(A.data(), numOfItems);
26+
cl::sycl::buffer<int, 1> bufferB(B.data(), numOfItems);
27+
cl::sycl::buffer<int, 1> bufferC(C.data(), numOfItems);
28+
29+
for (int i = 0; i < 256; i++) {
30+
deviceQueue.submit([&](cl::sycl::handler &cgh) {
31+
auto accessorA = bufferA.get_access<sycl_read>(cgh);
32+
auto accessorB = bufferB.get_access<sycl_read>(cgh);
33+
auto accessorC = bufferC.get_access<sycl_write>(cgh);
34+
35+
cgh.parallel_for<class SimpleVadd>(numOfItems, [=](cl::sycl::id<1> wiID) {
36+
accessorC[wiID] = accessorA[wiID] + accessorB[wiID];
37+
});
38+
});
39+
}
40+
return 0;
41+
}

0 commit comments

Comments
 (0)