|
| 1 | +// RUN: %{build} -o %t.out |
| 2 | +// RUN: %{run} %t.out |
| 3 | +// RUN: env SYCL_PI_TRACE=-1 %{run} %t.out 2>&1 | FileCheck %s |
| 4 | + |
| 5 | +#include <sycl/sycl.hpp> |
| 6 | + |
| 7 | +int main() { |
| 8 | + sycl::queue q; |
| 9 | + sycl::buffer<int, 1> b{1024}; |
| 10 | + sycl::id<1> start_offset{64}; |
| 11 | + size_t size = 16; |
| 12 | + sycl::buffer<int, 1> sub1{b, start_offset, sycl::range<1>{size}}; |
| 13 | + sycl::buffer<int, 1> sub2{b, start_offset, sycl::range<1>{size * 2}}; |
| 14 | + |
| 15 | + int idx = 0; |
| 16 | + for (auto &e : sycl::host_accessor{b}) |
| 17 | + e = idx++ % size; |
| 18 | + |
| 19 | + // CHECK: piMemBufferPartition |
| 20 | + // CHECK: pi_buffer_region origin/size : 256/64 |
| 21 | + q.submit([&](sycl::handler &cgh) { |
| 22 | + sycl::accessor acc{sub1, cgh}; |
| 23 | + cgh.parallel_for(size, [=](auto id) { acc[id] += 1; }); |
| 24 | + }); |
| 25 | + // CHECK: piMemBufferPartition |
| 26 | + // CHECK: pi_buffer_region origin/size : 256/128 |
| 27 | + q.submit([&](sycl::handler &cgh) { |
| 28 | + sycl::accessor acc{sub2, cgh}; |
| 29 | + cgh.parallel_for(size * 2, [=](auto id) { acc[id] -= 1; }); |
| 30 | + }); |
| 31 | + |
| 32 | + // Print before asserts to ensure stream is flushed. |
| 33 | + for (auto &e : sycl::host_accessor{sub2}) |
| 34 | + std::cout << e << " "; |
| 35 | + std::cout << std::endl; |
| 36 | + |
| 37 | + idx = 0; |
| 38 | + for (auto &e : sycl::host_accessor{sub2}) { |
| 39 | + assert(e == idx % size - idx / size); |
| 40 | + ++idx; |
| 41 | + } |
| 42 | + |
| 43 | + return 0; |
| 44 | +} |
0 commit comments