21
21
22
22
#include < iostream>
23
23
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 ;
30
27
31
28
namespace s = cl::sycl;
32
29
@@ -36,18 +33,16 @@ bool test1d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
36
33
dataT resultData;
37
34
38
35
{ // 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 });
41
38
42
- s::buffer<dataT, 1 > resultDataBuf (&resultData,
43
- s::range<1 >(1 ));
39
+ s::buffer<dataT, 1 > resultDataBuf (&resultData, s::range<1 >(1 ));
44
40
45
41
// Do the test by reading a single pixel from the image
46
42
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);
51
46
52
47
cgh.single_task <test_1d_class<dataT>>([=]() {
53
48
dataT RetColor = imageAcc.read (coord);
@@ -58,8 +53,8 @@ bool test1d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
58
53
#ifdef DEBUG_OUTPUT
59
54
std::cout << " Expected: " << expectedColour.r () << " , " << expectedColour.g ()
60
55
<< " , " << 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 " ;
63
58
#endif // DEBUG_OUTPUT
64
59
bool correct = true ;
65
60
if (resultData.r () != expectedColour.r ())
@@ -79,18 +74,16 @@ bool test2d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
79
74
dataT resultData;
80
75
81
76
{ // 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 });
84
79
85
- s::buffer<dataT, 1 > resultDataBuf (&resultData,
86
- s::range<1 >(1 ));
80
+ s::buffer<dataT, 1 > resultDataBuf (&resultData, s::range<1 >(1 ));
87
81
88
82
// Do the test by reading a single pixel from the image
89
83
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);
94
87
95
88
cgh.single_task <test_2d_class<dataT>>([=]() {
96
89
dataT RetColor = imageAcc.read (coord);
@@ -121,18 +114,16 @@ bool test3d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
121
114
dataT resultData;
122
115
123
116
{ // 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 });
126
119
127
- s::buffer<dataT, 1 > resultDataBuf (&resultData,
128
- s::range<1 >(1 ));
120
+ s::buffer<dataT, 1 > resultDataBuf (&resultData, s::range<1 >(1 ));
129
121
130
122
// Do the test by reading a single pixel from the image
131
123
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);
136
127
137
128
cgh.single_task <test_3d_class<dataT>>([=]() {
138
129
dataT RetColor = imageAcc.read (coord);
@@ -143,8 +134,8 @@ bool test3d_coord(s::queue myQueue, dataT *hostPtr, coordT coord,
143
134
#ifdef DEBUG_OUTPUT
144
135
std::cout << " Expected: " << expectedColour.r () << " , " << expectedColour.g ()
145
136
<< " , " << 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 " ;
148
139
#endif // DEBUG_OUTPUT
149
140
bool correct = true ;
150
141
if (resultData.r () != expectedColour.r ())
@@ -164,7 +155,8 @@ bool test1d(s::queue myQueue, coordT coord, dataT expectedResult) {
164
155
for (int i = 0 ; i < 3 ; i++)
165
156
hostPtr[i] = dataT (0 + i, 20 + i, 40 + i, 60 + i);
166
157
167
- return test1d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord, expectedResult);
158
+ return test1d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord,
159
+ expectedResult);
168
160
}
169
161
170
162
template <typename dataT, typename coordT, s::image_channel_type channelType>
@@ -173,7 +165,8 @@ bool test2d(s::queue myQueue, coordT coord, dataT expectedResult) {
173
165
for (int i = 0 ; i < 9 ; i++)
174
166
hostPtr[i] = dataT (0 + i, 20 + i, 40 + i, 60 + i);
175
167
176
- return test2d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord, expectedResult);
168
+ return test2d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord,
169
+ expectedResult);
177
170
}
178
171
179
172
template <typename dataT, typename coordT, s::image_channel_type channelType>
@@ -182,7 +175,8 @@ bool test3d(s::queue myQueue, coordT coord, dataT expectedResult) {
182
175
for (int i = 0 ; i < 27 ; i++)
183
176
hostPtr[i] = dataT (0 + i, 20 + i, 40 + i, 60 + i);
184
177
185
- return test3d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord, expectedResult);
178
+ return test3d_coord<dataT, coordT, channelType>(myQueue, hostPtr, coord,
179
+ expectedResult);
186
180
}
187
181
188
182
template <typename dataT, s::image_channel_type channelType>
@@ -199,45 +193,48 @@ bool test(s::queue myQueue) {
199
193
passed = false ;
200
194
201
195
// 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 )))
203
198
passed = false ;
204
199
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 )))
206
202
passed = false ;
207
203
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 )))
209
206
passed = false ;
210
207
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 )))
212
210
passed = false ;
213
211
214
212
// 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 )))
217
215
passed = false ;
218
216
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 )))
221
219
passed = false ;
222
220
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 )))
225
223
passed = false ;
226
224
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 )))
229
227
passed = false ;
230
228
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 )))
233
231
passed = false ;
234
232
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 )))
237
235
passed = false ;
238
236
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 ),
241
238
dataT (13 , 33 , 53 , 73 )))
242
239
passed = false ;
243
240
0 commit comments