Skip to content

Commit

Permalink
[SYCL] Fix Coverity issues after #16228 (#16313)
Browse files Browse the repository at this point in the history
All of these Coverity issues are related to using `std::move()` instead
of variable copy.
  • Loading branch information
uditagarwal97 authored Dec 10, 2024
1 parent 2f63969 commit a1355e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sycl/source/detail/kernel_bundle_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class kernel_bundle_impl {
detail::ProgramManager::getInstance().build(DevImgWithDeps,
MDevices, PropList);
MDeviceImages.emplace_back(BuiltImg);
MUniqueDeviceImages.push_back(BuiltImg);
MUniqueDeviceImages.emplace_back(BuiltImg);
break;
}
case bundle_state::input:
Expand Down
16 changes: 9 additions & 7 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram(
std::copy(DeviceImagesToLink.begin(), DeviceImagesToLink.end(),
std::back_inserter(AllImages));

return getBuiltURProgram(AllImages, Context, {Device});
return getBuiltURProgram(std::move(AllImages), Context, {Device});
}

ur_program_handle_t ProgramManager::getBuiltURProgram(
Expand Down Expand Up @@ -2400,7 +2400,8 @@ ProgramManager::getSYCLDeviceImagesWithCompatibleState(
std::vector<device_image_plain> Images;
const std::set<RTDeviceBinaryImage *> &Deps = ImgInfoPair.second.Deps;
Images.reserve(Deps.size() + 1);
Images.push_back(createSyclObjFromImpl<device_image_plain>(MainImpl));
Images.push_back(
createSyclObjFromImpl<device_image_plain>(std::move(MainImpl)));
for (RTDeviceBinaryImage *Dep : Deps) {
std::shared_ptr<std::vector<sycl::kernel_id>> DepKernelIDs;
{
Expand All @@ -2414,7 +2415,8 @@ ProgramManager::getSYCLDeviceImagesWithCompatibleState(
Dep, Ctx, Devs, ImgInfoPair.second.State, DepKernelIDs,
/*PIProgram=*/nullptr);

Images.push_back(createSyclObjFromImpl<device_image_plain>(DepImpl));
Images.push_back(
createSyclObjFromImpl<device_image_plain>(std::move(DepImpl)));
}
SYCLDeviceImages.push_back(std::move(Images));
}
Expand Down Expand Up @@ -2600,7 +2602,7 @@ ProgramManager::compile(const DevImgPlainWithDeps &ImgWithDeps,
getSyclObjImpl(ObjectImpl->get_context())));

CompiledImages.push_back(
createSyclObjFromImpl<device_image_plain>(ObjectImpl));
createSyclObjFromImpl<device_image_plain>(std::move(ObjectImpl)));
}
return CompiledImages;
}
Expand Down Expand Up @@ -2775,14 +2777,14 @@ ProgramManager::build(const DevImgPlainWithDeps &DevImgWithDeps,
SpecConstMap = MainInputImpl->get_spec_const_data_ref();
}

ur_program_handle_t ResProgram =
getBuiltURProgram(BinImgs, Context, Devs, &DevImgWithDeps, SpecConstBlob);
ur_program_handle_t ResProgram = getBuiltURProgram(
std::move(BinImgs), Context, Devs, &DevImgWithDeps, SpecConstBlob);

DeviceImageImplPtr ExecImpl = std::make_shared<detail::device_image_impl>(
MainInputImpl->get_bin_image_ref(), Context, Devs,
bundle_state::executable, std::move(KernelIDs), ResProgram,
std::move(SpecConstMap), std::move(SpecConstBlob));
return createSyclObjFromImpl<device_image_plain>(ExecImpl);
return createSyclObjFromImpl<device_image_plain>(std::move(ExecImpl));
}

// When caching is enabled, the returned UrKernel will already have
Expand Down

0 comments on commit a1355e8

Please sign in to comment.