|
| 1 | +// RUN: %clangxx -fsycl %s -o %t.out -lOpenCL |
| 2 | +// RUN: env SYCL_DEVICE_TYPE=HOST %t.out |
| 3 | +// RUN: env SYCL_PI_TRACE=1 %CPU_RUN_PLACEHOLDER %t.out 2>&1 %CPU_CHECK_PLACEHOLDER |
| 4 | +// RUN: env SYCL_PI_TRACE=1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER |
| 5 | +// RUN: env SYCL_PI_TRACE=1 %ACC_RUN_PLACEHOLDER %t.out 2>&1 %ACC_CHECK_PLACEHOLDER |
| 6 | + |
| 7 | +//==-------------- image_access.cpp - SYCL image accessors test -----------==// |
| 8 | +// |
| 9 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 10 | +// See https://llvm.org/LICENSE.txt for license information. |
| 11 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 12 | +// |
| 13 | +//===----------------------------------------------------------------------===// |
| 14 | + |
| 15 | +#include <CL/sycl.hpp> |
| 16 | + |
| 17 | +int main() { |
| 18 | + try { |
| 19 | + cl::sycl::range<1> Range(32); |
| 20 | + std::vector<cl_float> Data(Range.size() * 4, 0.0f); |
| 21 | + cl::sycl::image<1> Image(Data.data(), cl::sycl::image_channel_order::rgba, |
| 22 | + cl::sycl::image_channel_type::fp32, Range); |
| 23 | + cl::sycl::queue Queue; |
| 24 | + |
| 25 | + Queue.submit([&](cl::sycl::handler &CGH) { |
| 26 | + cl::sycl::accessor<cl_int4, 1, cl::sycl::access::mode::read, |
| 27 | + cl::sycl::access::target::image, |
| 28 | + cl::sycl::access::placeholder::false_t> |
| 29 | + A(Image, CGH); |
| 30 | + CGH.single_task<class MyKernel>([=]() {}); |
| 31 | + }); |
| 32 | + Queue.wait_and_throw(); |
| 33 | + |
| 34 | + cl::sycl::accessor<cl_int4, 1, cl::sycl::access::mode::read, |
| 35 | + cl::sycl::access::target::host_image, |
| 36 | + cl::sycl::access::placeholder::false_t> |
| 37 | + A(Image); |
| 38 | + } catch (cl::sycl::exception &E) { |
| 39 | + std::cout << E.what(); |
| 40 | + } |
| 41 | + return 0; |
| 42 | +} |
| 43 | + |
| 44 | +// CHECK: PI ---> (NewMem = RT::piMemImageCreate(TargetContext->getHandleRef(), CreationFlags, &Format, &Desc, UserPtr, &Error), Error) |
| 45 | +// CHECK: PI ---> RT::piEnqueueMemImageRead( Queue, SrcMem, CL_FALSE, &SrcOffset[0], &SrcAccessRange[0], RowPitch, SlicePitch, DstMem, DepEvents.size(), &DepEvents[0], &OutEvent) |
0 commit comments