Skip to content

[SYCL RT][Coverity] Optimizing by moving instead of copy#22462

Open
Robertkq wants to merge 4 commits into
intel:syclfrom
Robertkq:Robertkq/19234
Open

[SYCL RT][Coverity] Optimizing by moving instead of copy#22462
Robertkq wants to merge 4 commits into
intel:syclfrom
Robertkq:Robertkq/19234

Conversation

@Robertkq

@Robertkq Robertkq commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

fixes #19234

This PR addresses the following CID: 490211, 490242, 490405, 512042. All of the other CIDs that were specified by the issue #19234 have already been in the fixed state when I started working on this.

@Robertkq Robertkq requested a review from a team as a code owner June 27, 2026 17:57
@Robertkq Robertkq requested a review from uditagarwal97 June 27, 2026 17:57
@Robertkq

Copy link
Copy Markdown
Contributor Author
image

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Coverity findings in the SYCL runtime by eliminating unnecessary copies and enabling move semantics when forwarding temporaries (e.g., queue, std::shared_ptr, and std::string) into implementation/storage APIs.

Changes:

  • Forward queue parameters into kernel_impl::ext_oneapi_get_info via std::move for several overloads.
  • Move event implementation pointers into MEventsWaitWithBarrier to avoid refcounting/copies.
  • Move the final substring into the result vector in split_string to avoid an extra copy.

No control-flow changes were introduced beyond adding braces around an existing conditional; nothing here appears likely to impact profiling/debug info integrity.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
sycl/source/kernel.cpp Move queue when delegating kernel::ext_oneapi_get_info overloads to the impl to avoid copies.
sycl/source/handler.cpp Move EventImpl into MEventsWaitWithBarrier to avoid shared_ptr copies/refcount churn.
sycl/source/detail/split_string.hpp Move LastSubStr into the result vector to avoid copying the last token.
sycl/source/detail/scheduler/commands.cpp Move UnmapEventImpl into EventImpls to avoid copying shared_ptr.

@uditagarwal97 uditagarwal97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT

Comment on lines +34 to +36
if (!LastSubStr.empty()) {
Result.push_back(std::move(LastSubStr));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!LastSubStr.empty()) {
Result.push_back(std::move(LastSubStr));
}
if (!LastSubStr.empty())
Result.push_back(std::move(LastSubStr));

@Robertkq Robertkq Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this as my clang-format or maybe some clangd/clang extension suggested it. I assume that it automatically read the .clang-format or related config file of the project and suggested the prefered syntax

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Which clang-format version are you using?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

clang-format --version

clang-format version 22.1.8 (Fedora 22.1.8-1.fc44)

clang-tidy --version

LLVM (http://llvm.org/):
  LLVM version 22.1.8
  Optimized build.

@Robertkq

Copy link
Copy Markdown
Contributor Author

Moved to comment from PR body:

For 512042, I found multiple cases of this missed optimization to move instead of copy in the same file, so I changed it for all. I tried to inspect the latest coverity report by file but I failed to find the correct filter / setting to use to check for existing CID for these appearances

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SYCL RT][Coverity] Copy instead of move

3 participants