2222
2323#include < utility>
2424
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+
2561__SYCL_INLINE_NAMESPACE (cl) {
2662namespace sycl {
2763
@@ -184,17 +220,9 @@ class __SYCL_EXPORT queue {
184220 // / \param CGF is a function object containing command group.
185221 // / \param CodeLoc is the code location of the submit call (default argument)
186222 // / \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+
198226 return submit_impl (CGF, CodeLoc);
199227 }
200228
@@ -210,16 +238,9 @@ class __SYCL_EXPORT queue {
210238 // / \return a SYCL event object, which corresponds to the queue the command
211239 // / group is being enqueued on.
212240 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+
223244 return submit_impl (CGF, SecondaryQueue, CodeLoc);
224245 }
225246
@@ -230,16 +251,8 @@ class __SYCL_EXPORT queue {
230251 // / \param CodeLoc is the code location of the submit call (default argument)
231252 // / \return a SYCL event object, which corresponds to the queue the command
232253 // / 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));
243256 }
244257
245258 // / Prevents any commands submitted afterward to this queue from executing
@@ -251,33 +264,20 @@ class __SYCL_EXPORT queue {
251264 // / \param CodeLoc is the code location of the submit call (default argument)
252265 // / \return a SYCL event object, which corresponds to the queue the command
253266 // / 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));
266271 }
267272
268273 // / Performs a blocking wait for the completion of all enqueued tasks in the
269274 // / queue.
270275 // /
271276 // / Synchronous errors will be reported through SYCL exceptions.
272277 // / @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+
281281 wait_proxy (CodeLoc);
282282 }
283283
@@ -289,14 +289,9 @@ class __SYCL_EXPORT queue {
289289 // / construction. If no async_handler was provided then asynchronous
290290 // / exceptions will be lost.
291291 // / @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+
300295 wait_and_throw_proxy (CodeLoc);
301296 }
302297
@@ -375,36 +370,6 @@ class __SYCL_EXPORT queue {
375370 return submit ([=](handler &CGH) { CGH.prefetch (Ptr, Count); });
376371 }
377372
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-
408373 // / single_task version with a kernel represented as a lambda.
409374 // /
410375 // / \param KernelFunc is the Kernel functor or lambda
@@ -746,7 +711,9 @@ class __SYCL_EXPORT queue {
746711
747712// Clean up CODELOC and KERNELFUNC macros.
748713#undef _CODELOCPARAM
714+ #undef _CODELOCONLYPARAM
749715#undef _CODELOCARG
716+ #undef _CODELOCFW
750717#undef _KERNELFUNCPARAM
751718
752719 // / Returns whether the queue is in order or OoO
0 commit comments