fix: remove unnecessary comments from graph dump

Add section comments only when corresponding edges are present.

Related-To: NEO-15377
Signed-off-by: Naklicki, Mateusz <mateusz.naklicki@intel.com>
This commit is contained in:
Naklicki, Mateusz
2025-10-13 15:07:40 +00:00
committed by Compute-Runtime-Automation
parent fa1645eab8
commit e31d052328
2 changed files with 48 additions and 5 deletions

View File

@@ -119,6 +119,22 @@ TEST_F(GraphDotExporterTest, GivenGraphWithMultipleCommandsWhenWriteEdgesThenGen
EXPECT_NE(output.find("L0_S0_C0 -> L0_S0_C1"), std::string::npos);
}
TEST_F(GraphDotExporterTest, GivenGraphWithSingleCommandWhenWriteEdgesThenDoesNotGenerateSequentialSectionComment) {
Graph testGraph{&ctx, true};
Mock<Event> event;
Mock<CommandList> cmdlist;
cmdlist.cmdListType = L0::CommandList::CommandListType::typeImmediate;
testGraph.capture<CaptureApi::zeCommandListAppendBarrier>(&cmdlist, &event, 0U, nullptr);
testGraph.stopCapturing();
std::ostringstream dot;
exporter.writeEdges(dot, testGraph, 0, 0);
std::string output = dot.str();
EXPECT_EQ(output.find("// Sequential edges:"), std::string::npos);
}
TEST_F(GraphDotExporterTest, GivenGraphWithCommandWhenGetCommandNodeLabelThenReturnsCorrectLabel) {
Graph testGraph{&ctx, true};
Mock<Event> event;
@@ -466,6 +482,16 @@ TEST_F(GraphDotExporterTest, GivenGraphWithEmptySubgraphWhenWriteForkJoinEdgesTh
EXPECT_EQ(output.find("->"), std::string::npos);
}
TEST_F(GraphDotExporterTest, GivenGraphWithNoJoinedForksWhenWriteForkJoinEdgesThenNoSectionComment) {
Graph testGraph{&ctx, true};
std::ostringstream dot;
exporter.writeForkJoinEdges(dot, testGraph, 0, 0);
std::string output = dot.str();
EXPECT_EQ(output.find("// Fork/Join edges:"), std::string::npos);
}
TEST_F(GraphDotExporterTest, GivenGraphWithUnjoinedForksWhenWriteUnjoinedForkEdgesThenGeneratesUnjoinedEdges) {
Graph testGraph{&ctx, true};
Mock<Event> forkEvent;
@@ -525,6 +551,16 @@ TEST_F(GraphDotExporterTest, GivenGraphWithEmptyUnjoinedSubgraphWhenWriteUnjoine
testGraph.stopCapturing();
}
TEST_F(GraphDotExporterTest, GivenGraphWithNoUnjoinedForksWhenWriteUnjoinedForkEdgesThenNoSectionComment) {
Graph testGraph{&ctx, true};
std::ostringstream dot;
exporter.writeUnjoinedForkEdges(dot, testGraph, 0, 0);
std::string output = dot.str();
EXPECT_EQ(output.find("// Unjoined forks:"), std::string::npos);
}
class GraphDotExporterSimpleStyleTest : public ::testing::Test {
protected:
GraphsCleanupGuard graphCleanup;

View File

@@ -102,7 +102,10 @@ void GraphDotExporter::writeSequentialEdges(std::ostringstream &dot, const Graph
const std::string indent(static_cast<size_t>(level + 1) * 2, ' ');
const auto &commands = graph.getCapturedCommands();
dot << indent << "// Sequential edges:\n";
if (commands.size() > 1) {
dot << indent << "// Sequential edges:\n";
}
for (CapturedCommandId cmdId = 1; cmdId < static_cast<uint32_t>(commands.size()); ++cmdId) {
const std::string fromNode = generateNodeId(level, subgraphId, cmdId - 1);
@@ -117,8 +120,10 @@ void GraphDotExporter::writeForkJoinEdges(std::ostringstream &dot, const Graph &
const auto &joinedForks = graph.getJoinedForks();
const auto &subGraphs = graph.getSubgraphs();
dot << "\n"
<< indent << "// Fork/Join edges:\n";
if (!joinedForks.empty()) {
dot << "\n"
<< indent << "// Fork/Join edges:\n";
}
for (const auto &[forkCmdId, forkJoinInfo] : joinedForks) {
const auto subgraphIndex = findSubgraphIndex(subGraphs, forkJoinInfo.forkDestiny);
@@ -141,8 +146,10 @@ void GraphDotExporter::writeUnjoinedForkEdges(std::ostringstream &dot, const Gra
const auto &unjoinedForks = graph.getUnjoinedForks();
const auto &subGraphs = graph.getSubgraphs();
dot << "\n"
<< indent << "// Unjoined forks:\n";
if (!unjoinedForks.empty()) {
dot << "\n"
<< indent << "// Unjoined forks:\n";
}
for (const auto &[cmdList, forkInfo] : unjoinedForks) {
const auto subgraphIndex = findSubgraphIndexByCommandList(subGraphs, cmdList);