Skip to content

Commit 6945759

Browse files
authored
[SYCL] Fix image_array.cpp on GPU (#17166)
Fix issue #15398 by adding group barriers between write and read statements. Also revised the parameters of the second write-read test case (from `42, 42` to `53, 55`) to prevent failures from it been covered by success of the first write-read test case. --------- Signed-off-by: peisenhu <peisen.hu@intel.com> Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
1 parent b2b0a3a commit 6945759

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

sycl/test-e2e/Basic/image/image_array.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// RUN: %{build} -o %t.out
55
// RUN: %{run} %t.out
66

7-
// UNSUPPORTED: gpu
8-
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/15398
9-
107
//==------------------- image.cpp - SYCL image basic test -----------------==//
118
//
129
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -18,6 +15,7 @@
1815
#include <sycl/accessor_image.hpp>
1916
#include <sycl/builtins.hpp>
2017
#include <sycl/detail/core.hpp>
18+
#include <sycl/group_barrier.hpp>
2119

2220
#include <iostream>
2321
#include <vector>
@@ -32,6 +30,7 @@ int main() {
3230
const sycl::image_channel_type ChanType = sycl::image_channel_type::fp32;
3331

3432
const sycl::range<2> ImgSize(4, 4);
33+
const sycl::nd_range<2> NDImgSize{ImgSize, ImgSize};
3534

3635
std::vector<sycl::float4> Img1HostData(ImgSize.size(), {1, 2, 3, 4});
3736

@@ -119,12 +118,13 @@ int main() {
119118

120119
auto ResAcc = ResBuf.get_access<SYCLReadWrite>(CGH);
121120

122-
CGH.parallel_for<class Check2>(ImgSize, [=](sycl::item<2> Item) {
123-
sycl::int2 CoordI{Item[0], Item[1]};
121+
CGH.parallel_for<class Check2>(NDImgSize, [=](sycl::nd_item<2> Item) {
122+
sycl::int2 CoordI{Item.get_global_id(0), Item.get_global_id(1)};
124123

125124
// CHeck that data written using image array
126125
const sycl::float4 ValRef{CoordI.x(), 42, 42, CoordI.y()};
127126
ImgArrayAcc[CoordI.y()].write((int)CoordI.x(), ValRef);
127+
sycl::group_barrier(Item.get_group());
128128
auto Val = ImgAcc.read(CoordI);
129129

130130
ResAcc[WRITE1] |= sycl::any(sycl::isnotequal(Val, ValRef));
@@ -139,12 +139,13 @@ int main() {
139139

140140
auto ResAcc = ResBuf.get_access<SYCLReadWrite>(CGH);
141141

142-
CGH.parallel_for<class Check3>(ImgSize, [=](sycl::item<2> Item) {
143-
sycl::int2 CoordI{Item[0], Item[1]};
142+
CGH.parallel_for<class Check3>(NDImgSize, [=](sycl::nd_item<2> Item) {
143+
sycl::int2 CoordI{Item.get_global_id(0), Item.get_global_id(1)};
144144

145145
// CHeck that data read using image array
146-
const sycl::float4 ValRef{CoordI.x(), 42, 42, CoordI.y()};
146+
const sycl::float4 ValRef{CoordI.x(), 53, 55, CoordI.y()};
147147
ImgAcc.write(CoordI, ValRef);
148+
sycl::group_barrier(Item.get_group());
148149
auto Val = ImgArrayAcc[CoordI.y()].read((int)CoordI.x());
149150

150151
ResAcc[WRITE2] |= sycl::any(sycl::isnotequal(Val, ValRef));

0 commit comments

Comments
 (0)