Skip to content

[SYCL][ABI-Break] Re-design the handling of optional code location argument for USM calls and honor memory allocation properties #6474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions sycl/include/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ struct code_location {
unsigned long MLineNo;
unsigned long MColumnNo;
};

// The C++ FE may instrument user calls with code location metadata.
// If it does then that will appear as an extra last argument.
// 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).

#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 _CODELOCPARAMDEF(a) , const detail::code_location a

#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

} // namespace detail
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)
Expand Down
32 changes: 2 additions & 30 deletions sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,9 @@
#include <utility>

// 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
// Here we simplify 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__
Expand Down Expand Up @@ -1081,11 +1057,7 @@ class __SYCL_EXPORT queue {
CodeLoc);
}

// Clean up CODELOC and KERNELFUNC macros.
#undef _CODELOCPARAM
#undef _CODELOCONLYPARAM
#undef _CODELOCARG
#undef _CODELOCFW
// Clean KERNELFUNC macros.
#undef _KERNELFUNCPARAM

/// Returns whether the queue is in order or OoO
Expand Down
Loading