Skip to content

Commit 73e6b22

Browse files
authored
[SYCLCOMPAT] Forward launch arguments to avoid copies (#16965)
This is important when passing a CUTensorMap argument to a descriptor, since taking the address of a copy of a CUTensorMap will cause runtime issues. e.g. ``` UR CUDA ERROR: Value: 700 Name: CUDA_ERROR_ILLEGAL_ADDRESS Description: an illegal memory access was encountered Function: operator() Source Location: llvm/build/_deps/unified-runtime-src/source/adapters/cuda/queue.cpp:231 ```
1 parent 0dfb947 commit 73e6b22

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sycl/include/syclcompat/launch_policy.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,17 @@ launch_policy(dim3, dim3, Ts...) -> launch_policy<
194194
namespace detail {
195195
// Custom std::apply helpers to enable inlining
196196
template <class F, class Tuple, size_t... Is>
197-
__syclcompat_inline__ constexpr void apply_expand(F f, Tuple t,
197+
__syclcompat_inline__ constexpr void apply_expand(F &&f, Tuple &&t,
198198
std::index_sequence<Is...>) {
199-
[[clang::always_inline]] f(get<Is>(t)...);
199+
[[clang::always_inline]] std::forward<F>(f)(
200+
get<Is>(std::forward<Tuple>(t))...);
200201
}
201202

202203
template <class F, class Tuple>
203-
__syclcompat_inline__ constexpr void apply_helper(F f, Tuple t) {
204-
apply_expand(f, t, std::make_index_sequence<std::tuple_size<Tuple>{}>{});
204+
__syclcompat_inline__ constexpr void apply_helper(F &&f, Tuple &&t) {
205+
apply_expand(
206+
std::forward<F>(f), std::forward<Tuple>(t),
207+
std::make_index_sequence<std::tuple_size_v<std::decay_t<Tuple>>>{});
205208
}
206209

207210
template <auto F, typename Range, typename KProps, bool HasLocalMem,

0 commit comments

Comments
 (0)