@@ -18,8 +18,6 @@ template <typename T> class Modifier;
18
18
19
19
template <typename T> class Init ;
20
20
21
- template <bool B, typename T> class NameGen ;
22
-
23
21
template <typename BufferT, typename ValueT>
24
22
void checkBufferValues (BufferT Buffer, ValueT Value) {
25
23
auto Acc = Buffer.template get_access <mode::read>();
@@ -32,7 +30,7 @@ void checkBufferValues(BufferT Buffer, ValueT Value) {
32
30
}
33
31
}
34
32
35
- template <bool UseSYCL2020HostTask, typename DataT>
33
+ template <typename DataT>
36
34
void copy (buffer<DataT, 1 > &Src, buffer<DataT, 1 > &Dst, queue &Q) {
37
35
Q.submit ([&](handler &CGH) {
38
36
auto SrcA = Src.template get_access <mode::read>(CGH);
@@ -61,10 +59,7 @@ void copy(buffer<DataT, 1> &Src, buffer<DataT, 1> &Dst, queue &Q) {
61
59
" interop_handle::get_backend() returned a wrong value" ,
62
60
CL_INVALID_VALUE);
63
61
};
64
- if constexpr (UseSYCL2020HostTask)
65
- CGH.host_task (Func);
66
- else
67
- CGH.codeplay_host_task (Func);
62
+ CGH.host_task (Func);
68
63
});
69
64
}
70
65
@@ -96,7 +91,7 @@ void init(buffer<DataT, 1> &B1, buffer<DataT, 1> &B2, queue &Q) {
96
91
// kernel that modifies the data in place for B, e.g. increment one, then copy
97
92
// back to buffer A. Run it on a loop, to ensure the dependencies and the
98
93
// reference counting of the objects is not leaked.
99
- template < bool UseSYCL2020HostTask> void test1 (queue &Q) {
94
+ void test1 (queue &Q) {
100
95
static constexpr int COUNT = 4 ;
101
96
buffer<int , 1 > Buffer1{BUFFER_SIZE};
102
97
buffer<int , 1 > Buffer2{BUFFER_SIZE};
@@ -106,9 +101,9 @@ template <bool UseSYCL2020HostTask> void test1(queue &Q) {
106
101
107
102
// Repeat a couple of times
108
103
for (size_t Idx = 0 ; Idx < COUNT; ++Idx) {
109
- copy<UseSYCL2020HostTask> (Buffer1, Buffer2, Q);
104
+ copy (Buffer1, Buffer2, Q);
110
105
modify (Buffer2, Q);
111
- copy<UseSYCL2020HostTask> (Buffer2, Buffer1, Q);
106
+ copy (Buffer2, Buffer1, Q);
112
107
}
113
108
114
109
checkBufferValues (Buffer1, COUNT - 1 );
@@ -118,7 +113,7 @@ template <bool UseSYCL2020HostTask> void test1(queue &Q) {
118
113
// Same as above, but performing each command group on a separate SYCL queue
119
114
// (on the same or different devices). This ensures the dependency tracking
120
115
// works well but also there is no accidental side effects on other queues.
121
- template < bool UseSYCL2020HostTask> void test2 (queue &Q) {
116
+ void test2 (queue &Q) {
122
117
static constexpr int COUNT = 4 ;
123
118
buffer<int , 1 > Buffer1{BUFFER_SIZE};
124
119
buffer<int , 1 > Buffer2{BUFFER_SIZE};
@@ -128,16 +123,16 @@ template <bool UseSYCL2020HostTask> void test2(queue &Q) {
128
123
129
124
// Repeat a couple of times
130
125
for (size_t Idx = 0 ; Idx < COUNT; ++Idx) {
131
- copy<UseSYCL2020HostTask> (Buffer1, Buffer2, Q);
126
+ copy (Buffer1, Buffer2, Q);
132
127
modify (Buffer2, Q);
133
- copy<UseSYCL2020HostTask> (Buffer2, Buffer1, Q);
128
+ copy (Buffer2, Buffer1, Q);
134
129
}
135
130
checkBufferValues (Buffer1, COUNT - 1 );
136
131
checkBufferValues (Buffer2, COUNT - 1 );
137
132
}
138
133
139
134
// Same as above but with queue constructed out of context
140
- template < bool UseSYCL2020HostTask> void test2_1 (queue &Q) {
135
+ void test2_1 (queue &Q) {
141
136
static constexpr int COUNT = 4 ;
142
137
buffer<int , 1 > Buffer1{BUFFER_SIZE};
143
138
buffer<int , 1 > Buffer2{BUFFER_SIZE};
@@ -149,9 +144,9 @@ template <bool UseSYCL2020HostTask> void test2_1(queue &Q) {
149
144
150
145
// Repeat a couple of times
151
146
for (size_t Idx = 0 ; Idx < COUNT; ++Idx) {
152
- copy<UseSYCL2020HostTask> (Buffer1, Buffer2, Q);
147
+ copy (Buffer1, Buffer2, Q);
153
148
modify (Buffer2, Q);
154
- copy<UseSYCL2020HostTask> (Buffer2, Buffer1, Q);
149
+ copy (Buffer2, Buffer1, Q);
155
150
}
156
151
checkBufferValues (Buffer1, COUNT - 1 );
157
152
checkBufferValues (Buffer2, COUNT - 1 );
@@ -161,15 +156,15 @@ template <bool UseSYCL2020HostTask> void test2_1(queue &Q) {
161
156
// captured outside the command group. The OpenCL event can be set after the
162
157
// command group finishes. Must not deadlock according to implementation and
163
158
// proposal
164
- template < bool UseSYCL2020HostTask> void test3 (queue &Q) {
159
+ void test3 (queue &Q) {
165
160
// Want some large buffer for operation to take long
166
161
buffer<int , 1 > Buffer{BUFFER_SIZE * 128 };
167
162
168
163
event Event = Q.submit ([&](handler &CGH) {
169
164
auto Acc1 = Buffer.get_access <mode::write>(CGH);
170
165
171
- CGH.parallel_for <NameGen<UseSYCL2020HostTask, class Init3 >>(
172
- BUFFER_SIZE, [=](item<1 > Id) { Acc1[Id] = 123 ; });
166
+ CGH.parallel_for <class Init3 >(BUFFER_SIZE,
167
+ [=](item<1 > Id) { Acc1[Id] = 123 ; });
173
168
});
174
169
175
170
Q.submit ([&](handler &CGH) {
@@ -181,40 +176,33 @@ template <bool UseSYCL2020HostTask> void test3(queue &Q) {
181
176
if (RC != CL_SUCCESS)
182
177
throw runtime_error (" Can't wait for events" , RC);
183
178
};
184
- if constexpr (UseSYCL2020HostTask)
185
- CGH.host_task (Func);
186
- else
187
- CGH.codeplay_host_task (Func);
179
+ CGH.host_task (Func);
188
180
});
189
181
}
190
182
191
183
// Check that a single host-interop-task with a buffer will work
192
- template < bool UseSYCL2020HostTask> void test4 (queue &Q) {
184
+ void test4 (queue &Q) {
193
185
buffer<int , 1 > Buffer{BUFFER_SIZE};
194
186
195
187
Q.submit ([&](handler &CGH) {
196
188
auto Acc = Buffer.get_access <mode::write>(CGH);
197
189
auto Func = [=](interop_handle IH) { /* A no-op */ };
198
- if constexpr (UseSYCL2020HostTask)
199
- CGH.host_task (Func);
200
- else
201
- CGH.codeplay_host_task (Func);
190
+ CGH.host_task (Func);
202
191
});
203
192
}
204
193
205
- template < bool UseSYCL2020HostTask> void test5 (queue &Q) {
194
+ void test5 (queue &Q) {
206
195
buffer<int , 1 > Buffer1{BUFFER_SIZE};
207
196
buffer<int , 1 > Buffer2{BUFFER_SIZE};
208
197
209
198
Q.submit ([&](handler &CGH) {
210
199
auto Acc = Buffer1.template get_access <mode::write>(CGH);
211
200
212
201
auto Kernel = [=](item<1 > Id) { Acc[Id] = 123 ; };
213
- CGH.parallel_for <NameGen<UseSYCL2020HostTask, class Test5Init >>(
214
- Acc.get_count (), Kernel);
202
+ CGH.parallel_for <class Test5Init >(Acc.get_count (), Kernel);
215
203
});
216
204
217
- copy<UseSYCL2020HostTask> (Buffer1, Buffer2, Q);
205
+ copy (Buffer1, Buffer2, Q);
218
206
219
207
checkBufferValues (Buffer2, static_cast <int >(123 ));
220
208
}
@@ -223,7 +211,7 @@ template <bool UseSYCL2020HostTask> void test5(queue &Q) {
223
211
// when properly registered in the command group.
224
212
// It also checks that an exception is thrown if the placeholder accessor
225
213
// is not registered.
226
- template < bool UseSYCL2020HostTask> void test6 (queue &Q) {
214
+ void test6 (queue &Q) {
227
215
// Placeholder accessor that is properly registered in CGH.
228
216
try {
229
217
size_t size = 1 ;
@@ -233,8 +221,7 @@ template <bool UseSYCL2020HostTask> void test6(queue &Q) {
233
221
PHAcc (Buf);
234
222
Q.submit ([&](sycl::handler &CGH) {
235
223
CGH.require (PHAcc);
236
- CGH.codeplay_host_task (
237
- [=](interop_handle IH) { (void )IH.get_native_mem (PHAcc); });
224
+ CGH.host_task ([=](interop_handle IH) { (void )IH.get_native_mem (PHAcc); });
238
225
});
239
226
Q.wait_and_throw ();
240
227
} catch (sycl::exception &E) {
@@ -251,10 +238,7 @@ template <bool UseSYCL2020HostTask> void test6(queue &Q) {
251
238
PHAcc (Buf);
252
239
Q.submit ([&](sycl::handler &CGH) {
253
240
auto Func = [=](interop_handle IH) { (void )IH.get_native_mem (PHAcc); };
254
- if constexpr (UseSYCL2020HostTask)
255
- CGH.host_task (Func);
256
- else
257
- CGH.codeplay_host_task (Func);
241
+ CGH.host_task (Func);
258
242
});
259
243
Q.wait_and_throw ();
260
244
assert (!" Expected exception was not caught" );
@@ -265,14 +249,14 @@ template <bool UseSYCL2020HostTask> void test6(queue &Q) {
265
249
}
266
250
}
267
251
268
- template < bool UseSYCL2020HostTask> void tests (queue &Q) {
269
- test1<UseSYCL2020HostTask> (Q);
270
- test2<UseSYCL2020HostTask> (Q);
271
- test2_1<UseSYCL2020HostTask> (Q);
272
- test3<UseSYCL2020HostTask> (Q);
273
- test4<UseSYCL2020HostTask> (Q);
274
- test5<UseSYCL2020HostTask> (Q);
275
- test6<UseSYCL2020HostTask> (Q);
252
+ void tests (queue &Q) {
253
+ test1 (Q);
254
+ test2 (Q);
255
+ test2_1 (Q);
256
+ test3 (Q);
257
+ test4 (Q);
258
+ test5 (Q);
259
+ test6 (Q);
276
260
}
277
261
278
262
int main () {
@@ -283,8 +267,8 @@ int main() {
283
267
}
284
268
std::rethrow_exception (*ExceptionList.begin ());
285
269
});
286
- tests< true > (Q);
287
- tests< false > (Q);
270
+ tests (Q);
271
+ tests (Q);
288
272
std::cout << " Test PASSED" << std::endl;
289
273
return 0 ;
290
274
}
0 commit comments