Skip to content

[SYCL][Graph]Fix coverity issues by passing shared pointer by reference. #18473

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

Open
wants to merge 2 commits into
base: sycl
Choose a base branch
from
Open
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
9 changes: 5 additions & 4 deletions sycl/source/detail/graph_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void propagatePartitionUp(std::shared_ptr<node_impl> Node, int PartitionNum) {
/// @param HostTaskList List of host tasks that have already been processed and
/// are encountered as successors to the node Node.
void propagatePartitionDown(
std::shared_ptr<node_impl> Node, int PartitionNum,
const std::shared_ptr<node_impl> &Node, int PartitionNum,
std::list<std::shared_ptr<node_impl>> &HostTaskList) {
if (Node->MCGType == sycl::detail::CGType::CodeplayHostTask) {
if (Node->MPartitionNum != -1) {
Expand Down Expand Up @@ -753,7 +753,7 @@ std::vector<sycl::detail::EventImplPtr> graph_impl::getExitNodesEvents(
}

void graph_impl::beginRecording(
std::shared_ptr<sycl::detail::queue_impl> Queue) {
const std::shared_ptr<sycl::detail::queue_impl> &Queue) {
graph_impl::WriteLock Lock(MMutex);
if (!Queue->hasCommandGraph()) {
Queue->setCommandGraph(shared_from_this());
Expand Down Expand Up @@ -1024,9 +1024,10 @@ exec_graph_impl::enqueue(const std::shared_ptr<sycl::detail::queue_impl> &Queue,
for (std::vector<sycl::detail::EventImplPtr>::iterator It =
MExecutionEvents.begin();
It != MExecutionEvents.end();) {
auto Event = *It;
EventImplPtr &Event = *It;
if (!Event->isCompleted()) {
auto &AttachedEventsList = Event->getPostCompleteEvents();
const std::vector<EventImplPtr> &AttachedEventsList =
Event->getPostCompleteEvents();
CGData.MEvents.reserve(CGData.MEvents.size() +
AttachedEventsList.size() + 1);
CGData.MEvents.push_back(Event);
Expand Down
6 changes: 3 additions & 3 deletions sycl/source/detail/graph_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
/// @param EventImpl Event to associate with a node in map.
/// @param NodeImpl Node to associate with event in map.
void addEventForNode(std::shared_ptr<sycl::detail::event_impl> EventImpl,
std::shared_ptr<node_impl> NodeImpl) {
const std::shared_ptr<node_impl> &NodeImpl) {
if (!(EventImpl->hasCommandGraph()))
EventImpl->setCommandGraph(shared_from_this());
MEventsMap[EventImpl] = NodeImpl;
Expand Down Expand Up @@ -1145,7 +1145,7 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
/// Sets the Queue state to queue_state::recording. Adds the queue to the list
/// of recording queues associated with this graph.
/// @param[in] Queue The queue to be recorded from.
void beginRecording(std::shared_ptr<sycl::detail::queue_impl> Queue);
void beginRecording(const std::shared_ptr<sycl::detail::queue_impl> &Queue);

/// Store the last barrier node that was submitted to the queue.
/// @param[in] Queue The queue the barrier was recorded from.
Expand Down Expand Up @@ -1212,7 +1212,7 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
/// added as a root node.
/// @param Node The node to add deps for
/// @param Deps List of dependent nodes
void addDepsToNode(std::shared_ptr<node_impl> Node,
void addDepsToNode(const std::shared_ptr<node_impl> &Node,
std::vector<std::shared_ptr<node_impl>> &Deps) {
if (!Deps.empty()) {
for (auto &N : Deps) {
Expand Down