Skip to content

Commit 049ae99

Browse files
authored
[SYCL] Align image class constructors with the SYCL spec (#2603)
Enable image construction with initialization data and const pitch parameters.
1 parent 69825ee commit 049ae99

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

sycl/include/CL/sycl/image.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class image {
155155
template <bool B = (Dimensions > 1)>
156156
image(void *HostPointer, image_channel_order Order, image_channel_type Type,
157157
const range<Dimensions> &Range,
158-
typename std::enable_if<B, range<Dimensions - 1>>::type &Pitch,
158+
const typename std::enable_if<B, range<Dimensions - 1>>::type &Pitch,
159159
const property_list &PropList = {}) {
160160
impl = std::make_shared<detail::image_impl<Dimensions>>(
161161
HostPointer, Order, Type, Range, Pitch,
@@ -167,7 +167,7 @@ class image {
167167
template <bool B = (Dimensions > 1)>
168168
image(void *HostPointer, image_channel_order Order, image_channel_type Type,
169169
const range<Dimensions> &Range,
170-
typename std::enable_if<B, range<Dimensions - 1>>::type &Pitch,
170+
const typename std::enable_if<B, range<Dimensions - 1>>::type &Pitch,
171171
AllocatorT Allocator, const property_list &PropList = {}) {
172172
impl = std::make_shared<detail::image_impl<Dimensions>>(
173173
HostPointer, Order, Type, Range, Pitch,

sycl/test/basic_tests/image.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ int main() {
7676
});
7777
}
7878

79+
{
80+
const sycl::range<1> ImgPitch(4 * 4 * 4 * 2);
81+
sycl::image<2> Img(Img1HostData.data(), ChanOrder, ChanType, Img1Size,
82+
ImgPitch);
83+
TestQueue Q{sycl::default_selector()};
84+
Q.submit([&](sycl::handler &CGH) {
85+
auto ImgAcc = Img.get_access<sycl::float4, SYCLRead>(CGH);
86+
CGH.single_task<class ConstTestPitch>([=] { ImgAcc.get_range(); });
87+
});
88+
}
89+
7990
// image with write accessor to it in kernel
8091
{
8192
int NX = 32;

0 commit comments

Comments
 (0)