From c4cab41cc2799354a29b705f389e0d57a2f4ec90 Mon Sep 17 00:00:00 2001 From: Rahul Manocha Date: Fri, 13 Sep 2024 12:16:52 -0700 Subject: [PATCH] SWDEV-479575 - Add marker to parent graph dependencies in childgraph node 1) Child Graph nodes need to have parent graph dependencies in waitlist. 2) Marker is placed on base stream with parent graph waitlist Change-Id: Iec65a0171ea387be05b0733abcc708fb630e4be4 [ROCm/clr commit: 4d1ded9eaf949df3381b6d3484ce8f8ee1e75801] --- .../clr/hipamd/src/hip_graph_internal.cpp | 36 ++++++++++++------- .../clr/hipamd/src/hip_graph_internal.hpp | 3 +- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/projects/clr/hipamd/src/hip_graph_internal.cpp b/projects/clr/hipamd/src/hip_graph_internal.cpp index c90a8cd75e..83d53b162c 100644 --- a/projects/clr/hipamd/src/hip_graph_internal.cpp +++ b/projects/clr/hipamd/src/hip_graph_internal.cpp @@ -666,24 +666,24 @@ bool Graph::RunOneNode(Node node, bool wait) { } } + // Create a wait list from the last launches of all dependencies + for (auto dep : wait_order_) { + if (dep != nullptr) { + // Add all commands in the wait list + if (dep->GetType() != hipGraphNodeTypeGraph) { + for (auto command : dep->GetCommands()) { + waitList.push_back(command); + } + } + } + } if (node->GetType() == hipGraphNodeTypeGraph) { // Process child graph separately, since, there is no connection auto child = reinterpret_cast(node)->childGraph_; if (!reinterpret_cast(node)->graphCaptureStatus_) { - child->RunNodes(node->stream_id_, &streams_); + child->RunNodes(node->stream_id_, &streams_, &waitList); } } else { - // Create a wait list from the last launches of all dependencies - for (auto dep : wait_order_) { - if (dep != nullptr) { - // Add all commands in the wait list - if (dep->GetType() != hipGraphNodeTypeGraph) { - for (auto command : dep->GetCommands()) { - waitList.push_back(command); - } - } - } - } // Assing a stream to the current node node->SetStream(streams_); // Create the execution commands on the assigned stream @@ -731,11 +731,21 @@ bool Graph::RunOneNode(Node node, bool wait) { // ================================================================================================ bool Graph::RunNodes( int32_t base_stream, - const std::vector* parallel_streams) { + const std::vector* parallel_streams, + const amd::Command::EventWaitList* parent_waitlist) { + if (parallel_streams != nullptr) { streams_ = *parallel_streams; } + // childgraph node has dependencies on parent graph nodes from other streams + if (parent_waitlist != nullptr) { + auto start_marker = new amd::Marker(*streams_[base_stream], true, *parent_waitlist); + if (start_marker != nullptr) { + start_marker->enqueue(); + start_marker->release(); + } + } amd::Command::EventWaitList wait_list; current_id_ = 0; memset(&leafs_[0], 0, sizeof(Node) * leafs_.size()); diff --git a/projects/clr/hipamd/src/hip_graph_internal.hpp b/projects/clr/hipamd/src/hip_graph_internal.hpp index 6e32f1d02e..67fdfd1066 100644 --- a/projects/clr/hipamd/src/hip_graph_internal.hpp +++ b/projects/clr/hipamd/src/hip_graph_internal.hpp @@ -601,7 +601,8 @@ struct Graph { //! Runs all nodes from the execution graph on the assigned streams bool RunNodes( int32_t base_stream = 0, //!< The base stream to run the graph on - const std::vector* streams = nullptr //!< Streams to run the graph + const std::vector* streams = nullptr, //!< Streams to run the graph + const amd::Command::EventWaitList* parent_waitlist = nullptr //!< Parent Graph waitlist ); bool TopologicalOrder(std::vector& TopoOrder);