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