|
| 1 | +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o - |
| 2 | + |
| 3 | +// Test checks for that no compile errors occur for |
| 4 | +// builtin async_work_group_copy |
| 5 | +#include <sycl/sycl.hpp> |
| 6 | + |
| 7 | +using namespace cl::sycl; |
| 8 | + |
| 9 | +// Define the number of work items to enqueue. |
| 10 | +const size_t NElems = 32; |
| 11 | +const size_t WorkGroupSize = 8; |
| 12 | +const size_t NWorkGroups = NElems / WorkGroupSize; |
| 13 | + |
| 14 | +template <typename T> void async_work_group_test() { |
| 15 | + queue Q; |
| 16 | + |
| 17 | + buffer<T, 1> InBuf(NElems); |
| 18 | + buffer<T, 1> OutBuf(NElems); |
| 19 | + |
| 20 | + Q.submit([&](handler &CGH) { |
| 21 | + auto In = InBuf.template get_access<access::mode::read>(CGH); |
| 22 | + auto Out = OutBuf.template get_access<access::mode::write>(CGH); |
| 23 | + accessor<T, 1, access::mode::read_write, access::target::local> Local( |
| 24 | + range<1>{WorkGroupSize}, CGH); |
| 25 | + |
| 26 | + nd_range<1> NDR{range<1>(NElems), range<1>(WorkGroupSize)}; |
| 27 | + CGH.parallel_for(NDR, [=](nd_item<1> NDId) { |
| 28 | + auto GrId = NDId.get_group_linear_id(); |
| 29 | + auto Group = NDId.get_group(); |
| 30 | + size_t Offset = GrId * WorkGroupSize; |
| 31 | + auto E = NDId.async_work_group_copy( |
| 32 | + Local.get_pointer(), In.get_pointer() + Offset, WorkGroupSize); |
| 33 | + E = NDId.async_work_group_copy(Out.get_pointer() + Offset, |
| 34 | + Local.get_pointer(), WorkGroupSize); |
| 35 | + }); |
| 36 | + }).wait(); |
| 37 | +} |
| 38 | + |
| 39 | +template <typename T> void test() { |
| 40 | + async_work_group_test<T>(); |
| 41 | + async_work_group_test<vec<T, 2>>(); |
| 42 | + async_work_group_test<vec<T, 3>>(); |
| 43 | + async_work_group_test<vec<T, 4>>(); |
| 44 | + async_work_group_test<vec<T, 8>>(); |
| 45 | + async_work_group_test<vec<T, 16>>(); |
| 46 | + async_work_group_test<detail::make_unsigned_t<T>>(); |
| 47 | + async_work_group_test<vec<detail::make_unsigned_t<T>, 2>>(); |
| 48 | + async_work_group_test<vec<detail::make_unsigned_t<T>, 3>>(); |
| 49 | + async_work_group_test<vec<detail::make_unsigned_t<T>, 4>>(); |
| 50 | + async_work_group_test<vec<detail::make_unsigned_t<T>, 8>>(); |
| 51 | + async_work_group_test<vec<detail::make_unsigned_t<T>, 16>>(); |
| 52 | +} |
| 53 | + |
| 54 | +int main() { |
| 55 | + test<int8_t>(); |
| 56 | + test<int16_t>(); |
| 57 | + test<int32_t>(); |
| 58 | + test<int64_t>(); |
| 59 | + test<cl::sycl::cl_half>(); |
| 60 | + test<float>(); |
| 61 | + test<double>(); |
| 62 | + return 1; |
| 63 | +} |
0 commit comments