Skip to content

Commit 373a81c

Browse files
[SYCL] Use std::move instead of copy (#19382)
Coverity suggested these fixes.
1 parent c80cbea commit 373a81c

File tree

9 files changed

+15
-13
lines changed

9 files changed

+15
-13
lines changed

sycl/source/detail/context_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ context_impl::context_impl(ur_context_handle_t UrContext,
6464
async_handler AsyncHandler, adapter_impl &Adapter,
6565
const std::vector<sycl::device> &DeviceList,
6666
bool OwnedByRuntime, private_tag)
67-
: MOwnedByRuntime(OwnedByRuntime), MAsyncHandler(AsyncHandler),
67+
: MOwnedByRuntime(OwnedByRuntime), MAsyncHandler(std::move(AsyncHandler)),
6868
MDevices(DeviceList), MContext(UrContext), MPlatform(),
6969
MSupportBufferLocationByDevices(NotChecked) {
7070
if (!MDevices.empty()) {

sycl/source/detail/context_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class context_impl : public std::enable_shared_from_this<context_impl> {
6868

6969
context_impl(ur_context_handle_t UrContext, async_handler AsyncHandler,
7070
adapter_impl &Adapter, private_tag tag)
71-
: context_impl(UrContext, AsyncHandler, Adapter,
71+
: context_impl(UrContext, std::move(AsyncHandler), Adapter,
7272
std::vector<sycl::device>{},
7373
/*OwnedByRuntime*/ true, tag) {}
7474

sycl/source/detail/kernel_bundle_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class kernel_bundle_impl
124124
// Interop constructor
125125
kernel_bundle_impl(context Ctx, std::vector<device> Devs,
126126
device_image_plain &DevImage, private_tag Tag)
127-
: kernel_bundle_impl(Ctx, Devs, Tag) {
127+
: kernel_bundle_impl(std::move(Ctx), std::move(Devs), Tag) {
128128
MDeviceImages.emplace_back(DevImage);
129129
MUniqueDeviceImages.emplace_back(DevImage);
130130
}

sycl/source/detail/platform_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ std::vector<platform> platform_impl::getAdapterPlatforms(adapter_impl &Adapter,
143143

144144
if (!Supported) {
145145
if (IsBanned || !HasAnyDevices) {
146-
Platforms.push_back(Platform);
146+
Platforms.push_back(std::move(Platform));
147147
}
148148
} else {
149149
if (IsBanned) {
@@ -155,7 +155,7 @@ std::vector<platform> platform_impl::getAdapterPlatforms(adapter_impl &Adapter,
155155
// 2020 4.6.2 ) If we have an empty platform, we don't report it back
156156
// from platform::get_platforms().
157157
if (HasAnyDevices) {
158-
Platforms.push_back(Platform);
158+
Platforms.push_back(std::move(Platform));
159159
}
160160
}
161161
}

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ static void appendCompileOptionsFromImage(std::string &CompileOpts,
442442
// Extract everything after this option and add it to the above.
443443
if (EndOfOpt != std::string::npos)
444444
NewCompileOpts += CompileOpts.substr(EndOfOpt);
445-
CompileOpts = NewCompileOpts;
445+
CompileOpts = std::move(NewCompileOpts);
446446
OptPos = CompileOpts.find(TargetRegisterAllocMode);
447447
}
448448
constexpr std::string_view ReplaceOpts[] = {"-foffload-fp32-prec-div",

sycl/source/detail/scheduler/commands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3805,7 +3805,7 @@ UpdateCommandBufferCommand::UpdateCommandBufferCommand(
38053805
std::vector<std::shared_ptr<ext::oneapi::experimental::detail::node_impl>>
38063806
Nodes)
38073807
: Command(CommandType::UPDATE_CMD_BUFFER, Queue), MGraph(Graph),
3808-
MNodes(Nodes) {}
3808+
MNodes(std::move(Nodes)) {}
38093809

38103810
ur_result_t UpdateCommandBufferCommand::enqueueImp() {
38113811
waitForPreparedHostEvents();

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ Scheduler::GraphBuilder::getOrInsertMemObjRecord(queue_impl *Queue,
224224
std::shared_ptr<queue_impl> InteropQueuePtr = queue_impl::create(
225225
Dev, *InteropCtxPtr, async_handler{}, property_list{});
226226

227-
MemObject->MRecord.reset(
228-
new MemObjRecord{InteropCtxPtr, LeafLimit, AllocateDependency});
227+
MemObject->MRecord.reset(new MemObjRecord{InteropCtxPtr, LeafLimit,
228+
std::move(AllocateDependency)});
229229
std::vector<Command *> ToEnqueue;
230230
getOrCreateAllocaForReq(MemObject->MRecord.get(), Req,
231231
InteropQueuePtr.get(), ToEnqueue);
@@ -234,7 +234,8 @@ Scheduler::GraphBuilder::getOrInsertMemObjRecord(queue_impl *Queue,
234234
"alloca or exceeding the leaf limit).");
235235
} else
236236
MemObject->MRecord.reset(new MemObjRecord{queue_impl::getContext(Queue),
237-
LeafLimit, AllocateDependency});
237+
LeafLimit,
238+
std::move(AllocateDependency)});
238239

239240
MMemObjs.push_back(MemObject);
240241
return MemObject->MRecord.get();
@@ -1345,7 +1346,7 @@ Command *Scheduler::GraphBuilder::addCommandGraphUpdate(
13451346
if (e->getCommand() && e->getCommand() == NewCmd.get()) {
13461347
continue;
13471348
}
1348-
if (Command *ConnCmd = NewCmd->addDep(e, ToCleanUp))
1349+
if (Command *ConnCmd = NewCmd->addDep(std::move(e), ToCleanUp))
13491350
ToEnqueue.push_back(ConnCmd);
13501351
}
13511352

sycl/source/detail/scheduler/scheduler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,8 @@ EventImplPtr Scheduler::addCommandGraphUpdate(
654654
WriteLockT Lock = acquireWriteLock();
655655

656656
Command *NewCmd = MGraphBuilder.addCommandGraphUpdate(
657-
Graph, Nodes, Queue, Requirements, Events, AuxiliaryCmds);
657+
Graph, std::move(Nodes), Queue, std::move(Requirements), Events,
658+
AuxiliaryCmds);
658659
if (!NewCmd)
659660
return nullptr;
660661
NewCmdEvent = NewCmd->getEvent();

sycl/source/detail/scheduler/scheduler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ struct MemObjRecord {
200200
MemObjRecord(context_impl *Ctx, std::size_t LeafLimit,
201201
LeavesCollection::AllocateDependencyF AllocateDependency)
202202
: MReadLeaves{this, LeafLimit, AllocateDependency},
203-
MWriteLeaves{this, LeafLimit, AllocateDependency},
203+
MWriteLeaves{this, LeafLimit, std::move(AllocateDependency)},
204204
MCurContext{Ctx ? Ctx->shared_from_this() : nullptr} {}
205205
// Contains all allocation commands for the memory object.
206206
std::vector<AllocaCommandBase *> MAllocaCommands;

0 commit comments

Comments
 (0)