diff --git a/src/cts/src/Clock.cpp b/src/cts/src/Clock.cpp index c0cf60495b..84b602c84a 100644 --- a/src/cts/src/Clock.cpp +++ b/src/cts/src/Clock.cpp @@ -106,7 +106,7 @@ Box Clock::computeSinkRegion() } Box Clock::computeSinkRegionClustered( - std::vector> sinks) + const std::vector>& sinks) { auto xMin = std::numeric_limits::max(); auto xMax = std::numeric_limits::lowest(); diff --git a/src/cts/src/Clock.h b/src/cts/src/Clock.h index 5b3abf13ed..8ce130c257 100644 --- a/src/cts/src/Clock.h +++ b/src/cts/src/Clock.h @@ -248,7 +248,7 @@ class Clock Box computeSinkRegion(); Box computeSinkRegionClustered( - std::vector> sinks); + const std::vector>& sinks); Box computeNormalizedSinkRegion(double factor); void report(utl::Logger* logger) const; diff --git a/src/cts/src/Clustering.cpp b/src/cts/src/Clustering.cpp index f8a66bf13c..4e0f77a444 100644 --- a/src/cts/src/Clustering.cpp +++ b/src/cts/src/Clustering.cpp @@ -66,11 +66,13 @@ using utl::CTS; struct Sink { Sink(const float x, const float y, const unsigned idx) - : x(x), y(y), cluster_idx(-1), sink_idx(idx){}; + : x(x), y(y), sink_idx(idx) + { + } // location const float x, y; - int cluster_idx; + int cluster_idx{-1}; const unsigned sink_idx; // index in sinks_ }; diff --git a/src/cts/src/HTreeBuilder.cpp b/src/cts/src/HTreeBuilder.cpp index a560067e83..86998e098f 100644 --- a/src/cts/src/HTreeBuilder.cpp +++ b/src/cts/src/HTreeBuilder.cpp @@ -64,8 +64,8 @@ void HTreeBuilder::preSinkClustering( (float) inst.getY() / wireSegmentUnit_); mapLocationToSink_[normLocation] = &inst; if (!fuzzyEqual(inst.getInsertionDelay(), 0.0, 1e-6)) { - setSinkInsertionDelay( - normLocation, (double) inst.getInsertionDelay() / wireSegmentUnit_); + setSinkInsertionDelay(normLocation, + inst.getInsertionDelay() / wireSegmentUnit_); // clang-format off debugPrint(logger_, CTS, "clustering", 1, "sink {} has insDelay {} at {}", inst.getName(), getSinkInsertionDelay(normLocation), @@ -358,7 +358,7 @@ void plotBlockage(std::ofstream& file, odb::dbDatabase* db_, int scalingFactor) int h = bbox->yMax() / scalingFactor - bbox->yMin() / scalingFactor; file << i++ << " " << x << " " << y << " " << w << " " << h << " block scalingFactor="; - file << scalingFactor << " " << blockage->getId() << std::endl; + file << scalingFactor << " " << blockage->getId() << '\n'; } } @@ -385,7 +385,7 @@ void plotSinks(std::ofstream& file, const std::vector>& sinks) double h = 1; auto name = "sink_"; file << cnt++ << " " << x << " " << y << " " << w << " " << h; - file << " " << name << " " << std::endl; + file << " " << name << '\n'; } } @@ -1252,7 +1252,7 @@ std::string HTreeBuilder::plotHTree() double y2 = branchPoint.getY(); std::string name = "buffer"; file << levelIdx << " " << x1 << " " << y1 << " " << x2 << " " << y2; - file << " " << name << std::endl; + file << " " << name << '\n'; }); } @@ -1271,7 +1271,7 @@ std::string HTreeBuilder::plotHTree() file << numSinks << " " << loc.getX() << " " << loc.getY(); file << " " << px << " " << py << " leafbuffer " << name2; - file << " z=" << wireSegmentUnit_ << std::endl; + file << " z=" << wireSegmentUnit_ << '\n'; ++numSinks; } }); diff --git a/src/cts/src/HTreeBuilder.h b/src/cts/src/HTreeBuilder.h index 0b8851d700..c6980f3fe0 100644 --- a/src/cts/src/HTreeBuilder.h +++ b/src/cts/src/HTreeBuilder.h @@ -89,7 +89,7 @@ class HTreeBuilder : public TreeBuilder public: static constexpr unsigned NO_PARENT = std::numeric_limits::max(); - explicit LevelTopology(double length) : length_(length){}; + explicit LevelTopology(double length) : length_(length) {} void addWireSegment(unsigned idx) { wireSegments_.push_back(idx); } diff --git a/src/cts/src/LevelBalancer.cpp b/src/cts/src/LevelBalancer.cpp index 718b333a65..d17dfd1991 100644 --- a/src/cts/src/LevelBalancer.cpp +++ b/src/cts/src/LevelBalancer.cpp @@ -83,7 +83,7 @@ unsigned LevelBalancer::computeMaxTreeDepth(TreeBuilder* parent) } void LevelBalancer::addBufferLevels(TreeBuilder* builder, - const std::vector cluster, + const std::vector& cluster, ClockSubNet* driverNet, const unsigned bufLevels, const std::string& nameSuffix) diff --git a/src/cts/src/LevelBalancer.h b/src/cts/src/LevelBalancer.h index ee614f0e73..cd774bf11a 100644 --- a/src/cts/src/LevelBalancer.h +++ b/src/cts/src/LevelBalancer.h @@ -98,7 +98,7 @@ class LevelBalancer void run(); void addBufferLevels(TreeBuilder* builder, - std::vector cluster, + const std::vector& cluster, ClockSubNet* driverNet, unsigned bufLevels, const std::string& nameSuffix); diff --git a/src/cts/src/SinkClustering.cpp b/src/cts/src/SinkClustering.cpp index ceeefe5f52..d8d2eedab7 100644 --- a/src/cts/src/SinkClustering.cpp +++ b/src/cts/src/SinkClustering.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -307,9 +308,9 @@ bool SinkClustering::findBestMatching(const unsigned groupSize) // Add vectors in case they are no allocated yet. (Depends if a new // cluster was defined above) if (solutions[j].size() < (clusters[j] + 1)) { - solutions[j].push_back({}); - solutionPoints[j].push_back({}); - solutionPointsIdx[j].push_back({}); + solutions[j].emplace_back(); + solutionPoints[j].emplace_back(); + solutionPointsIdx[j].emplace_back(); } // Save the current Point in it's respective cluster. (Depends if a new // cluster was defined above) @@ -326,9 +327,9 @@ bool SinkClustering::findBestMatching(const unsigned groupSize) // one late). for (unsigned j = (i + 1); j < groupSize; ++j) { if (solutions[j].size() < (clusters[j] + 1)) { - solutions[j].push_back({}); - solutionPoints[j].push_back({}); - solutionPointsIdx[j].push_back({}); + solutions[j].emplace_back(); + solutionPoints[j].emplace_back(); + solutionPointsIdx[j].emplace_back(); } // Thus here we will assign the Points missing from those solutions. const unsigned idx = thetaIndexVector_[i].second; @@ -372,9 +373,9 @@ bool SinkClustering::findBestMatching(const unsigned groupSize) } } if (solutions[j].size() < (clusters[j] + 1)) { - solutions[j].push_back({}); - solutionPoints[j].push_back({}); - solutionPointsIdx[j].push_back({}); + solutions[j].emplace_back(); + solutionPoints[j].emplace_back(); + solutionPointsIdx[j].emplace_back(); } solutionPoints[j][clusters[j]].push_back(p); solutionPointsIdx[j][clusters[j]].push_back(idx); @@ -417,11 +418,12 @@ bool SinkClustering::findBestMatching(const unsigned groupSize) if (logger_->debugCheck(CTS, "clustering", 2)) { size_t solnIndex = 0; for (const std::vector& soln : bestSolution_) { - std::cout << "Solution " << solnIndex << "[" << soln.size() << "]: "; + std::ostringstream s; + s << "Solution " << solnIndex << "[" << soln.size() << "]: "; for (const unsigned i : soln) { - std::cout << i << " "; + s << i << " "; } - std::cout << std::endl; + logger_->debug(CTS, "clustering", "{}", s.str()); ++solnIndex; } } diff --git a/src/cts/src/TechChar.cpp b/src/cts/src/TechChar.cpp index f70ffa2fff..31488ba127 100644 --- a/src/cts/src/TechChar.cpp +++ b/src/cts/src/TechChar.cpp @@ -480,32 +480,34 @@ void TechChar::initCharacterization() float maxBuffCap = 0.0; std::string bufMasterName; std::vector axisSlews, axisLoads; - for (int i = 0; i < masterVector.size(); i++) { + for (const std::string& master_name : masterVector) { float maxCap = 0.0; bool maxCapExist = false; - odb::dbMaster* buf = db_->findMaster(masterVector[i].c_str()); + odb::dbMaster* buf = db_->findMaster(master_name.c_str()); sta::Cell* masterCell = db_network_->dbToSta(buf); sta::LibertyCell* libertyCell = db_network_->libertyCell(masterCell); sta::LibertyPort *input, *output; libertyCell->bufferPorts(input, output); output->capacitanceLimit(sta::MinMax::max(), maxCap, maxCapExist); sta::LibertyLibrary* lib = libertyCell->libertyLibrary(); - if (!maxCapExist) + if (!maxCapExist) { lib->defaultMaxCapacitance(maxCap, maxCapExist); - if (!maxCapExist) + } + if (!maxCapExist) { logger_->error( - CTS, 111, "No max capacitance found for cell {}.", masterVector[i]); + CTS, 111, "No max capacitance found for cell {}.", master_name); + } if (maxCap >= maxBuffCap) { maxBuffCap = maxCap; charBuf_ = buf; - bufMasterName = masterVector[i]; + bufMasterName = master_name; } // collect slews and caps from NLDM table axis from all buffers in list collectSlewsLoadsFromTableAxis( libertyCell, input, output, axisSlews, axisLoads); } - if (bufMasterName == "") { + if (bufMasterName.empty()) { logger_->error( CTS, 113, @@ -573,7 +575,7 @@ void TechChar::initCharacterization() wirelengthsToTest_.push_back(wirelengthInter); } - if (wirelengthsToTest_.size() < 1) { + if (wirelengthsToTest_.empty()) { logger_->error( CTS, 75, @@ -608,16 +610,19 @@ void TechChar::initCharacterization() if (!maxSlewExist) { lib->defaultMaxSlew(maxSlew, maxSlewExist); } - if (!maxSlewExist) + if (!maxSlewExist) { logger_->error( CTS, 107, "No max slew found for cell {}.", bufMasterName); + } output->capacitanceLimit(sta::MinMax::max(), maxCap, maxCapExist); - if (!maxCapExist) + if (!maxCapExist) { lib->defaultMaxCapacitance(maxCap, maxCapExist); - if (!maxCapExist) + } + if (!maxCapExist) { logger_->error( CTS, 108, "No max capacitance found for cell {}.", bufMasterName); + } options_->setMaxCharSlew(maxSlew); options_->setMaxCharCap(maxCap); } @@ -812,13 +817,13 @@ void TechChar::collectSlewsLoadsFromTableAxis(sta::LibertyCell* libCell, } } if (slews) { - for (size_t i = 0; i < slews->size(); ++i) { - axisSlews.push_back((*slews)[i]); + for (const float slew : *slews) { + axisSlews.push_back(slew); } } if (loads) { - for (size_t i = 0; i < loads->size(); ++i) { - axisLoads.push_back((*loads)[i]); + for (const float load : *loads) { + axisLoads.push_back(load); } } } @@ -960,18 +965,19 @@ std::vector TechChar::createPatterns( solutionCounterInt++) { // Creates a bitset that represents the buffer locations. const std::bitset<5> solutionCounter(solutionCounterInt); - unsigned short int wireCounter = 0; + int wireCounter = 0; SolutionData topology; // Creates the starting net. - const std::string netName = "net_" + std::to_string(setupWirelength) + "_" - + solutionCounter.to_string() + "_" - + std::to_string(wireCounter); + const std::string netName = fmt::format("net_{}_{}_{}", + setupWirelength, + solutionCounter.to_string(), + wireCounter); net = odb::dbNet::create(charBlock_, netName.c_str()); odb::dbWire::create(net); net->setSigType(odb::dbSigType::SIGNAL); // Creates the input port. const std::string inPortName - = "in_" + std::to_string(setupWirelength) + solutionCounter.to_string(); + = fmt::format("in_{}{}", setupWirelength, solutionCounter.to_string()); odb::dbBTerm* inPort = odb::dbBTerm::create( net, inPortName.c_str()); // sig type is signal by default inPort->setIoType(odb::dbIoType::INPUT); @@ -993,9 +999,10 @@ std::vector TechChar::createPatterns( // Buffer, need to create the instance and a new net. nodesWithoutBuf++; // Creates a new buffer instance. - const std::string bufName = "buf_" + std::to_string(setupWirelength) - + "_" + solutionCounter.to_string() + "_" - + std::to_string(wireCounter); + const std::string bufName = fmt::format("buf_{}_{}_{}", + setupWirelength, + solutionCounter.to_string(), + wireCounter); // clang-format off debugPrint(logger_, CTS, "tech char", 1, " buffer {} at node:{} " "topo:{}", bufName, nodeIndex, solutionCounterInt); @@ -1011,9 +1018,10 @@ std::vector TechChar::createPatterns( topology.nodesWithoutBufVector.push_back(nodesWithoutBuf); // Creates a new net. wireCounter++; - const std::string netName = "net_" + std::to_string(setupWirelength) - + "_" + solutionCounter.to_string() + "_" - + std::to_string(wireCounter); + const std::string netName = fmt::format("net_{}_{}_{}", + setupWirelength, + solutionCounter.to_string(), + wireCounter); net = odb::dbNet::create(charBlock_, netName.c_str()); odb::dbWire::create(net); bufInstanceOutPin->connect(net); @@ -1034,8 +1042,8 @@ std::vector TechChar::createPatterns( } } // Finishing up the topology with the output port. - const std::string outPortName = "out_" + std::to_string(setupWirelength) - + solutionCounter.to_string(); + const std::string outPortName + = fmt::format("out_{}{}", setupWirelength, solutionCounter.to_string()); odb::dbBTerm* outPort = odb::dbBTerm::create( net, outPortName.c_str()); // sig type is signal by default outPort->setIoType(odb::dbIoType::OUTPUT); @@ -1454,7 +1462,7 @@ std::vector TechChar::characterizationPostProcess() // select only 3 of them. for (auto& keyResults : solutionMap_) { std::vector resultVector = keyResults.second; - for (ResultData selectedResults : resultVector) { + for (const ResultData& selectedResults : resultVector) { selectedSolutions.push_back(selectedResults); } } @@ -1506,8 +1514,8 @@ std::vector TechChar::characterizationPostProcess() if (std::find(masterNames_.begin(), masterNames_.end(), topologyS) == masterNames_.end()) { // Is a number (i.e. a wire segment). - topologyResult.push_back(std::to_string( - std::stod(topologyS) / static_cast(solution.wirelength))); + topologyResult.push_back( + std::to_string(std::stod(topologyS) / solution.wirelength)); } else { topologyResult.push_back(topologyS); } @@ -1559,7 +1567,7 @@ void TechChar::create() } // Setup of the attributes required to run the characterization. initCharacterization(); - long unsigned int topologiesCreated = 0; + int64_t topologiesCreated = 0; for (unsigned setupWirelength : wirelengthsToTest_) { // Creates the topologies for the current wirelength. std::vector topologiesVector @@ -1738,7 +1746,7 @@ unsigned TechChar::getBufferingCombo(size_t numBuffers, size_t numNodes) auto iter = bufferingComboTable_.find(iPair); if (iter != bufferingComboTable_.end()) { if (logger_->debugCheck(CTS, "tech char", 1)) { - tmp << "Monotonic entries (hashed): " << iter->second << std::endl; + tmp << "Monotonic entries (hashed): " << iter->second << '\n'; logger_->report(tmp.str()); } return iter->second; diff --git a/src/cts/src/TritonCTS.cpp b/src/cts/src/TritonCTS.cpp index 7d4bda3bb9..0f8680460f 100644 --- a/src/cts/src/TritonCTS.cpp +++ b/src/cts/src/TritonCTS.cpp @@ -940,7 +940,7 @@ void TritonCTS::populateTritonCTS() // Since a set is unique, only the nets not found by dbSta are added. clockNets.insert(net); } - clockNetsInfo.emplace_back(std::make_pair(clockNets, std::string(""))); + clockNetsInfo.emplace_back(clockNets, ""); } else { std::set allClkNets; staClockNets_ = openSta_->findClkNets(); @@ -955,7 +955,7 @@ void TritonCTS::populateTritonCTS() CTS, 114, "Clock {} overlaps a previous clock.", clkName); } } - clockNetsInfo.emplace_back(std::make_pair(clkNets, clkName)); + clockNetsInfo.emplace_back(clkNets, clkName); allClkNets.insert(clkNets.begin(), clkNets.end()); } }