Skip to content

Commit 1e89466

Browse files
[SYCL][ABI-Break] Re-design the handling of optional code location argument for USM calls and honor memory allocation properties (#6474)
Do not drop properties specified by user. Signed-off-by: Sergey V Maslov <sergey.v.maslov@intel.com>
1 parent 40d08c2 commit 1e89466

File tree

7 files changed

+428
-716
lines changed

7 files changed

+428
-716
lines changed

sycl/include/sycl/detail/common.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,30 @@ struct code_location {
8383
unsigned long MLineNo;
8484
unsigned long MColumnNo;
8585
};
86+
87+
// The C++ FE may instrument user calls with code location metadata.
88+
// If it does then that will appear as an extra last argument.
89+
// Having _TWO_ mid-param #ifdefs makes the functions very difficult to read.
90+
// Here we simplify the &CodeLoc declaration to be _CODELOCPARAM(&CodeLoc) and
91+
// _CODELOCARG(&CodeLoc).
92+
93+
#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
94+
#define _CODELOCONLYPARAM(a) \
95+
const detail::code_location a = detail::code_location::current()
96+
#define _CODELOCPARAM(a) \
97+
, const detail::code_location a = detail::code_location::current()
98+
#define _CODELOCPARAMDEF(a) , const detail::code_location a
99+
100+
#define _CODELOCARG(a)
101+
#define _CODELOCFW(a) , a
102+
#else
103+
#define _CODELOCONLYPARAM(a)
104+
#define _CODELOCPARAM(a)
105+
106+
#define _CODELOCARG(a) const detail::code_location a = {}
107+
#define _CODELOCFW(a)
108+
#endif
109+
86110
} // namespace detail
87111
} // namespace sycl
88112
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/sycl/queue.hpp

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,9 @@
3232
#include <utility>
3333

3434
// having _TWO_ mid-param #ifdefs makes the functions very difficult to read.
35-
// Here we simplify the &CodeLoc declaration to be _CODELOCPARAM(&CodeLoc) and
36-
// _CODELOCARG(&CodeLoc) Similarly, the KernelFunc param is simplified to be
35+
// Here we simplify the KernelFunc param is simplified to be
3736
// _KERNELFUNCPARAM(KernelFunc) Once the queue kernel functions are defined,
3837
// these macros are #undef immediately.
39-
40-
// replace _CODELOCPARAM(&CodeLoc) with nothing
41-
// or : , const detail::code_location &CodeLoc =
42-
// detail::code_location::current()
43-
// replace _CODELOCARG(&CodeLoc) with nothing
44-
// or : const detail::code_location &CodeLoc = {}
45-
46-
#ifndef DISABLE_SYCL_INSTRUMENTATION_METADATA
47-
#define _CODELOCONLYPARAM(a) \
48-
const detail::code_location a = detail::code_location::current()
49-
#define _CODELOCPARAM(a) \
50-
, const detail::code_location a = detail::code_location::current()
51-
52-
#define _CODELOCARG(a)
53-
#define _CODELOCFW(a) , a
54-
#else
55-
#define _CODELOCONLYPARAM(a)
56-
#define _CODELOCPARAM(a)
57-
58-
#define _CODELOCARG(a) const detail::code_location a = {}
59-
#define _CODELOCFW(a)
60-
#endif
61-
6238
// replace _KERNELFUNCPARAM(KernelFunc) with KernelType KernelFunc
6339
// or const KernelType &KernelFunc
6440
#ifdef __SYCL_NONCONST_FUNCTOR__
@@ -1081,11 +1057,7 @@ class __SYCL_EXPORT queue {
10811057
CodeLoc);
10821058
}
10831059

1084-
// Clean up CODELOC and KERNELFUNC macros.
1085-
#undef _CODELOCPARAM
1086-
#undef _CODELOCONLYPARAM
1087-
#undef _CODELOCARG
1088-
#undef _CODELOCFW
1060+
// Clean KERNELFUNC macros.
10891061
#undef _KERNELFUNCPARAM
10901062

10911063
/// Returns whether the queue is in order or OoO

0 commit comments

Comments
 (0)