Skip to content

Commit ff0a7ac

Browse files
authored
[SYCL][Graph]Fix coverity issues by passing shared pointer by reference. (#18473)
Changes some functions in the sycl graph implementation to pass shared pointers by reference instead of by value. Fixes: #18412
1 parent 92479ee commit ff0a7ac

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

sycl/source/detail/graph_impl.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void propagatePartitionUp(std::shared_ptr<node_impl> Node, int PartitionNum) {
139139
/// @param HostTaskList List of host tasks that have already been processed and
140140
/// are encountered as successors to the node Node.
141141
void propagatePartitionDown(
142-
std::shared_ptr<node_impl> Node, int PartitionNum,
142+
const std::shared_ptr<node_impl> &Node, int PartitionNum,
143143
std::list<std::shared_ptr<node_impl>> &HostTaskList) {
144144
if (Node->MCGType == sycl::detail::CGType::CodeplayHostTask) {
145145
if (Node->MPartitionNum != -1) {
@@ -753,7 +753,7 @@ std::vector<sycl::detail::EventImplPtr> graph_impl::getExitNodesEvents(
753753
}
754754

755755
void graph_impl::beginRecording(
756-
std::shared_ptr<sycl::detail::queue_impl> Queue) {
756+
const std::shared_ptr<sycl::detail::queue_impl> &Queue) {
757757
graph_impl::WriteLock Lock(MMutex);
758758
if (!Queue->hasCommandGraph()) {
759759
Queue->setCommandGraph(shared_from_this());
@@ -1024,9 +1024,10 @@ exec_graph_impl::enqueue(const std::shared_ptr<sycl::detail::queue_impl> &Queue,
10241024
for (std::vector<sycl::detail::EventImplPtr>::iterator It =
10251025
MExecutionEvents.begin();
10261026
It != MExecutionEvents.end();) {
1027-
auto Event = *It;
1027+
EventImplPtr &Event = *It;
10281028
if (!Event->isCompleted()) {
1029-
auto &AttachedEventsList = Event->getPostCompleteEvents();
1029+
const std::vector<EventImplPtr> &AttachedEventsList =
1030+
Event->getPostCompleteEvents();
10301031
CGData.MEvents.reserve(CGData.MEvents.size() +
10311032
AttachedEventsList.size() + 1);
10321033
CGData.MEvents.push_back(Event);

sycl/source/detail/graph_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
895895
/// @param EventImpl Event to associate with a node in map.
896896
/// @param NodeImpl Node to associate with event in map.
897897
void addEventForNode(std::shared_ptr<sycl::detail::event_impl> EventImpl,
898-
std::shared_ptr<node_impl> NodeImpl) {
898+
const std::shared_ptr<node_impl> &NodeImpl) {
899899
if (!(EventImpl->hasCommandGraph()))
900900
EventImpl->setCommandGraph(shared_from_this());
901901
MEventsMap[EventImpl] = NodeImpl;
@@ -1145,7 +1145,7 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
11451145
/// Sets the Queue state to queue_state::recording. Adds the queue to the list
11461146
/// of recording queues associated with this graph.
11471147
/// @param[in] Queue The queue to be recorded from.
1148-
void beginRecording(std::shared_ptr<sycl::detail::queue_impl> Queue);
1148+
void beginRecording(const std::shared_ptr<sycl::detail::queue_impl> &Queue);
11491149

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

0 commit comments

Comments
 (0)