Skip to content

Commit ad056e0

Browse files
authored
[SYCLomatic] modify image help function cases to support cuda backend.
2 parents 84fd612 + 0d7c657 commit ad056e0

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

help_function/src/image_wrapper.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
#include <dpct/dpct.hpp>
1313

1414
dpct::image_wrapper<sycl::float4, 2> tex42;
15-
dpct::image_wrapper<sycl::char4, 1> tex_char4;
16-
dpct::image_wrapper<sycl::ushort4, 3> tex43;
15+
dpct::image_wrapper<sycl::int4, 1> tex_int4;
16+
dpct::image_wrapper<sycl::uint4, 3> tex43;
1717

1818
// test_feature:image_accessor_ext
1919
void test_image(sycl::float4* out, dpct::image_accessor_ext<sycl::float4, 2> acc42,
20-
dpct::image_accessor_ext<sycl::char4, 1> acc21,
21-
dpct::image_accessor_ext<sycl::ushort4, 3> acc13) {
20+
dpct::image_accessor_ext<sycl::int4, 1> acc21,
21+
dpct::image_accessor_ext<sycl::uint4, 3> acc13) {
2222
// test_feature:read
2323
out[0] = acc42.read(0.5f, 0.5f);
2424
// test_feature:read
25-
sycl::ushort4 data13 = acc13.read((uint64_t)3, (int)4, (short)5);
25+
sycl::uint4 data13 = acc13.read((uint64_t)3, (int)4, (short)5);
2626
// test_feature:read
27-
sycl::char4 data21 = acc21.read(0.5f);
27+
sycl::int4 data21 = acc21.read(0.5f);
2828
int a = data21.x();
2929
int b = data13.x();
3030
out[1] = {a,b,a,b};
@@ -33,21 +33,21 @@ void test_image(sycl::float4* out, dpct::image_accessor_ext<sycl::float4, 2> acc
3333
int main() {
3434

3535
sycl::float4 *host_buffer = new sycl::float4[640 * 480 * 24];
36-
sycl::char4 *host_char_buffer = new sycl::char4[640];
36+
sycl::int4 *host_char_buffer = new sycl::int4[640];
3737

3838
for(int i = 0; i < 640 * 480 * 24; ++i) {
3939
host_buffer[i] = sycl::float4{10.0f, 10.0f, 10.0f, 10.0f};
4040
if (i < 640)
41-
host_char_buffer[i] = sycl::char4{30, 30, 30, 30};
41+
host_char_buffer[i] = sycl::int4{30, 30, 30, 30};
4242
}
4343
sycl::float4 *device_buffer;
4444
device_buffer = (sycl::float4 *)dpct::dpct_malloc(
4545
640 * 480 * 24 * sizeof(sycl::float4));
4646
dpct::dpct_memcpy(device_buffer, host_buffer, 640 * 480 * 24 * sizeof(sycl::float4));
4747

4848
dpct::image_channel chn1 =
49-
dpct::image_channel(16, 16, 16, 16, dpct::image_channel_data_type::unsigned_int);
50-
dpct::image_channel chn2 = dpct::image_channel::create<sycl::char4>();
49+
dpct::image_channel(32, 32, 32, 32, dpct::image_channel_data_type::unsigned_int);
50+
dpct::image_channel chn2 = dpct::image_channel::create<sycl::int4>();
5151
dpct::image_channel chn4 =
5252
dpct::image_channel(32, 32, 32, 32, dpct::image_channel_data_type::fp);
5353
chn4.set_channel_size(4, 32);
@@ -62,9 +62,9 @@ int main() {
6262

6363
tex42.attach(image_data2, 640, 480, 650 * sizeof(sycl::float4));
6464

65-
dpct::dpct_memcpy(array1->to_pitched_data(), sycl::id<3>(0, 0, 0), dpct::pitched_data(host_buffer, 640 * sizeof(sycl::char4), 640 * sizeof(sycl::char4), 1), sycl::id<3>(0, 0, 0), sycl::range<3>(640 * sizeof(sycl::char4), 1, 1));
65+
dpct::dpct_memcpy(array1->to_pitched_data(), sycl::id<3>(0, 0, 0), dpct::pitched_data(host_buffer, 640 * sizeof(sycl::int4), 640 * sizeof(sycl::int4), 1), sycl::id<3>(0, 0, 0), sycl::range<3>(640 * sizeof(sycl::int4), 1, 1));
6666
dpct::dpct_memcpy(dpct::pitched_data(image_data2, 650 * sizeof(sycl::float4), 640 * sizeof(sycl::float4*), 480), sycl::id<3>(0, 0, 0), dpct::pitched_data(host_buffer, 640 * 480 * sizeof(sycl::float4), 640 * 480 * sizeof(sycl::float4), 1), sycl::id<3>(0, 0, 0), sycl::range<3>(640 * 480 * sizeof(sycl::float4), 1, 1));
67-
dpct::dpct_memcpy(array3->to_pitched_data(), sycl::id<3>(0, 0, 0), dpct::pitched_data(device_buffer, 640 * 480 * 24 * sizeof(sycl::ushort4), 640 * 480 * 24 * sizeof(sycl::ushort4), 1), sycl::id<3>(0, 0, 0), sycl::range<3>(640 * 480 * 24 * sizeof(sycl::ushort4), 1, 1));
67+
dpct::dpct_memcpy(array3->to_pitched_data(), sycl::id<3>(0, 0, 0), dpct::pitched_data(device_buffer, 640 * 480 * 24 * sizeof(sycl::uint4), 640 * 480 * 24 * sizeof(sycl::uint4), 1), sycl::id<3>(0, 0, 0), sycl::range<3>(640 * 480 * 24 * sizeof(sycl::uint4), 1, 1));
6868

6969
tex43.attach(array3);
7070

@@ -102,7 +102,7 @@ int main() {
102102
dpct::get_default_queue().submit([&](sycl::handler &cgh) {
103103
auto acc42 = tex42.get_access(cgh);
104104
auto acc13 = tex43.get_access(cgh);
105-
auto acc21 = static_cast<dpct::image_wrapper<sycl::char4, 1> *>(tex41)->get_access(cgh);
105+
auto acc21 = static_cast<dpct::image_wrapper<sycl::int4, 1> *>(tex41)->get_access(cgh);
106106

107107
auto smpl42 = tex42.get_sampler();
108108
auto smpl13 = tex43.get_sampler();
@@ -112,8 +112,8 @@ int main() {
112112

113113
cgh.single_task<dpct_kernel_name<class dpct_single_kernel>>([=] {
114114
test_image(acc_out.get_pointer(),dpct::image_accessor_ext<sycl::float4, 2>(smpl42, acc42),
115-
dpct::image_accessor_ext<sycl::char4, 1>(smpl21, acc21),
116-
dpct::image_accessor_ext<sycl::ushort4, 3>(smpl13, acc13));
115+
dpct::image_accessor_ext<sycl::int4, 1>(smpl21, acc21),
116+
dpct::image_accessor_ext<sycl::uint4, 3>(smpl13, acc13));
117117
});
118118
});
119119
}

help_function/src/image_wrapper_usm.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
dpct::image_wrapper<sycl::float4, 2> tex42;
1414
dpct::image_wrapper<sycl::float4, 1> tex41;
15-
dpct::image_wrapper<sycl::ushort4, 3> tex43;
15+
dpct::image_wrapper<sycl::uint4, 3> tex43;
1616

1717
void test_image(sycl::float4* out, dpct::image_accessor_ext<sycl::float4, 2> acc42,
1818
dpct::image_accessor_ext<sycl::float4, 1> acc21,
19-
dpct::image_accessor_ext<sycl::ushort4, 3> acc13) {
19+
dpct::image_accessor_ext<sycl::uint4, 3> acc13) {
2020
out[0] = acc42.read(0.5f, 0.5f);
21-
sycl::ushort4 data13 = acc13.read(0.5f, 0.5f, 0.5f);
21+
sycl::uint4 data13 = acc13.read(0.5f, 0.5f, 0.5f);
2222
sycl::float4 data21 = acc21.read(0.5f);
2323
out[1].x() = data21.x();
2424
out[1].y() = data13.x();
@@ -37,7 +37,7 @@ int main() {
3737
dpct::dpct_memcpy(device_buffer, host_buffer, 640 * 480 * 24 * sizeof(sycl::float4));
3838

3939
dpct::image_channel chn1 =
40-
dpct::image_channel(16, 16, 16, 16, dpct::image_channel_data_type::unsigned_int);
40+
dpct::image_channel(32, 32, 32, 32, dpct::image_channel_data_type::unsigned_int);
4141
dpct::image_channel chn2 =
4242
dpct::image_channel(32, 32, 32, 32, dpct::image_channel_data_type::fp);
4343
dpct::image_channel chn4 =
@@ -56,7 +56,7 @@ int main() {
5656

5757
dpct::dpct_memcpy(array1->to_pitched_data(), sycl::id<3>(0, 0, 0), dpct::pitched_data(host_buffer, 640 * sizeof(sycl::float4), 640 * sizeof(sycl::float4), 1), sycl::id<3>(0, 0, 0), sycl::range<3>(640 * sizeof(sycl::float4), 1, 1));
5858
dpct::dpct_memcpy(dpct::pitched_data(image_data2, 650 * sizeof(sycl::float4), 640 * sizeof(sycl::float4*), 480), sycl::id<3>(0, 0, 0), dpct::pitched_data(host_buffer, 640 * 480 * sizeof(sycl::float4), 640 * 480 * sizeof(sycl::float4), 1), sycl::id<3>(0, 0, 0), sycl::range<3>(640 * 480 * sizeof(sycl::float4), 1, 1));
59-
dpct::dpct_memcpy(array3->to_pitched_data(), sycl::id<3>(0, 0, 0), dpct::pitched_data(device_buffer, 640 * 480 * 24 * sizeof(sycl::ushort4), 640 * 480 * 24 * sizeof(sycl::ushort4), 1), sycl::id<3>(0, 0, 0), sycl::range<3>(640 * 480 * 24 * sizeof(sycl::ushort4), 1, 1));
59+
dpct::dpct_memcpy(array3->to_pitched_data(), sycl::id<3>(0, 0, 0), dpct::pitched_data(device_buffer, 640 * 480 * 24 * sizeof(sycl::uint4), 640 * 480 * 24 * sizeof(sycl::uint4), 1), sycl::id<3>(0, 0, 0), sycl::range<3>(640 * 480 * 24 * sizeof(sycl::uint4), 1, 1));
6060

6161
tex43.attach(array3);
6262

@@ -105,7 +105,7 @@ int main() {
105105
cgh.single_task<dpct_kernel_name<class dpct_single_kernel>>([=] {
106106
test_image(acc_out.get_pointer(),dpct::image_accessor_ext<sycl::float4, 2>(smpl42, acc42),
107107
dpct::image_accessor_ext<sycl::float4, 1>(smpl21, acc21),
108-
dpct::image_accessor_ext<sycl::ushort4, 3>(smpl13, acc13));
108+
dpct::image_accessor_ext<sycl::uint4, 3>(smpl13, acc13));
109109
});
110110
});
111111
}

0 commit comments

Comments
 (0)