From f537aebb27326474f715ccc97d17916759a38cf1 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Fri, 21 Nov 2025 08:52:03 -0800 Subject: [PATCH 1/2] [SYCL] Use perfect forwarding around host tasks properly Fixes https://github.com/intel/llvm/issues/20722. --- sycl/include/sycl/handler.hpp | 12 ++++++------ sycl/source/handler.cpp | 4 ++-- sycl/test/abi/sycl_symbols_linux.dump | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index d8d46d2a27814..754f24a8138a6 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1457,8 +1457,8 @@ class __SYCL_EXPORT handler { template void setHandlerKernelBundle(SharedPtrT &&NewKernelBundleImpPtr); - void SetHostTask(std::function &&Func); - void SetHostTask(std::function &&Func); + void SetHostTask(std::function Func); + void SetHostTask(std::function Func); template std::enable_if_t, @@ -1472,7 +1472,7 @@ class __SYCL_EXPORT handler { // accessors during finalize setArgsToAssociatedAccessors(); - SetHostTask(std::move(Func)); + SetHostTask(std::forward(Func)); } template @@ -1485,7 +1485,7 @@ class __SYCL_EXPORT handler { // accessors during finalize setArgsToAssociatedAccessors(); - SetHostTask(std::move(Func)); + SetHostTask(std::forward(Func)); setType(detail::CGType::EnqueueNativeCommand); } @@ -1707,7 +1707,7 @@ class __SYCL_EXPORT handler { detail::check_fn_signature, void(interop_handle)>::value> host_task(FuncT &&Func) { - host_task_impl(Func); + host_task_impl(std::forward(Func)); } /// Enqueues a command to the SYCL runtime to invoke \p Func immediately. @@ -1716,7 +1716,7 @@ class __SYCL_EXPORT handler { void(interop_handle)>::value> ext_codeplay_enqueue_native_command([[maybe_unused]] FuncT &&Func) { #ifndef __SYCL_DEVICE_ONLY__ - ext_codeplay_enqueue_native_command_impl(Func); + ext_codeplay_enqueue_native_command_impl(std::forward(Func)); #endif } diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index fbcd88f1bd42a..8fd04c79cf224 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2045,13 +2045,13 @@ void *handler::storeRawArg(const void *Ptr, size_t Size) { return Storage; } -void handler::SetHostTask(std::function &&Func) { +void handler::SetHostTask(std::function Func) { setNDRangeDescriptor(range<1>(1)); impl->MHostTask.reset(new detail::HostTask(std::move(Func))); setType(detail::CGType::CodeplayHostTask); } -void handler::SetHostTask(std::function &&Func) { +void handler::SetHostTask(std::function Func) { setNDRangeDescriptor(range<1>(1)); impl->MHostTask.reset(new detail::HostTask(std::move(Func))); setType(detail::CGType::CodeplayHostTask); diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 5bd6c70baed67..d16c83b449cfe 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3544,8 +3544,8 @@ _ZN4sycl3_V17handler10depends_onERKSt6vectorINS0_5eventESaIS3_EE _ZN4sycl3_V17handler10depends_onERKSt6vectorISt10shared_ptrINS0_6detail10event_implEESaIS6_EE _ZN4sycl3_V17handler10mem_adviseEPKvmi _ZN4sycl3_V17handler10processArgEPvRKNS0_6detail19kernel_param_kind_tEimRmbb -_ZN4sycl3_V17handler11SetHostTaskEOSt8functionIFvNS0_14interop_handleEEE -_ZN4sycl3_V17handler11SetHostTaskEOSt8functionIFvvEE +_ZN4sycl3_V17handler11SetHostTaskESt8functionIFvNS0_14interop_handleEEE +_ZN4sycl3_V17handler11SetHostTaskESt8functionIFvvEE _ZN4sycl3_V17handler11copyCodeLocERKS1_ _ZN4sycl3_V17handler11saveCodeLocENS0_6detail13code_locationE _ZN4sycl3_V17handler11saveCodeLocENS0_6detail13code_locationEb From e87e2eea0d9e49fa9699d21da060b8945f065475 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Mon, 24 Nov 2025 08:26:39 -0800 Subject: [PATCH 2/2] Update `sycl/test/abi/sycl_symbols_windows.dump` --- sycl/test/abi/sycl_symbols_windows.dump | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index bd4600e29aad2..4feae1f0400bd 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -730,8 +730,8 @@ ?SecondaryQueue@SubmissionInfo@detail@_V1@sycl@@QEBAAEBV?$shared_ptr@Vqueue_impl@detail@_V1@sycl@@@std@@XZ ?SecondaryQueue@SubmissionInfo@v1@detail@_V1@sycl@@QEAAAEAV?$shared_ptr@Vqueue_impl@detail@_V1@sycl@@@std@@XZ ?SecondaryQueue@SubmissionInfo@v1@detail@_V1@sycl@@QEBAAEBV?$shared_ptr@Vqueue_impl@detail@_V1@sycl@@@std@@XZ -?SetHostTask@handler@_V1@sycl@@AEAAX$$QEAV?$function@$$A6AXVinterop_handle@_V1@sycl@@@Z@std@@@Z -?SetHostTask@handler@_V1@sycl@@AEAAX$$QEAV?$function@$$A6AXXZ@std@@@Z +?SetHostTask@handler@_V1@sycl@@AEAAXV?$function@$$A6AXVinterop_handle@_V1@sycl@@@Z@std@@@Z +?SetHostTask@handler@_V1@sycl@@AEAAXV?$function@$$A6AXXZ@std@@@Z ?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 ?__abs_diff_impl@_V1@sycl@@YA?AV?$vec@C$00@12@V312@0@Z ?__abs_diff_impl@_V1@sycl@@YA?AV?$vec@C$01@12@V312@0@Z