Skip to content

Commit 0a42cf7

Browse files
authored
[SYCL] Fix move instead of copy Coverity hits (#17982)
Move instead of copy Coverity hit fixes for `sycl/source/detail/queue_impl.hpp` and `sycl/source/detail/scheduler/commands.cpp`
1 parent 4d8a539 commit 0a42cf7

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

sycl/source/detail/queue_impl.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -783,12 +783,12 @@ class queue_impl {
783783
auto EventRet = Handler.finalize();
784784
const EventImplPtr &EventRetImpl = getSyclObjImpl(EventRet);
785785
if (Type == CGType::CodeplayHostTask)
786-
Deps.UnenqueuedCmdEvents.push_back(EventRetImpl);
786+
Deps.UnenqueuedCmdEvents.push_back(std::move(EventRetImpl));
787787
else if (Type == CGType::Barrier || Type == CGType::BarrierWaitlist) {
788-
Deps.LastBarrier = EventRetImpl;
788+
Deps.LastBarrier = std::move(EventRetImpl);
789789
Deps.UnenqueuedCmdEvents.clear();
790790
} else if (!EventRetImpl->isEnqueued()) {
791-
Deps.UnenqueuedCmdEvents.push_back(EventRetImpl);
791+
Deps.UnenqueuedCmdEvents.push_back(std::move(EventRetImpl));
792792
}
793793

794794
return EventRet;

sycl/source/detail/scheduler/commands.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -3059,14 +3059,15 @@ ur_result_t ExecCGCommand::enqueueImpCommandBuffer() {
30593059
"Can't get memory object due to no allocation available " +
30603060
codeToString(UR_RESULT_ERROR_INVALID_MEM_OBJECT));
30613061
};
3062-
std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv);
3062+
std::for_each(std::begin(HandlerReq), std::end(HandlerReq),
3063+
std::move(ReqToMemConv));
30633064

30643065
ur_exp_command_buffer_handle_t InteropCommandBuffer =
30653066
ChildCommandBuffer ? ChildCommandBuffer : MCommandBuffer;
3066-
interop_handle IH{ReqToMem, MQueue, DeviceImpl, ContextImpl,
3067+
interop_handle IH{std::move(ReqToMem), MQueue, DeviceImpl, ContextImpl,
30673068
InteropCommandBuffer};
30683069
CommandBufferNativeCommandData CustomOpData{
3069-
IH, HostTask->MHostTask->MInteropTask};
3070+
std::move(IH), HostTask->MHostTask->MInteropTask};
30703071

30713072
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
30723073
// CMPLRLLVM-66082
@@ -3397,7 +3398,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
33973398
"Can't get memory object due to no allocation available " +
33983399
codeToString(UR_RESULT_ERROR_INVALID_MEM_OBJECT));
33993400
};
3400-
std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv);
3401+
std::for_each(std::begin(HandlerReq), std::end(HandlerReq),
3402+
std::move(ReqToMemConv));
34013403
std::sort(std::begin(ReqToMem), std::end(ReqToMem));
34023404
}
34033405

@@ -3462,12 +3464,13 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
34623464
"Can't get memory object due to no allocation available " +
34633465
codeToString(UR_RESULT_ERROR_INVALID_MEM_OBJECT));
34643466
};
3465-
std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv);
3467+
std::for_each(std::begin(HandlerReq), std::end(HandlerReq),
3468+
std::move(ReqToMemConv));
34663469
std::sort(std::begin(ReqToMem), std::end(ReqToMem));
34673470
}
34683471

34693472
EnqueueNativeCommandData CustomOpData{
3470-
interop_handle{ReqToMem, HostTask->MQueue,
3473+
interop_handle{std::move(ReqToMem), HostTask->MQueue,
34713474
HostTask->MQueue->getDeviceImplPtr(),
34723475
HostTask->MQueue->getContextImplPtr()},
34733476
HostTask->MHostTask->MInteropTask};

0 commit comments

Comments
 (0)