Skip to content

Commit f7ca993

Browse files
committed
Apply clang-format
1 parent a127155 commit f7ca993

File tree

4 files changed

+160
-173
lines changed

4 files changed

+160
-173
lines changed

sycl/test/basic_tests/image/image_read.cpp

Lines changed: 52 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121

2222
#include <iostream>
2323

24-
template <typename T>
25-
class test_1d_class;
26-
template <typename T>
27-
class test_2d_class;
28-
template <typename T>
29-
class test_3d_class;
24+
template <typename T> class test_1d_class;
25+
template <typename T> class test_2d_class;
26+
template <typename T> class test_3d_class;
3027

3128
namespace s = cl::sycl;
3229

@@ -36,18 +33,16 @@ bool test1d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
3633
dataT resultData;
3734

3835
{ // Scope everything to force destruction
39-
s::image<1> image(hostPtr, s::image_channel_order::rgba,
40-
channelType, s::range<1>{3});
36+
s::image<1> image(hostPtr, s::image_channel_order::rgba, channelType,
37+
s::range<1>{3});
4138

42-
s::buffer<dataT, 1> resultDataBuf(&resultData,
43-
s::range<1>(1));
39+
s::buffer<dataT, 1> resultDataBuf(&resultData, s::range<1>(1));
4440

4541
// Do the test by reading a single pixel from the image
4642
myQueue.submit([&](s::handler &cgh) {
47-
auto imageAcc =
48-
image.get_access<dataT, s::access::mode::read>(cgh);
49-
s::accessor<dataT, 1, s::access::mode::write>
50-
resultDataAcc(resultDataBuf, cgh);
43+
auto imageAcc = image.get_access<dataT, s::access::mode::read>(cgh);
44+
s::accessor<dataT, 1, s::access::mode::write> resultDataAcc(resultDataBuf,
45+
cgh);
5146

5247
cgh.single_task<test_1d_class<dataT>>([=]() {
5348
dataT RetColor = imageAcc.read(coord);
@@ -58,8 +53,8 @@ bool test1d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
5853
#ifdef DEBUG_OUTPUT
5954
std::cout << "Expected: " << expectedColour.r() << ", " << expectedColour.g()
6055
<< ", " << expectedColour.b() << ", " << expectedColour.a() << "\n";
61-
std::cout << "Got: " << resultData.r() << ", " << resultData.g()
62-
<< ", " << resultData.b() << ", " << resultData.a() << "\n";
56+
std::cout << "Got: " << resultData.r() << ", " << resultData.g() << ", "
57+
<< resultData.b() << ", " << resultData.a() << "\n";
6358
#endif // DEBUG_OUTPUT
6459
bool correct = true;
6560
if (resultData.r() != expectedColour.r())
@@ -79,18 +74,16 @@ bool test2d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
7974
dataT resultData;
8075

8176
{ // Scope everything to force destruction
82-
s::image<2> image(hostPtr, s::image_channel_order::rgba,
83-
channelType, s::range<2>{3, 3});
77+
s::image<2> image(hostPtr, s::image_channel_order::rgba, channelType,
78+
s::range<2>{3, 3});
8479

85-
s::buffer<dataT, 1> resultDataBuf(&resultData,
86-
s::range<1>(1));
80+
s::buffer<dataT, 1> resultDataBuf(&resultData, s::range<1>(1));
8781

8882
// Do the test by reading a single pixel from the image
8983
myQueue.submit([&](s::handler &cgh) {
90-
auto imageAcc =
91-
image.get_access<dataT, s::access::mode::read>(cgh);
92-
s::accessor<dataT, 1, s::access::mode::write>
93-
resultDataAcc(resultDataBuf, cgh);
84+
auto imageAcc = image.get_access<dataT, s::access::mode::read>(cgh);
85+
s::accessor<dataT, 1, s::access::mode::write> resultDataAcc(resultDataBuf,
86+
cgh);
9487

9588
cgh.single_task<test_2d_class<dataT>>([=]() {
9689
dataT RetColor = imageAcc.read(coord);
@@ -121,18 +114,16 @@ bool test3d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
121114
dataT resultData;
122115

123116
{ // Scope everything to force destruction
124-
s::image<3> image(hostPtr, s::image_channel_order::rgba,
125-
channelType, s::range<3>{3, 3, 3});
117+
s::image<3> image(hostPtr, s::image_channel_order::rgba, channelType,
118+
s::range<3>{3, 3, 3});
126119

127-
s::buffer<dataT, 1> resultDataBuf(&resultData,
128-
s::range<1>(1));
120+
s::buffer<dataT, 1> resultDataBuf(&resultData, s::range<1>(1));
129121

130122
// Do the test by reading a single pixel from the image
131123
myQueue.submit([&](s::handler &cgh) {
132-
auto imageAcc =
133-
image.get_access<dataT, s::access::mode::read>(cgh);
134-
s::accessor<dataT, 1, s::access::mode::write>
135-
resultDataAcc(resultDataBuf, cgh);
124+
auto imageAcc = image.get_access<dataT, s::access::mode::read>(cgh);
125+
s::accessor<dataT, 1, s::access::mode::write> resultDataAcc(resultDataBuf,
126+
cgh);
136127

137128
cgh.single_task<test_3d_class<dataT>>([=]() {
138129
dataT RetColor = imageAcc.read(coord);
@@ -143,8 +134,8 @@ bool test3d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
143134
#ifdef DEBUG_OUTPUT
144135
std::cout << "Expected: " << expectedColour.r() << ", " << expectedColour.g()
145136
<< ", " << expectedColour.b() << ", " << expectedColour.a() << "\n";
146-
std::cout << "Got: " << resultData.r() << ", " << resultData.g()
147-
<< ", " << resultData.b() << ", " << resultData.a() << "\n";
137+
std::cout << "Got: " << resultData.r() << ", " << resultData.g() << ", "
138+
<< resultData.b() << ", " << resultData.a() << "\n";
148139
#endif // DEBUG_OUTPUT
149140
bool correct = true;
150141
if (resultData.r() != expectedColour.r())
@@ -164,7 +155,8 @@ bool test1d(s::queue myQueue, coordT coord, dataT expectedResult) {
164155
for (int i = 0; i < 3; i++)
165156
hostPtr[i] = dataT(0 + i, 20 + i, 40 + i, 60 + i);
166157

167-
return test1d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord, expectedResult);
158+
return test1d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord,
159+
expectedResult);
168160
}
169161

170162
template <typename dataT, typename coordT, s::image_channel_type channelType>
@@ -173,7 +165,8 @@ bool test2d(s::queue myQueue, coordT coord, dataT expectedResult) {
173165
for (int i = 0; i < 9; i++)
174166
hostPtr[i] = dataT(0 + i, 20 + i, 40 + i, 60 + i);
175167

176-
return test2d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord, expectedResult);
168+
return test2d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord,
169+
expectedResult);
177170
}
178171

179172
template <typename dataT, typename coordT, s::image_channel_type channelType>
@@ -182,7 +175,8 @@ bool test3d(s::queue myQueue, coordT coord, dataT expectedResult) {
182175
for (int i = 0; i < 27; i++)
183176
hostPtr[i] = dataT(0 + i, 20 + i, 40 + i, 60 + i);
184177

185-
return test3d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord, expectedResult);
178+
return test3d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord,
179+
expectedResult);
186180
}
187181

188182
template <typename dataT, s::image_channel_type channelType>
@@ -199,45 +193,48 @@ bool test(s::queue myQueue) {
199193
passed = false;
200194

201195
// 2d image tests
202-
if (!test2d<dataT, s::int2, channelType>(myQueue, s::int2(0, 0), dataT(0, 20, 40, 60)))
196+
if (!test2d<dataT, s::int2, channelType>(myQueue, s::int2(0, 0),
197+
dataT(0, 20, 40, 60)))
203198
passed = false;
204199

205-
if (!test2d<dataT, s::int2, channelType>(myQueue, s::int2(1, 0), dataT(1, 21, 41, 61)))
200+
if (!test2d<dataT, s::int2, channelType>(myQueue, s::int2(1, 0),
201+
dataT(1, 21, 41, 61)))
206202
passed = false;
207203

208-
if (!test2d<dataT, s::int2, channelType>(myQueue, s::int2(0, 1), dataT(3, 23, 43, 63)))
204+
if (!test2d<dataT, s::int2, channelType>(myQueue, s::int2(0, 1),
205+
dataT(3, 23, 43, 63)))
209206
passed = false;
210207

211-
if (!test2d<dataT, s::int2, channelType>(myQueue, s::int2(1, 1), dataT(4, 24, 44, 64)))
208+
if (!test2d<dataT, s::int2, channelType>(myQueue, s::int2(1, 1),
209+
dataT(4, 24, 44, 64)))
212210
passed = false;
213211

214212
// 3d image tests
215-
if (!test3d<dataT, s::int4, channelType>(myQueue,
216-
s::int4(0, 0, 0, 0), dataT(0, 20, 40, 60)))
213+
if (!test3d<dataT, s::int4, channelType>(myQueue, s::int4(0, 0, 0, 0),
214+
dataT(0, 20, 40, 60)))
217215
passed = false;
218216

219-
if (!test3d<dataT, s::int4, channelType>(myQueue,
220-
s::int4(1, 0, 0, 0), dataT(1, 21, 41, 61)))
217+
if (!test3d<dataT, s::int4, channelType>(myQueue, s::int4(1, 0, 0, 0),
218+
dataT(1, 21, 41, 61)))
221219
passed = false;
222220

223-
if (!test3d<dataT, s::int4, channelType>(myQueue,
224-
s::int4(0, 1, 0, 0), dataT(3, 23, 43, 63)))
221+
if (!test3d<dataT, s::int4, channelType>(myQueue, s::int4(0, 1, 0, 0),
222+
dataT(3, 23, 43, 63)))
225223
passed = false;
226224

227-
if (!test3d<dataT, s::int4, channelType>(myQueue,
228-
s::int4(1, 1, 0, 0), dataT(4, 24, 44, 64)))
225+
if (!test3d<dataT, s::int4, channelType>(myQueue, s::int4(1, 1, 0, 0),
226+
dataT(4, 24, 44, 64)))
229227
passed = false;
230228

231-
if (!test3d<dataT, s::int4, channelType>(myQueue,
232-
s::int4(1, 0, 1, 0), dataT(10, 30, 50, 70)))
229+
if (!test3d<dataT, s::int4, channelType>(myQueue, s::int4(1, 0, 1, 0),
230+
dataT(10, 30, 50, 70)))
233231
passed = false;
234232

235-
if (!test3d<dataT, s::int4, channelType>(myQueue,
236-
s::int4(0, 1, 1, 0), dataT(12, 32, 52, 72)))
233+
if (!test3d<dataT, s::int4, channelType>(myQueue, s::int4(0, 1, 1, 0),
234+
dataT(12, 32, 52, 72)))
237235
passed = false;
238236

239-
if (!test3d<dataT, s::int4, channelType>(myQueue,
240-
s::int4(1, 1, 1, 0),
237+
if (!test3d<dataT, s::int4, channelType>(myQueue, s::int4(1, 1, 1, 0),
241238
dataT(13, 33, 53, 73)))
242239
passed = false;
243240

sycl/test/basic_tests/image/image_sample.cpp

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
/*
77
XFAIL CUDA due to driver bug.
8-
Newer CUDA drivers cannot build valid programs here, failing with CUDA_ERROR_NOT_FOUND.
8+
Newer CUDA drivers cannot build valid programs here, failing with
9+
CUDA_ERROR_NOT_FOUND.
910
*/
1011

1112
#include <CL/sycl.hpp>
@@ -41,30 +42,26 @@ bool check_result(dataT resultData, dataT expectedData, float epsilon = 0.1) {
4142
}
4243

4344
template <typename dataT, typename coordT, s::image_channel_type channelType>
44-
bool test1d_coord(dataT *hostPtr, coordT coord,
45-
dataT expectedColour) {
45+
bool test1d_coord(dataT *hostPtr, coordT coord, dataT expectedColour) {
4646
dataT resultData;
4747

4848
s::sampler testSampler(s::coordinate_normalization_mode::unnormalized,
49-
s::addressing_mode::clamp,
50-
s::filtering_mode::linear);
49+
s::addressing_mode::clamp, s::filtering_mode::linear);
5150

5251
s::default_selector selector;
5352

5453
{ // Scope everything to force destruction
55-
s::image<1> image(hostPtr, s::image_channel_order::rgba,
56-
channelType, s::range<1>{3});
54+
s::image<1> image(hostPtr, s::image_channel_order::rgba, channelType,
55+
s::range<1>{3});
5756

58-
s::buffer<dataT, 1> resultDataBuf(&resultData,
59-
s::range<1>(1));
57+
s::buffer<dataT, 1> resultDataBuf(&resultData, s::range<1>(1));
6058

6159
// Do the test by reading a single pixel from the image
6260
s::queue myQueue(selector);
6361
myQueue.submit([&](s::handler &cgh) {
64-
auto imageAcc =
65-
image.get_access<dataT, s::access::mode::read>(cgh);
66-
s::accessor<dataT, 1, s::access::mode::write>
67-
resultDataAcc(resultDataBuf, cgh);
62+
auto imageAcc = image.get_access<dataT, s::access::mode::read>(cgh);
63+
s::accessor<dataT, 1, s::access::mode::write> resultDataAcc(resultDataBuf,
64+
cgh);
6865

6966
cgh.single_task<test_1d_class>([=]() {
7067
dataT RetColor = imageAcc.read(coord, testSampler);
@@ -82,30 +79,26 @@ bool test1d_coord(dataT *hostPtr, coordT coord,
8279
}
8380

8481
template <typename dataT, typename coordT, s::image_channel_type channelType>
85-
bool test2d_coord(dataT *hostPtr, coordT coord,
86-
dataT expectedColour) {
82+
bool test2d_coord(dataT *hostPtr, coordT coord, dataT expectedColour) {
8783
dataT resultData;
8884

8985
s::sampler testSampler(s::coordinate_normalization_mode::unnormalized,
90-
s::addressing_mode::clamp,
91-
s::filtering_mode::linear);
86+
s::addressing_mode::clamp, s::filtering_mode::linear);
9287

9388
s::default_selector selector;
9489

9590
{ // Scope everything to force destruction
96-
s::image<2> image(hostPtr, s::image_channel_order::rgba,
97-
channelType, s::range<2>{3, 3});
91+
s::image<2> image(hostPtr, s::image_channel_order::rgba, channelType,
92+
s::range<2>{3, 3});
9893

99-
s::buffer<dataT, 1> resultDataBuf(&resultData,
100-
s::range<1>(1));
94+
s::buffer<dataT, 1> resultDataBuf(&resultData, s::range<1>(1));
10195

10296
// Do the test by reading a single pixel from the image
10397
s::queue myQueue(selector);
10498
myQueue.submit([&](s::handler &cgh) {
105-
auto imageAcc =
106-
image.get_access<dataT, s::access::mode::read>(cgh);
107-
s::accessor<dataT, 1, s::access::mode::write>
108-
resultDataAcc(resultDataBuf, cgh);
99+
auto imageAcc = image.get_access<dataT, s::access::mode::read>(cgh);
100+
s::accessor<dataT, 1, s::access::mode::write> resultDataAcc(resultDataBuf,
101+
cgh);
109102

110103
cgh.single_task<test_2d_class>([=]() {
111104
dataT RetColor = imageAcc.read(coord, testSampler);
@@ -123,30 +116,26 @@ bool test2d_coord(dataT *hostPtr, coordT coord,
123116
}
124117

125118
template <typename dataT, typename coordT, s::image_channel_type channelType>
126-
bool test3d_coord(dataT *hostPtr, coordT coord,
127-
dataT expectedColour) {
119+
bool test3d_coord(dataT *hostPtr, coordT coord, dataT expectedColour) {
128120
dataT resultData;
129121

130122
s::sampler testSampler(s::coordinate_normalization_mode::unnormalized,
131-
s::addressing_mode::clamp,
132-
s::filtering_mode::linear);
123+
s::addressing_mode::clamp, s::filtering_mode::linear);
133124

134125
s::default_selector selector;
135126

136127
{ // Scope everything to force destruction
137-
s::image<3> image(hostPtr, s::image_channel_order::rgba,
138-
channelType, s::range<3>{3, 3, 3});
128+
s::image<3> image(hostPtr, s::image_channel_order::rgba, channelType,
129+
s::range<3>{3, 3, 3});
139130

140-
s::buffer<dataT, 1> resultDataBuf(&resultData,
141-
s::range<1>(1));
131+
s::buffer<dataT, 1> resultDataBuf(&resultData, s::range<1>(1));
142132

143133
// Do the test by reading a single pixel from the image
144134
s::queue myQueue(selector);
145135
myQueue.submit([&](s::handler &cgh) {
146-
auto imageAcc =
147-
image.get_access<dataT, s::access::mode::read>(cgh);
148-
s::accessor<dataT, 1, s::access::mode::write>
149-
resultDataAcc(resultDataBuf, cgh);
136+
auto imageAcc = image.get_access<dataT, s::access::mode::read>(cgh);
137+
s::accessor<dataT, 1, s::access::mode::write> resultDataAcc(resultDataBuf,
138+
cgh);
150139

151140
cgh.single_task<test_3d_class>([=]() {
152141
dataT RetColor = imageAcc.read(coord, testSampler);
@@ -157,7 +146,8 @@ bool test3d_coord(dataT *hostPtr, coordT coord,
157146
bool correct = check_result(resultData, expectedColour);
158147
#ifdef DEBUG_OUTPUT
159148
if (!correct) {
160-
std::cout << "Coord: " << coord.x() << ", " << coord.y() << ", " << coord.z() << "\n";
149+
std::cout << "Coord: " << coord.x() << ", " << coord.y() << ", "
150+
<< coord.z() << "\n";
161151
}
162152
#endif // DEBUG_OUTPUT
163153
return correct;
@@ -168,23 +158,26 @@ bool test1d(coordT coord, dataT expectedResult) {
168158
dataT hostPtr[3];
169159
for (int i = 0; i < 3; i++)
170160
hostPtr[i] = dataT(0 + i, 20 + i, 40 + i, 60 + i);
171-
return test1d_coord<dataT, coordT, channelType>(hostPtr, coord, expectedResult);
161+
return test1d_coord<dataT, coordT, channelType>(hostPtr, coord,
162+
expectedResult);
172163
}
173164

174165
template <typename dataT, typename coordT, s::image_channel_type channelType>
175166
bool test2d(coordT coord, dataT expectedResult) {
176167
dataT hostPtr[9];
177168
for (int i = 0; i < 9; i++)
178169
hostPtr[i] = dataT(0 + i, 20 + i, 40 + i, 60 + i);
179-
return test2d_coord<dataT, coordT, channelType>(hostPtr, coord, expectedResult);
170+
return test2d_coord<dataT, coordT, channelType>(hostPtr, coord,
171+
expectedResult);
180172
}
181173

182174
template <typename dataT, typename coordT, s::image_channel_type channelType>
183175
bool test3d(coordT coord, dataT expectedResult) {
184176
dataT hostPtr[27];
185177
for (int i = 0; i < 27; i++)
186178
hostPtr[i] = dataT(0 + i, 20 + i, 40 + i, 60 + i);
187-
return test3d_coord<dataT, coordT, channelType>(hostPtr, coord, expectedResult);
179+
return test3d_coord<dataT, coordT, channelType>(hostPtr, coord,
180+
expectedResult);
188181
}
189182

190183
int main() {

0 commit comments

Comments
 (0)