Skip to content

[SYCL RT][Coverity] Copy instead of move #19234

Open
@AlexeySachkov

Description

@AlexeySachkov

See Coverity issues at https://scan.coverity.com/projects/intel-llvm?tab=overview

CID 489796:

Coverity complains that the last call of IsMatchingPlatform should use std::move to pass Platform, but we should probably just accept it as const & in the lambda

auto IsMatchingOpenCL = [](platform Platform, const std::string_view name) {
const bool HasNameMatch = Platform.get_info<info::platform::name>().find(
name) != std::string::npos;
const auto Backend = detail::getSyclObjImpl(Platform)->getBackend();
const bool IsMatchingOCL = (HasNameMatch && Backend == backend::opencl);
if (detail::ur::trace(detail::ur::TraceLevel::TRACE_ALL) && IsMatchingOCL) {
std::cout << "SYCL_UR_TRACE: " << name
<< " OpenCL platform found but is not compatible." << std::endl;
}
return IsMatchingOCL;
};
return IsMatchingOpenCL(Platform, "NVIDIA CUDA") ||
IsMatchingOpenCL(Platform, "AMD Accelerated Parallel Processing");

CID 489974:

sycl_device within the lambda should be moved

std::vector<device> res;
std::for_each(SubDevices.begin(), SubDevices.end(),
[&res, this](const ur_device_handle_t &a_ur_device) {
device sycl_device = detail::createSyclObjFromImpl<device>(
MPlatform->getOrMakeDeviceImpl(a_ur_device));
res.push_back(sycl_device);
});

CID 490149:

push_back into Composites

std::vector<device> Composites;
std::vector<device> Result;
for (auto &Dev : GPUDevices) {
if (!Dev.has(sycl::aspect::ext_oneapi_is_component))
continue;
auto Composite = Dev.get_info<
sycl::ext::oneapi::experimental::info::device::composite_device>();
if (std::find(Composites.begin(), Composites.end(), Composite) ==
Composites.end())
Composites.push_back(Composite);
}

CID 490211:

UnmapEventImpl->setHandle(UREvent);
std::swap(MAllocaCmd->MIsActive, MAllocaCmd->MLinkedAllocaCmd->MIsActive);
EventImpls.clear();
EventImpls.push_back(UnmapEventImpl);

CID 490242:

if (Start < End) {
std::string LastSubStr(str.substr(Start, End - Start));
// In case str has a delimeter at the end, the substring will be empty, so
// we shouldn't add it to the final vector
if (!LastSubStr.empty())
Result.push_back(LastSubStr);
}

CID 490405:

llvm/sycl/source/handler.cpp

Lines 1402 to 1408 in 6d5fe22

auto EventImpl = detail::getSyclObjImpl(Event);
// We could not wait for host task events in backend.
// Adding them as dependency to enable proper scheduling.
if (EventImpl->isHost()) {
depends_on(EventImpl);
}
impl->MEventsWaitWithBarrier.push_back(EventImpl);

CID 490430:

auto Composite = D.get_info<info::device::composite_device>();
Composites.insert(Composite);

CID 512042:

Note that multiple ext_oneapi_get_info overloads are affected

return impl->ext_oneapi_get_info<Param>(Queue, WG);

CID 521997:

std::vector<device> UniqueDevices =
sycl::detail::removeDuplicateDevices(Devices);
kernel_bundle_impl &sourceImpl = *getSyclObjImpl(SourceKB);
std::shared_ptr<kernel_bundle_impl> KBImpl = sourceImpl.compile_from_source(
UniqueDevices, BuildOptions, LogPtr, RegisteredKernelNames);
auto result = sycl::detail::createSyclObjFromImpl<obj_kb>(KBImpl);

CID 525242, 525254:

AsyncHandler and Devices could be moved

: MOwnedByRuntime(true), MAsyncHandler(AsyncHandler), MDevices(Devices),

CID 526323

llvm/sycl/source/handler.cpp

Lines 2469 to 2471 in 6d5fe22

auto E = AuxHandler.finalize();
if (EventNeeded)
CGH.depends_on(E);

CID 526341

llvm/sycl/source/handler.cpp

Lines 2487 to 2489 in 6d5fe22

auto E = CGH.finalize();
if (!InOrder)
PostProcessHandler.depends_on(E);

CID 527582, 527595:

Ctx and Devs could be moved

: MContext(Ctx), MDevices(Devs), MState(bundle_state::executable) {

CID 527597:

CID 528701:

Platforms.push_back(Platform);

Platforms.push_back(Platform);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions