diff --git a/sycl/include/CL/sycl/queue.hpp b/sycl/include/CL/sycl/queue.hpp index d2584b6d847c9..2e01a1fecb1b2 100644 --- a/sycl/include/CL/sycl/queue.hpp +++ b/sycl/include/CL/sycl/queue.hpp @@ -22,6 +22,42 @@ #include +// having _TWO_ mid-param #ifdefs makes the functions very difficult to read. +// Here we simplify the &CodeLoc declaration to be _CODELOCPARAM(&CodeLoc) and +// _CODELOCARG(&CodeLoc) Similarly, the KernelFunc param is simplified to be +// _KERNELFUNCPARAM(KernelFunc) Once the queue kernel functions are defined, +// these macros are #undef immediately. + +// replace _CODELOCPARAM(&CodeLoc) with nothing +// or : , const detail::code_location &CodeLoc = +// detail::code_location::current() +// replace _CODELOCARG(&CodeLoc) with nothing +// or : const detail::code_location &CodeLoc = {} + +#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA +#define _CODELOCONLYPARAM(a) \ + const detail::code_location a = detail::code_location::current() +#define _CODELOCPARAM(a) \ + , const detail::code_location a = detail::code_location::current() + +#define _CODELOCARG(a) +#define _CODELOCFW(a) , a +#else +#define _CODELOCONLYPARAM(a) +#define _CODELOCPARAM(a) + +#define _CODELOCARG(a) const detail::code_location a = {} +#define _CODELOCFW(a) +#endif + +// replace _KERNELFUNCPARAM(KernelFunc) with KernelType KernelFunc +// or const KernelType &KernelFunc +#ifdef __SYCL_NONCONST_FUNCTOR__ +#define _KERNELFUNCPARAM(a) KernelType a +#else +#define _KERNELFUNCPARAM(a) const KernelType &a +#endif + __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { @@ -182,17 +218,9 @@ class __SYCL_EXPORT queue { /// \param CGF is a function object containing command group. /// \param CodeLoc is the code location of the submit call (default argument) /// \return a SYCL event object for the submitted command group. - template - event - submit(T CGF -#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA - , - const detail::code_location &CodeLoc = detail::code_location::current() -#endif - ) { -#ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA - const detail::code_location &CodeLoc = {}; -#endif + template event submit(T CGF _CODELOCPARAM(&CodeLoc)) { + _CODELOCARG(&CodeLoc); + return submit_impl(CGF, CodeLoc); } @@ -208,16 +236,9 @@ class __SYCL_EXPORT queue { /// \return a SYCL event object, which corresponds to the queue the command /// group is being enqueued on. template - event - submit(T CGF, queue &SecondaryQueue -#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA - , - const detail::code_location &CodeLoc = detail::code_location::current() -#endif - ) { -#ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA - const detail::code_location &CodeLoc = {}; -#endif + event submit(T CGF, queue &SecondaryQueue _CODELOCPARAM(&CodeLoc)) { + _CODELOCARG(&CodeLoc); + return submit_impl(CGF, SecondaryQueue, CodeLoc); } @@ -228,16 +249,8 @@ class __SYCL_EXPORT queue { /// \param CodeLoc is the code location of the submit call (default argument) /// \return a SYCL event object, which corresponds to the queue the command /// group is being enqueued on. - event submit_barrier( -#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA - const detail::code_location &CodeLoc = detail::code_location::current() -#endif - ) { - return submit([=](handler &CGH) { CGH.barrier(); } -#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA - , CodeLoc -#endif - ); + event submit_barrier(_CODELOCONLYPARAM(&CodeLoc)) { + return submit([=](handler &CGH) { CGH.barrier(); } _CODELOCFW(CodeLoc)); } /// Prevents any commands submitted afterward to this queue from executing @@ -249,18 +262,10 @@ class __SYCL_EXPORT queue { /// \param CodeLoc is the code location of the submit call (default argument) /// \return a SYCL event object, which corresponds to the queue the command /// group is being enqueued on. - event submit_barrier( - const vector_class &WaitList -#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA - , - const detail::code_location &CodeLoc = detail::code_location::current() -#endif - ) { - return submit([=](handler &CGH) { CGH.barrier(WaitList); } -#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA - , CodeLoc -#endif - ); + event + submit_barrier(const vector_class &WaitList _CODELOCPARAM(&CodeLoc)) { + return submit( + [=](handler &CGH) { CGH.barrier(WaitList); } _CODELOCFW(CodeLoc)); } /// Performs a blocking wait for the completion of all enqueued tasks in the @@ -268,14 +273,9 @@ class __SYCL_EXPORT queue { /// /// Synchronous errors will be reported through SYCL exceptions. /// @param CodeLoc is the code location of the submit call (default argument) - void wait( -#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA - const detail::code_location &CodeLoc = detail::code_location::current() -#endif - ) { -#ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA - const detail::code_location &CodeLoc = {}; -#endif + void wait(_CODELOCONLYPARAM(&CodeLoc)) { + _CODELOCARG(&CodeLoc) + wait_proxy(CodeLoc); } @@ -287,14 +287,9 @@ class __SYCL_EXPORT queue { /// construction. If no async_handler was provided then asynchronous /// exceptions will be lost. /// @param CodeLoc is the code location of the submit call (default argument) - void wait_and_throw( -#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA - const detail::code_location &CodeLoc = detail::code_location::current() -#endif - ) { -#ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA - const detail::code_location &CodeLoc = {}; -#endif + void wait_and_throw(_CODELOCONLYPARAM(&CodeLoc)) { + _CODELOCARG(&CodeLoc); + wait_and_throw_proxy(CodeLoc); } @@ -373,36 +368,6 @@ class __SYCL_EXPORT queue { return submit([=](handler &CGH) { CGH.prefetch(Ptr, Count); }); } - // having _TWO_ mid-param #ifdefs makes the functions very difficult to read. - // Here we simplify the &CodeLoc declaration to be _CODELOCPARAM(&CodeLoc) and - // _CODELOCARG(&CodeLoc) Similarly, the KernelFunc param is simplified to be - // _KERNELFUNCPARAM(KernelFunc) Once the queue kernel functions are defined, - // these macros are #undef immediately. - - // replace _CODELOCPARAM(&CodeLoc) with nothing - // or : , const detail::code_location &CodeLoc = - // detail::code_location::current() - // replace _CODELOCARG(&CodeLoc) with nothing - // or : const detail::code_location &CodeLoc = {} - -#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA -#define _CODELOCPARAM(a) \ - , const detail::code_location a = detail::code_location::current() - -#define _CODELOCARG(a) -#else -#define _CODELOCPARAM(a) - -#define _CODELOCARG(a) const detail::code_location a = {} -#endif -// replace _KERNELFUNCPARAM(KernelFunc) with KernelType KernelFunc -// or const KernelType &KernelFunc -#ifdef __SYCL_NONCONST_FUNCTOR__ -#define _KERNELFUNCPARAM(a) KernelType a -#else -#define _KERNELFUNCPARAM(a) const KernelType &a -#endif - /// single_task version with a kernel represented as a lambda. /// /// \param KernelFunc is the Kernel functor or lambda @@ -744,7 +709,9 @@ class __SYCL_EXPORT queue { // Clean up CODELOC and KERNELFUNC macros. #undef _CODELOCPARAM +#undef _CODELOCONLYPARAM #undef _CODELOCARG +#undef _CODELOCFW #undef _KERNELFUNCPARAM /// Returns whether the queue is in order or OoO