Skip to content

Commit 24a0cf3

Browse files
[SYCL] Use perfect forwarding around host tasks properly (#20732)
Fixes #20722.
1 parent 7bdfb08 commit 24a0cf3

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

sycl/include/sycl/handler.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,8 +1457,8 @@ class __SYCL_EXPORT handler {
14571457
template <typename SharedPtrT>
14581458
void setHandlerKernelBundle(SharedPtrT &&NewKernelBundleImpPtr);
14591459

1460-
void SetHostTask(std::function<void()> &&Func);
1461-
void SetHostTask(std::function<void(interop_handle)> &&Func);
1460+
void SetHostTask(std::function<void()> Func);
1461+
void SetHostTask(std::function<void(interop_handle)> Func);
14621462

14631463
template <typename FuncT>
14641464
std::enable_if_t<detail::check_fn_signature<std::remove_reference_t<FuncT>,
@@ -1472,7 +1472,7 @@ class __SYCL_EXPORT handler {
14721472
// accessors during finalize
14731473
setArgsToAssociatedAccessors();
14741474

1475-
SetHostTask(std::move(Func));
1475+
SetHostTask(std::forward<FuncT>(Func));
14761476
}
14771477

14781478
template <typename FuncT>
@@ -1485,7 +1485,7 @@ class __SYCL_EXPORT handler {
14851485
// accessors during finalize
14861486
setArgsToAssociatedAccessors();
14871487

1488-
SetHostTask(std::move(Func));
1488+
SetHostTask(std::forward<FuncT>(Func));
14891489
setType(detail::CGType::EnqueueNativeCommand);
14901490
}
14911491

@@ -1707,7 +1707,7 @@ class __SYCL_EXPORT handler {
17071707
detail::check_fn_signature<std::remove_reference_t<FuncT>,
17081708
void(interop_handle)>::value>
17091709
host_task(FuncT &&Func) {
1710-
host_task_impl(Func);
1710+
host_task_impl(std::forward<FuncT>(Func));
17111711
}
17121712

17131713
/// Enqueues a command to the SYCL runtime to invoke \p Func immediately.
@@ -1716,7 +1716,7 @@ class __SYCL_EXPORT handler {
17161716
void(interop_handle)>::value>
17171717
ext_codeplay_enqueue_native_command([[maybe_unused]] FuncT &&Func) {
17181718
#ifndef __SYCL_DEVICE_ONLY__
1719-
ext_codeplay_enqueue_native_command_impl(Func);
1719+
ext_codeplay_enqueue_native_command_impl(std::forward<FuncT>(Func));
17201720
#endif
17211721
}
17221722

sycl/source/handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,13 +2045,13 @@ void *handler::storeRawArg(const void *Ptr, size_t Size) {
20452045
return Storage;
20462046
}
20472047

2048-
void handler::SetHostTask(std::function<void()> &&Func) {
2048+
void handler::SetHostTask(std::function<void()> Func) {
20492049
setNDRangeDescriptor(range<1>(1));
20502050
impl->MHostTask.reset(new detail::HostTask(std::move(Func)));
20512051
setType(detail::CGType::CodeplayHostTask);
20522052
}
20532053

2054-
void handler::SetHostTask(std::function<void(interop_handle)> &&Func) {
2054+
void handler::SetHostTask(std::function<void(interop_handle)> Func) {
20552055
setNDRangeDescriptor(range<1>(1));
20562056
impl->MHostTask.reset(new detail::HostTask(std::move(Func)));
20572057
setType(detail::CGType::CodeplayHostTask);

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,8 +3545,8 @@ _ZN4sycl3_V17handler10depends_onERKSt6vectorINS0_5eventESaIS3_EE
35453545
_ZN4sycl3_V17handler10depends_onERKSt6vectorISt10shared_ptrINS0_6detail10event_implEESaIS6_EE
35463546
_ZN4sycl3_V17handler10mem_adviseEPKvmi
35473547
_ZN4sycl3_V17handler10processArgEPvRKNS0_6detail19kernel_param_kind_tEimRmbb
3548-
_ZN4sycl3_V17handler11SetHostTaskEOSt8functionIFvNS0_14interop_handleEEE
3549-
_ZN4sycl3_V17handler11SetHostTaskEOSt8functionIFvvEE
3548+
_ZN4sycl3_V17handler11SetHostTaskESt8functionIFvNS0_14interop_handleEEE
3549+
_ZN4sycl3_V17handler11SetHostTaskESt8functionIFvvEE
35503550
_ZN4sycl3_V17handler11copyCodeLocERKS1_
35513551
_ZN4sycl3_V17handler11saveCodeLocENS0_6detail13code_locationE
35523552
_ZN4sycl3_V17handler11saveCodeLocENS0_6detail13code_locationEb

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@
712712
?SecondaryQueue@SubmissionInfo@detail@_V1@sycl@@QEBAAEBV?$shared_ptr@Vqueue_impl@detail@_V1@sycl@@@std@@XZ
713713
?SecondaryQueue@SubmissionInfo@v1@detail@_V1@sycl@@QEAAAEAV?$shared_ptr@Vqueue_impl@detail@_V1@sycl@@@std@@XZ
714714
?SecondaryQueue@SubmissionInfo@v1@detail@_V1@sycl@@QEBAAEBV?$shared_ptr@Vqueue_impl@detail@_V1@sycl@@@std@@XZ
715-
?SetHostTask@handler@_V1@sycl@@AEAAX$$QEAV?$function@$$A6AXVinterop_handle@_V1@sycl@@@Z@std@@@Z
716-
?SetHostTask@handler@_V1@sycl@@AEAAX$$QEAV?$function@$$A6AXXZ@std@@@Z
715+
?SetHostTask@handler@_V1@sycl@@AEAAXV?$function@$$A6AXVinterop_handle@_V1@sycl@@@Z@std@@@Z
716+
?SetHostTask@handler@_V1@sycl@@AEAAXV?$function@$$A6AXXZ@std@@@Z
717717
?SetKernelLaunchpropertiesIfNotEmpty@handler@_V1@sycl@@AEAAXAEBU?$PropsHolder@Uwork_group_scratch_size@experimental@oneapi@ext@_V1@sycl@@Ucache_config@2intel@456@Uuse_root_sync_key@23456@Uwork_group_progress_key@23456@Usub_group_progress_key@23456@Uwork_item_progress_key@23456@U?$cluster_size@$00@cuda@23456@U?$cluster_size@$01@cuda@23456@U?$cluster_size@$02@cuda@23456@@kernel_launch_properties_v1@detail@23@@Z
718718
?__abs_diff_impl@_V1@sycl@@YA?AV?$vec@C$00@12@V312@0@Z
719719
?__abs_diff_impl@_V1@sycl@@YA?AV?$vec@C$01@12@V312@0@Z

0 commit comments

Comments
 (0)