Skip to content

Commit 58b0af4

Browse files
committed
cts: update techChar debugprints to a better description of the steps
Signed-off-by: arthurjolo <[email protected]>
1 parent a6bbc93 commit 58b0af4

File tree

1 file changed

+46
-41
lines changed

1 file changed

+46
-41
lines changed

src/cts/src/TechChar.cpp

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (c) 2019-2025, The OpenROAD Authors
33

44
#include "TechChar.h"
5+
#include <spdlog/spdlog.h>
56

67
#include <algorithm>
78
#include <bitset>
@@ -942,18 +943,22 @@ std::vector<TechChar::SolutionData> TechChar::createPatterns(
942943
// can be placed and...
943944
//...the number of topologies (combinations of buffers, considering only 1
944945
// drive) that can exist.
946+
945947
const unsigned numberOfNodes
946948
= setupWirelength / options_->getWireSegmentUnit();
947949
const unsigned numberOfTopologies = 1 << numberOfNodes;
948950
std::vector<SolutionData> topologiesVector;
949951
odb::dbNet* net = nullptr;
950952
// clang-format off
951-
debugPrint(logger_, CTS, "tech char", 1, "createPatterns WL:{} #nodes:{}"
952-
"#topo:{}", setupWirelength, numberOfNodes, numberOfTopologies);
953+
debugPrint(logger_, CTS, "tech char", 1, "*createPatterns for #nodes = {}"
954+
" #topologies = {}", setupWirelength, numberOfNodes, numberOfTopologies);
953955
// clang-format on
954956
// For each possible topology...
955957
for (unsigned solutionCounterInt = 0; solutionCounterInt < numberOfTopologies;
956958
solutionCounterInt++) {
959+
debugPrint(logger_, CTS, "tech char", 1, "**topology {}", solutionCounterInt + 1);
960+
std::stringstream tmp;
961+
tmp << "***IN ";
957962
// Creates a bitset that represents the buffer locations.
958963
const std::bitset<5> solutionCounter(solutionCounterInt);
959964
int wireCounter = 0;
@@ -983,20 +988,24 @@ std::vector<TechChar::SolutionData> TechChar::createPatterns(
983988
// Not a buffer, only a wire segment.
984989
nodesWithoutBuf++;
985990
// clang-format off
986-
debugPrint(logger_, CTS, "tech char", 1, " wire at node:{} topo:{}",
991+
debugPrint(logger_, CTS, "tech char", 2, "***wire at node : {}",
987992
nodeIndex, solutionCounterInt);
988993
// clang-format on
989994
} else {
990995
// Buffer, need to create the instance and a new net.
991996
nodesWithoutBuf++;
997+
for(auto i = 0; i < nodesWithoutBuf - 1; i++) {
998+
tmp << "-- ";
999+
}
1000+
tmp << "-> ";
9921001
// Creates a new buffer instance.
9931002
const std::string bufName = fmt::format("buf_{}_{}_{}",
9941003
setupWirelength,
9951004
solutionCounter.to_string(),
9961005
wireCounter);
9971006
// clang-format off
998-
debugPrint(logger_, CTS, "tech char", 1, " buffer {} at node:{} "
999-
"topo:{}", bufName, nodeIndex, solutionCounterInt);
1007+
debugPrint(logger_, CTS, "tech char", 2, "***buffer {} at node : {}"
1008+
, bufName, nodeIndex, solutionCounterInt);
10001009
// clang-format on
10011010
odb::dbInst* bufInstance
10021011
= odb::dbInst::create(charBlock_, charBuf_, bufName.c_str());
@@ -1020,11 +1029,6 @@ std::vector<TechChar::SolutionData> TechChar::createPatterns(
10201029
// Updates the topology wih the new instance and the current topology
10211030
// (as a vector of strings).
10221031
topology.instVector.push_back(bufInstance);
1023-
// clang-format off
1024-
debugPrint(logger_, CTS, "tech char", 1, " topo instVector size:{} "
1025-
"node:{} topo:{}", topology.instVector.size(), nodeIndex,
1026-
solutionCounterInt);
1027-
// clang-format on
10281032
topology.topologyDescriptor.push_back(
10291033
std::to_string(nodesWithoutBuf * options_->getWireSegmentUnit()));
10301034
topology.topologyDescriptor.push_back(charBuf_->getName());
@@ -1041,6 +1045,11 @@ std::vector<TechChar::SolutionData> TechChar::createPatterns(
10411045
odb::dbBPin* outPortPin = odb::dbBPin::create(outPort);
10421046
// Updates the topology with the output port, old new, possible instances
10431047
// and other attributes.
1048+
for(auto i = 0; i < nodesWithoutBuf; i++) {
1049+
tmp << "-- ";
1050+
}
1051+
tmp << "OUT";
1052+
debugPrint(logger_, CTS, "tech char", 1, tmp.str());
10441053
topology.outPort = outPortPin;
10451054
if (isPureWire) {
10461055
topology.instVector.push_back(nullptr);
@@ -1194,7 +1203,7 @@ TechChar::ResultData TechChar::computeTopologyResults(
11941203
const float pinArrival = openStaChar_->vertexArrival(
11951204
outPinVert, sta::RiseFall::fall(), charPathAnalysis_);
11961205
results.pinArrival = pinArrival;
1197-
// Computations for output slew.
1206+
// Computations for output slew. Avg of rise and fall slew.
11981207
const float pinRise = openStaChar_->vertexSlew(
11991208
outPinVert, sta::RiseFall::rise(), sta::MinMax::max());
12001209
const float pinFall = openStaChar_->vertexSlew(
@@ -1333,7 +1342,7 @@ void TechChar::updateBufferTopologies(TechChar::SolutionData& solution)
13331342
odb::dbInst* inst = solution.instVector[nodeIndex];
13341343
inst->swapMaster(newMaster);
13351344
// clang-format off
1336-
debugPrint(logger_, CTS, "tech char", 1, "**updateBufferTopologies swap "
1345+
debugPrint(logger_, CTS, "tech char", 1, "***updateBufferTopologies swap "
13371346
"from {} to {}, index:{}", oldMaster->getName(),
13381347
newMaster->getName(), nodeIndex);
13391348
// clang-format on
@@ -1344,6 +1353,10 @@ void TechChar::updateBufferTopologies(TechChar::SolutionData& solution)
13441353

13451354
std::vector<size_t> TechChar::getCurrConfig(const SolutionData& solution)
13461355
{
1356+
if(solution.isPureWire) {
1357+
debugPrint(logger_, CTS, "tech char", 1,"**currConfig is a pure wire");
1358+
return {};
1359+
}
13471360
std::vector<size_t> config;
13481361
for (auto inst : solution.instVector) {
13491362
size_t masterID = cellNameToID(inst->getMaster()->getName());
@@ -1352,11 +1365,11 @@ std::vector<size_t> TechChar::getCurrConfig(const SolutionData& solution)
13521365

13531366
if (logger_->debugCheck(CTS, "tech char", 1)) {
13541367
std::stringstream tmp;
1355-
tmp << "currConfig: ";
1368+
tmp << "**currConfig: ";
13561369
for (unsigned i : config) {
13571370
tmp << i << " ";
13581371
}
1359-
logger_->report(tmp.str());
1372+
debugPrint(logger_, CTS, "tech char", 1, tmp.str());
13601373
}
13611374
return config;
13621375
}
@@ -1368,7 +1381,7 @@ size_t TechChar::cellNameToID(const std::string& masterName)
13681381
return std::distance(masterNames_.begin(), masterIter);
13691382
}
13701383

1371-
// Find a buffer config that is monotonic from current buffer config
1384+
// Find a buffer config that is monotonic from current buffer config.
13721385
std::vector<size_t> TechChar::getNextConfig(
13731386
const std::vector<size_t>& currConfig)
13741387
{
@@ -1392,11 +1405,11 @@ std::vector<size_t> TechChar::getNextConfig(
13921405

13931406
if (logger_->debugCheck(CTS, "tech char", 1)) {
13941407
std::stringstream tmp;
1395-
tmp << "nextConfig: ";
1408+
tmp << "**nextConfig: ";
13961409
for (unsigned i : nextConfig) {
13971410
tmp << i << " ";
13981411
}
1399-
logger_->report(tmp.str());
1412+
debugPrint(logger_, CTS, "tech char", 1, tmp.str());
14001413
}
14011414

14021415
return nextConfig;
@@ -1426,15 +1439,15 @@ void TechChar::swapTopologyBuffer(SolutionData& solution,
14261439
topologyIndex++) {
14271440
const std::string topologyS = solution.topologyDescriptor[topologyIndex];
14281441
// clang-format off
1429-
debugPrint(logger_, CTS, "tech char", 1, "**topo:{} topoIdx:{}",
1442+
debugPrint(logger_, CTS, "tech char", 1, "***topo:{} topoIdx:{}",
14301443
topologyS, topologyIndex);
14311444
// clang-format on
14321445
if (!(std::find(masterNames_.begin(), masterNames_.end(), topologyS)
14331446
== masterNames_.end())) {
14341447
if (topologyCounter == nodeIndex) {
14351448
solution.topologyDescriptor[topologyIndex] = newMasterName;
14361449
// clang-format off
1437-
debugPrint(logger_, CTS, "tech char", 1, "**soln topo descript at "
1450+
debugPrint(logger_, CTS, "tech char", 1, "***soln topo descript at "
14381451
"{} set to {}", topologyIndex, newMasterName);
14391452
// clang-format on
14401453
break;
@@ -1561,6 +1574,7 @@ void TechChar::create()
15611574
int64_t topologiesCreated = 0;
15621575
for (unsigned setupWirelength : wirelengthsToTest_) {
15631576
// Creates the topologies for the current wirelength.
1577+
debugPrint(logger_, CTS, "tech char", 1, "Wirelength = {}", setupWirelength);
15641578
std::vector<SolutionData> topologiesVector
15651579
= createPatterns(setupWirelength);
15661580
// Creates an OpenSTA instance.
@@ -1572,9 +1586,8 @@ void TechChar::create()
15721586
int topoIndex = 0;
15731587
for (SolutionData solution : topologiesVector) {
15741588
// clang-format off
1575-
debugPrint(logger_, CTS, "tech char", 1, "create WL:{} of {}, "
1576-
"topo:{} of {}", setupWirelength, wirelengthsToTest_.size(),
1577-
topoIndex, topologiesVector.size());
1589+
debugPrint(logger_, CTS, "tech char", 1, "*genrate combinations for "
1590+
"topology: {} of {}", topoIndex + 1, topologiesVector.size());
15781591
// clang-format on
15791592
topoIndex++;
15801593
// Gets the input and output port (as terms, pins and vertices).
@@ -1610,15 +1623,15 @@ void TechChar::create()
16101623
r1,
16111624
c1,
16121625
piExists);
1626+
1627+
// clang-format off
1628+
debugPrint(logger_, CTS, "tech char", 1, "*# bufs = {}; "
1629+
"# nodes with buf = {}",
1630+
masterNames_.size(), solution.instVector.size());
1631+
// clang-format on
16131632
// For each possible buffer combination (different sizes).
16141633
unsigned buffersUpdate
16151634
= getBufferingCombo(masterNames_.size(), solution.instVector.size());
1616-
// clang-format off
1617-
debugPrint(logger_, CTS, "tech char", 1, "create #bufs={} "
1618-
"#soln.instVector.size={}, #bufUpdate={}, #topo={}",
1619-
masterNames_.size(), solution.instVector.size(),
1620-
buffersUpdate, topologiesCreated);
1621-
// clang-format on
16221635

16231636
if (buffersUpdate == 0) {
16241637
continue;
@@ -1737,14 +1750,10 @@ void TechChar::create()
17371750
unsigned TechChar::getBufferingCombo(size_t numBuffers, size_t numNodes)
17381751
{
17391752
// check if this has been computed already
1740-
std::stringstream tmp;
17411753
std::pair iPair(numBuffers, numNodes);
17421754
auto iter = bufferingComboTable_.find(iPair);
17431755
if (iter != bufferingComboTable_.end()) {
1744-
if (logger_->debugCheck(CTS, "tech char", 1)) {
1745-
tmp << "Monotonic entries (hashed): " << iter->second << '\n';
1746-
logger_->report(tmp.str());
1747-
}
1756+
debugPrint(logger_, CTS, "tech char", 1,"**Monotonic entries are already hashed: {}", iter->second);
17481757
return iter->second;
17491758
}
17501759

@@ -1762,6 +1771,8 @@ unsigned TechChar::getBufferingCombo(size_t numBuffers, size_t numNodes)
17621771

17631772
unsigned numMonotonic = 0;
17641773
for (const auto& row : matrix) {
1774+
std::stringstream tmp;
1775+
tmp << "**";
17651776
for (size_t val : row) {
17661777
if (logger_->debugCheck(CTS, "tech char", 1)) {
17671778
tmp << val << " ";
@@ -1773,15 +1784,9 @@ unsigned TechChar::getBufferingCombo(size_t numBuffers, size_t numNodes)
17731784
}
17741785
numMonotonic++;
17751786
}
1776-
if (logger_->debugCheck(CTS, "tech char", 1)) {
1777-
logger_->report(tmp.str());
1778-
}
1779-
}
1780-
if (logger_->debugCheck(CTS, "tech char", 1)) {
1781-
tmp << "Monotonic entries: " << numMonotonic;
1782-
logger_->report(tmp.str());
1787+
debugPrint(logger_, CTS, "tech char", 1, tmp.str());
17831788
}
1784-
1789+
debugPrint(logger_, CTS, "tech char", 1, "**Monotonic entries: {}", numMonotonic);
17851790
// insert new result into hash table
17861791
bufferingComboTable_[iPair] = numMonotonic;
17871792
return numMonotonic;

0 commit comments

Comments
 (0)