|
| 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