From c2a4062392797651694e94b1814f2fb105b5d2ee Mon Sep 17 00:00:00 2001 From: Anusha GodavarthySurya Date: Tue, 20 Aug 2024 09:27:42 +0000 Subject: [PATCH] SWDEV-470612 - Add stream id to DOT print when DEBUG_HIP_GRAPH_DOT_PRINT is enabled Change-Id: Iec3630ba6fb2206925653ea939770bb9820d7c52 [ROCm/clr commit: 19bf971134d13fb05edd533001110d1a7a2f178d] --- projects/clr/hipamd/src/hip_graph.cpp | 2 +- .../clr/hipamd/src/hip_graph_internal.hpp | 46 +++++++++++-------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/projects/clr/hipamd/src/hip_graph.cpp b/projects/clr/hipamd/src/hip_graph.cpp index ac7144121e..3fe822ff1d 100644 --- a/projects/clr/hipamd/src/hip_graph.cpp +++ b/projects/clr/hipamd/src/hip_graph.cpp @@ -1319,7 +1319,7 @@ hipError_t ihipGraphInstantiate(hip::GraphExec** pGraphExec, hip::Graph* graph, std::string filename = "graph_" + std::to_string(amd::Os::getProcessId()) + "_dot_print_" + std::to_string(i++); hipError_t status = - ihipGraphDebugDotPrint(reinterpret_cast(graph), filename.c_str(), 0); + ihipGraphDebugDotPrint(reinterpret_cast(clonedGraph), filename.c_str(), 0); if (status == hipSuccess) { LogPrintfInfo("[hipGraph] graph dump:%s", filename.c_str()); } diff --git a/projects/clr/hipamd/src/hip_graph_internal.hpp b/projects/clr/hipamd/src/hip_graph_internal.hpp index ba7bc8d84f..c491088def 100644 --- a/projects/clr/hipamd/src/hip_graph_internal.hpp +++ b/projects/clr/hipamd/src/hip_graph_internal.hpp @@ -148,22 +148,7 @@ struct hipGraphNodeDOTAttribute { virtual std::string GetLabel(hipGraphDebugDotFlags flag) { return label_; } - virtual void PrintAttributes(std::ostream& out, hipGraphDebugDotFlags flag) { - out << "["; - out << "style"; - out << "=\""; - out << style_; - out << "\""; - out << "shape"; - out << "=\""; - out << GetShape(flag); - out << "\""; - out << "label"; - out << "=\""; - out << GetLabel(flag); - out << "\""; - out << "];"; - } + virtual void PrintAttributes(std::ostream& out, hipGraphDebugDotFlags flag) {} }; class GraphKernelArgManager : public amd::ReferenceCountedObject, public amd::GraphKernelArgManager { @@ -465,6 +450,25 @@ struct GraphNode : public hipGraphNodeDOTAttribute { } return isGraphCapture; } + virtual void PrintAttributes(std::ostream& out, hipGraphDebugDotFlags flag) override { + out << "["; + out << "style"; + out << "=\""; + out << style_; + out << "\""; + out << "shape"; + out << "=\""; + out << GetShape(flag); + out << "\""; + out << "label"; + out << "=\""; + out << GetLabel(flag); + if (DEBUG_HIP_GRAPH_DOT_PRINT) { + out << "\nStreamId:" << stream_id_; + } + out << "\""; + out << "];"; + } }; struct Graph { @@ -969,8 +973,9 @@ class GraphKernelNode : public GraphNode { out << "=\""; out << style_; (flag == hipGraphDebugDotFlagsKernelNodeParams || - flag == hipGraphDebugDotFlagsKernelNodeAttributes) ? - out << "\n" : out << "\""; + flag == hipGraphDebugDotFlagsKernelNodeAttributes) + ? out << "\n" + : out << "\""; out << "shape"; out << "=\""; out << GetShape(flag); @@ -978,9 +983,12 @@ class GraphKernelNode : public GraphNode { out << "label"; out << "=\""; out << GetLabel(flag); + if (DEBUG_HIP_GRAPH_DOT_PRINT) { + out << "StreamId:" << stream_id_; + } out << "\""; out << "];"; - } + } virtual std::string GetLabel(hipGraphDebugDotFlags flag) override { hipFunction_t func = getFunc(kernelParams_, ihipGetDevice());