Skip to content

[SYCL] Fix move instead of copy Coverity hits #17982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sycl/source/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,12 +783,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;
Expand Down
15 changes: 9 additions & 6 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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};
Expand Down