Skip to content

Commit 03b994e

Browse files
[SYCL] Add code location information to enqueue free functions (#13924)
This commit adds the code_location argument to the new enqueue functions to enforce better code location information from callers. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent c275619 commit 03b994e

File tree

1 file changed

+49
-22
lines changed

1 file changed

+49
-22
lines changed

sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <utility> // for std::forward
1212

13+
#include <sycl/detail/common.hpp>
1314
#include <sycl/event.hpp>
1415
#include <sycl/ext/oneapi/properties/properties.hpp>
1516
#include <sycl/handler.hpp>
@@ -74,14 +75,18 @@ template <typename LCRangeT, typename LCPropertiesT> struct LaunchConfigAccess {
7475
} // namespace detail
7576

7677
template <typename CommandGroupFunc>
77-
void submit(queue Q, CommandGroupFunc &&CGF) {
78+
void submit(queue Q, CommandGroupFunc &&CGF,
79+
const sycl::detail::code_location &CodeLoc =
80+
sycl::detail::code_location::current()) {
7881
// TODO: Use new submit without Events.
79-
Q.submit(std::forward<CommandGroupFunc>(CGF));
82+
Q.submit(std::forward<CommandGroupFunc>(CGF), CodeLoc);
8083
}
8184

8285
template <typename CommandGroupFunc>
83-
event submit_with_event(queue Q, CommandGroupFunc &&CGF) {
84-
return Q.submit(std::forward<CommandGroupFunc>(CGF));
86+
event submit_with_event(queue Q, CommandGroupFunc &&CGF,
87+
const sycl::detail::code_location &CodeLoc =
88+
sycl::detail::code_location::current()) {
89+
return Q.submit(std::forward<CommandGroupFunc>(CGF), CodeLoc);
8590
}
8691

8792
template <typename KernelName = sycl::detail::auto_name, typename KernelType>
@@ -90,8 +95,12 @@ void single_task(handler &CGH, const KernelType &KernelObj) {
9095
}
9196

9297
template <typename KernelName = sycl::detail::auto_name, typename KernelType>
93-
void single_task(queue Q, const KernelType &KernelObj) {
94-
submit(Q, [&](handler &CGH) { single_task<KernelName>(CGH, KernelObj); });
98+
void single_task(queue Q, const KernelType &KernelObj,
99+
const sycl::detail::code_location &CodeLoc =
100+
sycl::detail::code_location::current()) {
101+
submit(
102+
Q, [&](handler &CGH) { single_task<KernelName>(CGH, KernelObj); },
103+
CodeLoc);
95104
}
96105

97106
template <typename... ArgsT>
@@ -261,25 +270,32 @@ inline void memcpy(handler &CGH, void *Dest, const void *Src, size_t NumBytes) {
261270
CGH.memcpy(Dest, Src, NumBytes);
262271
}
263272

264-
inline void memcpy(queue Q, void *Dest, const void *Src, size_t NumBytes) {
265-
submit(Q, [&](handler &CGH) { memcpy(CGH, Dest, Src, NumBytes); });
273+
inline void memcpy(queue Q, void *Dest, const void *Src, size_t NumBytes,
274+
const sycl::detail::code_location &CodeLoc =
275+
sycl::detail::code_location::current()) {
276+
submit(Q, [&](handler &CGH) { memcpy(CGH, Dest, Src, NumBytes); }, CodeLoc);
266277
}
267278

268279
template <typename T>
269280
void copy(handler &CGH, const T *Src, T *Dest, size_t Count) {
270281
CGH.copy<T>(Src, Dest, Count);
271282
}
272283

273-
template <typename T> void copy(queue Q, const T *Src, T *Dest, size_t Count) {
274-
submit(Q, [&](handler &CGH) { copy<T>(CGH, Src, Dest, Count); });
284+
template <typename T>
285+
void copy(queue Q, const T *Src, T *Dest, size_t Count,
286+
const sycl::detail::code_location &CodeLoc =
287+
sycl::detail::code_location::current()) {
288+
submit(Q, [&](handler &CGH) { copy<T>(CGH, Src, Dest, Count); }, CodeLoc);
275289
}
276290

277291
inline void memset(handler &CGH, void *Ptr, int Value, size_t NumBytes) {
278292
CGH.memset(Ptr, Value, NumBytes);
279293
}
280294

281-
inline void memset(queue Q, void *Ptr, int Value, size_t NumBytes) {
282-
submit(Q, [&](handler &CGH) { memset(CGH, Ptr, Value, NumBytes); });
295+
inline void memset(queue Q, void *Ptr, int Value, size_t NumBytes,
296+
const sycl::detail::code_location &CodeLoc =
297+
sycl::detail::code_location::current()) {
298+
submit(Q, [&](handler &CGH) { memset(CGH, Ptr, Value, NumBytes); }, CodeLoc);
283299
}
284300

285301
template <typename T>
@@ -288,38 +304,49 @@ void fill(sycl::handler &CGH, T *Ptr, const T &Pattern, size_t Count) {
288304
}
289305

290306
template <typename T>
291-
void fill(sycl::queue Q, T *Ptr, const T &Pattern, size_t Count) {
292-
submit(Q, [&](handler &CGH) { fill<T>(CGH, Ptr, Pattern, Count); });
307+
void fill(sycl::queue Q, T *Ptr, const T &Pattern, size_t Count,
308+
const sycl::detail::code_location &CodeLoc =
309+
sycl::detail::code_location::current()) {
310+
submit(Q, [&](handler &CGH) { fill<T>(CGH, Ptr, Pattern, Count); }, CodeLoc);
293311
}
294312

295313
inline void prefetch(handler &CGH, void *Ptr, size_t NumBytes) {
296314
CGH.prefetch(Ptr, NumBytes);
297315
}
298316

299-
inline void prefetch(queue Q, void *Ptr, size_t NumBytes) {
300-
submit(Q, [&](handler &CGH) { prefetch(CGH, Ptr, NumBytes); });
317+
inline void prefetch(queue Q, void *Ptr, size_t NumBytes,
318+
const sycl::detail::code_location &CodeLoc =
319+
sycl::detail::code_location::current()) {
320+
submit(Q, [&](handler &CGH) { prefetch(CGH, Ptr, NumBytes); }, CodeLoc);
301321
}
302322

303323
inline void mem_advise(handler &CGH, void *Ptr, size_t NumBytes, int Advice) {
304324
CGH.mem_advise(Ptr, NumBytes, Advice);
305325
}
306326

307-
inline void mem_advise(queue Q, void *Ptr, size_t NumBytes, int Advice) {
308-
submit(Q, [&](handler &CGH) { mem_advise(CGH, Ptr, NumBytes, Advice); });
327+
inline void mem_advise(queue Q, void *Ptr, size_t NumBytes, int Advice,
328+
const sycl::detail::code_location &CodeLoc =
329+
sycl::detail::code_location::current()) {
330+
submit(
331+
Q, [&](handler &CGH) { mem_advise(CGH, Ptr, NumBytes, Advice); },
332+
CodeLoc);
309333
}
310334

311335
inline void barrier(handler &CGH) { CGH.ext_oneapi_barrier(); }
312336

313-
inline void barrier(queue Q) {
314-
submit(Q, [&](handler &CGH) { barrier(CGH); });
337+
inline void barrier(queue Q, const sycl::detail::code_location &CodeLoc =
338+
sycl::detail::code_location::current()) {
339+
submit(Q, [&](handler &CGH) { barrier(CGH); }, CodeLoc);
315340
}
316341

317342
inline void partial_barrier(handler &CGH, const std::vector<event> &Events) {
318343
CGH.ext_oneapi_barrier(Events);
319344
}
320345

321-
inline void partial_barrier(queue Q, const std::vector<event> &Events) {
322-
submit(Q, [&](handler &CGH) { partial_barrier(CGH, Events); });
346+
inline void partial_barrier(queue Q, const std::vector<event> &Events,
347+
const sycl::detail::code_location &CodeLoc =
348+
sycl::detail::code_location::current()) {
349+
submit(Q, [&](handler &CGH) { partial_barrier(CGH, Events); }, CodeLoc);
323350
}
324351

325352
} // namespace ext::oneapi::experimental

0 commit comments

Comments
 (0)