22
22
23
23
#include < utility>
24
24
25
+ // having _TWO_ mid-param #ifdefs makes the functions very difficult to read.
26
+ // Here we simplify the &CodeLoc declaration to be _CODELOCPARAM(&CodeLoc) and
27
+ // _CODELOCARG(&CodeLoc) Similarly, the KernelFunc param is simplified to be
28
+ // _KERNELFUNCPARAM(KernelFunc) Once the queue kernel functions are defined,
29
+ // these macros are #undef immediately.
30
+
31
+ // replace _CODELOCPARAM(&CodeLoc) with nothing
32
+ // or : , const detail::code_location &CodeLoc =
33
+ // detail::code_location::current()
34
+ // replace _CODELOCARG(&CodeLoc) with nothing
35
+ // or : const detail::code_location &CodeLoc = {}
36
+
37
+ #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
38
+ #define _CODELOCONLYPARAM (a ) \
39
+ const detail::code_location a = detail::code_location::current()
40
+ #define _CODELOCPARAM (a ) \
41
+ , const detail::code_location a = detail::code_location::current()
42
+
43
+ #define _CODELOCARG (a )
44
+ #define _CODELOCFW (a ) , a
45
+ #else
46
+ #define _CODELOCONLYPARAM (a )
47
+ #define _CODELOCPARAM (a )
48
+
49
+ #define _CODELOCARG (a ) const detail::code_location a = {}
50
+ #define _CODELOCFW (a )
51
+ #endif
52
+
53
+ // replace _KERNELFUNCPARAM(KernelFunc) with KernelType KernelFunc
54
+ // or const KernelType &KernelFunc
55
+ #ifdef __SYCL_NONCONST_FUNCTOR__
56
+ #define _KERNELFUNCPARAM (a ) KernelType a
57
+ #else
58
+ #define _KERNELFUNCPARAM (a ) const KernelType &a
59
+ #endif
60
+
25
61
__SYCL_INLINE_NAMESPACE (cl) {
26
62
namespace sycl {
27
63
@@ -184,17 +220,9 @@ class __SYCL_EXPORT queue {
184
220
// / \param CGF is a function object containing command group.
185
221
// / \param CodeLoc is the code location of the submit call (default argument)
186
222
// / \return a SYCL event object for the submitted command group.
187
- template <typename T>
188
- event
189
- submit (T CGF
190
- #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
191
- ,
192
- const detail::code_location &CodeLoc = detail::code_location::current()
193
- #endif
194
- ) {
195
- #ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA
196
- const detail::code_location &CodeLoc = {};
197
- #endif
223
+ template <typename T> event submit (T CGF _CODELOCPARAM (&CodeLoc)) {
224
+ _CODELOCARG (&CodeLoc);
225
+
198
226
return submit_impl (CGF, CodeLoc);
199
227
}
200
228
@@ -210,16 +238,9 @@ class __SYCL_EXPORT queue {
210
238
// / \return a SYCL event object, which corresponds to the queue the command
211
239
// / group is being enqueued on.
212
240
template <typename T>
213
- event
214
- submit (T CGF, queue &SecondaryQueue
215
- #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
216
- ,
217
- const detail::code_location &CodeLoc = detail::code_location::current()
218
- #endif
219
- ) {
220
- #ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA
221
- const detail::code_location &CodeLoc = {};
222
- #endif
241
+ event submit (T CGF, queue &SecondaryQueue _CODELOCPARAM (&CodeLoc)) {
242
+ _CODELOCARG (&CodeLoc);
243
+
223
244
return submit_impl (CGF, SecondaryQueue, CodeLoc);
224
245
}
225
246
@@ -230,16 +251,8 @@ class __SYCL_EXPORT queue {
230
251
// / \param CodeLoc is the code location of the submit call (default argument)
231
252
// / \return a SYCL event object, which corresponds to the queue the command
232
253
// / group is being enqueued on.
233
- event submit_barrier (
234
- #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
235
- const detail::code_location &CodeLoc = detail::code_location::current()
236
- #endif
237
- ) {
238
- return submit ([=](handler &CGH) { CGH.barrier (); }
239
- #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
240
- , CodeLoc
241
- #endif
242
- );
254
+ event submit_barrier (_CODELOCONLYPARAM(&CodeLoc)) {
255
+ return submit ([=](handler &CGH) { CGH.barrier (); } _CODELOCFW (CodeLoc));
243
256
}
244
257
245
258
// / Prevents any commands submitted afterward to this queue from executing
@@ -251,33 +264,20 @@ class __SYCL_EXPORT queue {
251
264
// / \param CodeLoc is the code location of the submit call (default argument)
252
265
// / \return a SYCL event object, which corresponds to the queue the command
253
266
// / group is being enqueued on.
254
- event submit_barrier (
255
- const vector_class<event> &WaitList
256
- #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
257
- ,
258
- const detail::code_location &CodeLoc = detail::code_location::current()
259
- #endif
260
- ) {
261
- return submit ([=](handler &CGH) { CGH.barrier (WaitList); }
262
- #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
263
- , CodeLoc
264
- #endif
265
- );
267
+ event
268
+ submit_barrier (const vector_class<event> &WaitList _CODELOCPARAM (&CodeLoc)) {
269
+ return submit (
270
+ [=](handler &CGH) { CGH.barrier (WaitList); } _CODELOCFW (CodeLoc));
266
271
}
267
272
268
273
// / Performs a blocking wait for the completion of all enqueued tasks in the
269
274
// / queue.
270
275
// /
271
276
// / Synchronous errors will be reported through SYCL exceptions.
272
277
// / @param CodeLoc is the code location of the submit call (default argument)
273
- void wait (
274
- #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
275
- const detail::code_location &CodeLoc = detail::code_location::current()
276
- #endif
277
- ) {
278
- #ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA
279
- const detail::code_location &CodeLoc = {};
280
- #endif
278
+ void wait (_CODELOCONLYPARAM(&CodeLoc)) {
279
+ _CODELOCARG (&CodeLoc)
280
+
281
281
wait_proxy (CodeLoc);
282
282
}
283
283
@@ -289,14 +289,9 @@ class __SYCL_EXPORT queue {
289
289
// / construction. If no async_handler was provided then asynchronous
290
290
// / exceptions will be lost.
291
291
// / @param CodeLoc is the code location of the submit call (default argument)
292
- void wait_and_throw (
293
- #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
294
- const detail::code_location &CodeLoc = detail::code_location::current()
295
- #endif
296
- ) {
297
- #ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA
298
- const detail::code_location &CodeLoc = {};
299
- #endif
292
+ void wait_and_throw (_CODELOCONLYPARAM(&CodeLoc)) {
293
+ _CODELOCARG (&CodeLoc);
294
+
300
295
wait_and_throw_proxy (CodeLoc);
301
296
}
302
297
@@ -375,36 +370,6 @@ class __SYCL_EXPORT queue {
375
370
return submit ([=](handler &CGH) { CGH.prefetch (Ptr , Count); });
376
371
}
377
372
378
- // having _TWO_ mid-param #ifdefs makes the functions very difficult to read.
379
- // Here we simplify the &CodeLoc declaration to be _CODELOCPARAM(&CodeLoc) and
380
- // _CODELOCARG(&CodeLoc) Similarly, the KernelFunc param is simplified to be
381
- // _KERNELFUNCPARAM(KernelFunc) Once the queue kernel functions are defined,
382
- // these macros are #undef immediately.
383
-
384
- // replace _CODELOCPARAM(&CodeLoc) with nothing
385
- // or : , const detail::code_location &CodeLoc =
386
- // detail::code_location::current()
387
- // replace _CODELOCARG(&CodeLoc) with nothing
388
- // or : const detail::code_location &CodeLoc = {}
389
-
390
- #ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
391
- #define _CODELOCPARAM (a ) \
392
- , const detail::code_location a = detail::code_location::current()
393
-
394
- #define _CODELOCARG (a )
395
- #else
396
- #define _CODELOCPARAM (a )
397
-
398
- #define _CODELOCARG (a ) const detail::code_location a = {}
399
- #endif
400
- // replace _KERNELFUNCPARAM(KernelFunc) with KernelType KernelFunc
401
- // or const KernelType &KernelFunc
402
- #ifdef __SYCL_NONCONST_FUNCTOR__
403
- #define _KERNELFUNCPARAM (a ) KernelType a
404
- #else
405
- #define _KERNELFUNCPARAM (a ) const KernelType &a
406
- #endif
407
-
408
373
// / single_task version with a kernel represented as a lambda.
409
374
// /
410
375
// / \param KernelFunc is the Kernel functor or lambda
@@ -746,7 +711,9 @@ class __SYCL_EXPORT queue {
746
711
747
712
// Clean up CODELOC and KERNELFUNC macros.
748
713
#undef _CODELOCPARAM
714
+ #undef _CODELOCONLYPARAM
749
715
#undef _CODELOCARG
716
+ #undef _CODELOCFW
750
717
#undef _KERNELFUNCPARAM
751
718
752
719
// / Returns whether the queue is in order or OoO
0 commit comments