|
1 |
| -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out |
| 1 | +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out |
2 | 2 | // RUN: env SYCL_DEVICE_TYPE=HOST %t.out
|
3 | 3 | // RUN: %CPU_RUN_PLACEHOLDER %t.out
|
4 | 4 | // RUN: %GPU_RUN_PLACEHOLDER %t.out
|
|
19 | 19 | // 2) Exceptions if we trying to create sub buffer not according to spec
|
20 | 20 |
|
21 | 21 | #include <CL/sycl.hpp>
|
| 22 | + |
| 23 | +#include <algorithm> |
22 | 24 | #include <iostream>
|
23 | 25 | #include <numeric>
|
24 | 26 | #include <vector>
|
25 | 27 |
|
26 | 28 | void checkHostAccessor(cl::sycl::queue &q) {
|
27 |
| - std::size_t size = |
28 |
| - q.get_device().get_info<cl::sycl::info::device::mem_base_addr_align>() / |
29 |
| - 8; |
| 29 | + std::size_t subbuf_align = |
| 30 | + q.get_device().get_info<cl::sycl::info::device::mem_base_addr_align>() / 8; |
| 31 | + std::size_t size = std::max(subbuf_align, 10 * 2 * sizeof(int)); // hold at least 20 elements |
30 | 32 | size /= sizeof(int);
|
31 | 33 | size *= 2;
|
| 34 | + |
32 | 35 | std::vector<int> data(size);
|
33 | 36 | std::iota(data.begin(), data.end(), 0);
|
34 | 37 | {
|
@@ -59,9 +62,9 @@ void checkHostAccessor(cl::sycl::queue &q) {
|
59 | 62 | }
|
60 | 63 |
|
61 | 64 | void check1DSubBuffer(cl::sycl::queue &q) {
|
62 |
| - std::size_t size = |
63 |
| - q.get_device().get_info<cl::sycl::info::device::mem_base_addr_align>() / |
64 |
| - 8; |
| 65 | + std::size_t subbuf_align = |
| 66 | + q.get_device().get_info<cl::sycl::info::device::mem_base_addr_align>() / 8; |
| 67 | + std::size_t size = std::max(subbuf_align, 32 * sizeof(int)); // hold at least 32 elements |
65 | 68 | size /= sizeof(int);
|
66 | 69 | size *= 2;
|
67 | 70 |
|
@@ -201,7 +204,7 @@ void copyBlock() {
|
201 | 204 | using typename cl::sycl::access::mode;
|
202 | 205 | using buffer = cl::sycl::buffer<int, 1>;
|
203 | 206 |
|
204 |
| - auto CopyF = [](buffer& Buffer, buffer& Block, size_t Idx, size_t BlockSize) { |
| 207 | + auto CopyF = [](buffer &Buffer, buffer &Block, size_t Idx, size_t BlockSize) { |
205 | 208 | auto Subbuf = buffer(Buffer, Idx * BlockSize, BlockSize);
|
206 | 209 | auto *Src = Subbuf.get_access<mode::read>().get_pointer();
|
207 | 210 | auto *Dst = Block.get_access<mode::write>().get_pointer();
|
@@ -244,8 +247,7 @@ void copyBlock() {
|
244 | 247 | "Invalid data in block buffer");
|
245 | 248 | }
|
246 | 249 | }
|
247 |
| - } |
248 |
| - catch (cl::sycl::exception& ex) { |
| 250 | + } catch (cl::sycl::exception &ex) { |
249 | 251 | assert(false && "Unexpected exception captured!");
|
250 | 252 | }
|
251 | 253 | }
|
|
0 commit comments