Skip to content

Commit f78cf5f

Browse files
againullromanovvlad
authored andcommitted
[SYCL] Do not perform mapping/unmapping for 1D images (#418)
* [SYCL] Do not perform mapping/unmapping for 1D images Currently mapping is implemented only for buffers (clEnqueueMapBuffer). That is why simple copy operation should be called when dealing with images while mapping for images is not implemented. Signed-off-by: Artur Gainullin <[email protected]>
1 parent 96d4992 commit f78cf5f

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,10 @@ Command *Scheduler::GraphBuilder::addHostAccessor(Requirement *Req,
220220

221221
// In case of memory is 1 dimensional and located on OpenCL device we
222222
// can use map/unmap operation.
223+
// TODO: Implement mapping/unmapping for images
223224
if (!SrcQueue->is_host() && Req->MDims == 1 &&
224-
Req->MAccessRange == Req->MMemoryRange) {
225+
Req->MAccessRange == Req->MMemoryRange &&
226+
Req->MSYCLMemObj->getType() == detail::SYCLMemObjI::MemObjType::BUFFER) {
225227

226228
std::unique_ptr<MapMemObject> MapCmdUniquePtr(
227229
new MapMemObject(*SrcReq, SrcAllocaCmd, Req, SrcQueue));

sycl/test/regression/image_access.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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

Comments
 (0)