From e2865c063b97d8c558f6abb30fbb8d195872d748 Mon Sep 17 00:00:00 2001 From: "Garcia Orozco, David" Date: Fri, 11 Apr 2025 08:48:06 -0700 Subject: [PATCH 1/3] [SYCL] Fix move instead of copy hits in `scheduler/commands.cpp` --- sycl/source/detail/scheduler/commands.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 0bfa89e3dfb80..c8390f9fc2719 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -420,7 +420,7 @@ class DispatchHostTask { if (HostTask.MHostTask->isInteropTask()) { assert(HostTask.MQueue && "Host task submissions should have an associated queue"); - interop_handle IH{MReqToMem, HostTask.MQueue, + interop_handle IH{std::move(MReqToMem), HostTask.MQueue, HostTask.MQueue->getDeviceImplPtr(), HostTask.MQueue->getContextImplPtr()}; // TODO: should all the backends that support this entry point use this @@ -3059,14 +3059,15 @@ ur_result_t ExecCGCommand::enqueueImpCommandBuffer() { "Can't get memory object due to no allocation available " + codeToString(UR_RESULT_ERROR_INVALID_MEM_OBJECT)); }; - std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv); + std::for_each(std::begin(HandlerReq), std::end(HandlerReq), + std::move(ReqToMemConv)); ur_exp_command_buffer_handle_t InteropCommandBuffer = ChildCommandBuffer ? ChildCommandBuffer : MCommandBuffer; - interop_handle IH{ReqToMem, MQueue, DeviceImpl, ContextImpl, + interop_handle IH{std::move(ReqToMem), MQueue, DeviceImpl, ContextImpl, InteropCommandBuffer}; CommandBufferNativeCommandData CustomOpData{ - IH, HostTask->MHostTask->MInteropTask}; + std::move(IH), HostTask->MHostTask->MInteropTask}; #ifndef __INTEL_PREVIEW_BREAKING_CHANGES // CMPLRLLVM-66082 @@ -3397,7 +3398,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { "Can't get memory object due to no allocation available " + codeToString(UR_RESULT_ERROR_INVALID_MEM_OBJECT)); }; - std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv); + std::for_each(std::begin(HandlerReq), std::end(HandlerReq), + std::move(ReqToMemConv)); std::sort(std::begin(ReqToMem), std::end(ReqToMem)); } @@ -3462,12 +3464,13 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { "Can't get memory object due to no allocation available " + codeToString(UR_RESULT_ERROR_INVALID_MEM_OBJECT)); }; - std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv); + std::for_each(std::begin(HandlerReq), std::end(HandlerReq), + std::move(ReqToMemConv)); std::sort(std::begin(ReqToMem), std::end(ReqToMem)); } EnqueueNativeCommandData CustomOpData{ - interop_handle{ReqToMem, HostTask->MQueue, + interop_handle{std::move(ReqToMem), HostTask->MQueue, HostTask->MQueue->getDeviceImplPtr(), HostTask->MQueue->getContextImplPtr()}, HostTask->MHostTask->MInteropTask}; From 2d4dbf63018c6c4490740c87c20d68cfbb049b47 Mon Sep 17 00:00:00 2001 From: "Garcia Orozco, David" Date: Mon, 14 Apr 2025 10:36:57 -0700 Subject: [PATCH 2/3] Don't move member variable `MReqToMem` --- sycl/source/detail/scheduler/commands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index c8390f9fc2719..e0b176f5372b2 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -420,7 +420,7 @@ class DispatchHostTask { if (HostTask.MHostTask->isInteropTask()) { assert(HostTask.MQueue && "Host task submissions should have an associated queue"); - interop_handle IH{std::move(MReqToMem), HostTask.MQueue, + interop_handle IH{MReqToMem, HostTask.MQueue, HostTask.MQueue->getDeviceImplPtr(), HostTask.MQueue->getContextImplPtr()}; // TODO: should all the backends that support this entry point use this From 51c13cd2f76343a61008e0eb443781dd12eaeb6c Mon Sep 17 00:00:00 2001 From: "Garcia Orozco, David" Date: Mon, 14 Apr 2025 11:26:54 -0700 Subject: [PATCH 3/3] Fix one more instance of move instead of copy hit for queue_impl --- sycl/source/detail/queue_impl.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 9955855d5e2e4..67bac1fd15549 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -859,12 +859,12 @@ class queue_impl { auto EventRet = Handler.finalize(); const EventImplPtr &EventRetImpl = getSyclObjImpl(EventRet); if (Type == CGType::CodeplayHostTask) - Deps.UnenqueuedCmdEvents.push_back(EventRetImpl); + Deps.UnenqueuedCmdEvents.push_back(std::move(EventRetImpl)); else if (Type == CGType::Barrier || Type == CGType::BarrierWaitlist) { - Deps.LastBarrier = EventRetImpl; + Deps.LastBarrier = std::move(EventRetImpl); Deps.UnenqueuedCmdEvents.clear(); } else if (!EventRetImpl->isEnqueued()) { - Deps.UnenqueuedCmdEvents.push_back(EventRetImpl); + Deps.UnenqueuedCmdEvents.push_back(std::move(EventRetImpl)); } return EventRet;