Skip to content

Commit 9578baa

Browse files
committed
par: clang-tidy ArtNetSpec
Signed-off-by: Matt Liberty <[email protected]>
1 parent bbb1c58 commit 9578baa

File tree

3 files changed

+46
-44
lines changed

3 files changed

+46
-44
lines changed

src/par/include/par/PartitionMgr.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ class PartitionMgr
258258
double* c1,
259259
double* cov_11,
260260
double* sumsq);
261-
bool partitionCluster(std::shared_ptr<TritonPart> triton_part,
261+
bool partitionCluster(const std::shared_ptr<TritonPart>& triton_part,
262262
ModuleMgr& modMgr,
263263
SharedClusterVector& cv);
264264
int getClusterIONum(std::vector<bool>& inside,
265-
std::shared_ptr<Cluster> cluster);
266-
void Partitioning(std::shared_ptr<TritonPart> triton_part,
267-
std::shared_ptr<Cluster> cluster,
265+
const std::shared_ptr<Cluster>& cluster);
266+
void Partitioning(const std::shared_ptr<TritonPart>& triton_part,
267+
const std::shared_ptr<Cluster>& cluster,
268268
SharedClusterVector& resultCV);
269269
void writeFile(
270270
std::unordered_map<std::string, std::pair<int, bool>>& onlyUseMasters,

src/par/src/ArtNetSpec.cpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void PartitionMgr::BuildTimingPath(int& Dmax, int& MDmax)
278278

279279
int ff_max = 0;
280280
int mac_max = 0;
281-
for (auto path : pathDepthMap) {
281+
for (const auto& path : pathDepthMap) {
282282
auto inst = block->findInst((path.first).c_str());
283283
if (inst) {
284284
if (inst->getMaster()->isBlock()) {
@@ -342,9 +342,10 @@ void PartitionMgr::getRents(float& Rratio, float& p, float& q)
342342
}
343343
}
344344

345-
bool PartitionMgr::partitionCluster(std::shared_ptr<TritonPart> triton_part,
346-
ModuleMgr& modMgr,
347-
SharedClusterVector& cv)
345+
bool PartitionMgr::partitionCluster(
346+
const std::shared_ptr<TritonPart>& triton_part,
347+
ModuleMgr& modMgr,
348+
SharedClusterVector& cv)
348349
{
349350
int MIN_GATE_NUM_PER_CLUSTER = 100;
350351
bool flag = true;
@@ -396,11 +397,10 @@ bool PartitionMgr::partitionCluster(std::shared_ptr<TritonPart> triton_part,
396397

397398
if (Tvect.size() > 1) {
398399
double sumSqrtT = 0.0;
399-
for (auto itr = Tvect.begin(); itr != Tvect.end(); ++itr) {
400-
double t = *itr;
400+
for (const double t : Tvect) {
401401
sumSqrtT += pow((t - avgT), 2);
402402
}
403-
stdevT = sqrt(double(sumSqrtT) / count);
403+
stdevT = sqrt(sumSqrtT / count);
404404
}
405405

406406
if (avgInsts >= 1 && avgT >= 1) {
@@ -417,8 +417,8 @@ bool PartitionMgr::partitionCluster(std::shared_ptr<TritonPart> triton_part,
417417
return flag;
418418
}
419419

420-
void PartitionMgr::Partitioning(std::shared_ptr<TritonPart> triton_part,
421-
std::shared_ptr<Cluster> cluster,
420+
void PartitionMgr::Partitioning(const std::shared_ptr<TritonPart>& triton_part,
421+
const std::shared_ptr<Cluster>& cluster,
422422
SharedClusterVector& resultCV)
423423
{
424424
std::vector<odb::dbInst*> insts;
@@ -534,7 +534,7 @@ void PartitionMgr::Partitioning(std::shared_ptr<TritonPart> triton_part,
534534
}
535535

536536
int PartitionMgr::getClusterIONum(std::vector<bool>& inside,
537-
std::shared_ptr<Cluster> cluster)
537+
const std::shared_ptr<Cluster>& cluster)
538538
{
539539
std::vector<odb::dbInst*> cInsts = cluster->getInsts();
540540
std::unordered_set<odb::dbNet*> cNets;
@@ -589,11 +589,12 @@ void PartitionMgr::linCurvFit(ModuleMgr& modMgr,
589589
double* y = new double[n];
590590

591591
auto modules = modMgr.getModules();
592-
std::sort(modules.begin(),
593-
modules.end(),
594-
[](std::shared_ptr<Module> m1, std::shared_ptr<Module> m2) {
595-
return m1->getAvgInsts() < m2->getAvgInsts();
596-
});
592+
std::sort(
593+
modules.begin(),
594+
modules.end(),
595+
[](const std::shared_ptr<Module>& m1, const std::shared_ptr<Module>& m2) {
596+
return m1->getAvgInsts() < m2->getAvgInsts();
597+
});
597598

598599
double b = log(modules[n - 1]->getAvgK());
599600
for (int i = 0; i < n; i++) {
@@ -641,11 +642,10 @@ std::tuple<double, double, double> PartitionMgr::fitRent(double* x,
641642
double newDev = sqrt(sumsq / n);
642643
if (newDev > oldDev) {
643644
break;
644-
} else {
645-
oldDev = newDev;
646-
bestN = n;
647-
bestRent = rentP;
648645
}
646+
oldDev = newDev;
647+
bestN = n;
648+
bestRent = rentP;
649649
}
650650
double Rratio;
651651
if (bestN == totPoints) {
@@ -716,35 +716,35 @@ void PartitionMgr::writeFile(
716716
exit(0);
717717
}
718718

719-
outFile << "LIBRARY" << std::endl;
720-
outFile << "NAME lib" << std::endl;
719+
outFile << "LIBRARY\n";
720+
outFile << "NAME lib\n";
721721

722722
// unordered_map<string, int> --> cellName / isMacro
723723
for (const auto& it : onlyUseMasters) {
724724
if (!it.second.second) {
725-
outFile << "STD_CELL " << it.first << std::endl;
725+
outFile << "STD_CELL " << it.first << '\n';
726726
} else {
727-
outFile << "MACRO_CELL " << it.first << std::endl;
727+
outFile << "MACRO_CELL " << it.first << '\n';
728728
}
729729
}
730-
outFile << std::endl;
730+
outFile << '\n';
731731

732-
outFile << "CIRCUIT" << std::endl;
733-
outFile << "NAME " << top_name << std::endl;
734-
outFile << "LIBRARIES lib" << std::endl;
732+
outFile << "CIRCUIT\n";
733+
outFile << "NAME " << top_name << '\n';
734+
outFile << "LIBRARIES lib" << '\n';
735735
outFile << "DISTRIBUTION ";
736736
for (const auto& it : onlyUseMasters) {
737737
outFile << it.second.first << " ";
738738
}
739-
outFile << std::endl;
740-
outFile << "SIZE " << int(numInsts * Rratio) << std::endl;
741-
outFile << "p " << p << std::endl;
742-
outFile << "q " << q << std::endl;
743-
outFile << "END" << std::endl;
744-
outFile << "SIZE " << numInsts << std::endl;
745-
outFile << "I " << numPIs << std::endl;
746-
outFile << "O " << numPOs << std::endl;
747-
outFile << "END" << std::endl;
739+
outFile << '\n';
740+
outFile << "SIZE " << int(numInsts * Rratio) << '\n';
741+
outFile << "p " << p << '\n';
742+
outFile << "q " << q << '\n';
743+
outFile << "END\n";
744+
outFile << "SIZE " << numInsts << '\n';
745+
outFile << "I " << numPIs << '\n';
746+
outFile << "O " << numPOs << '\n';
747+
outFile << "END\n";
748748
outFile.close();
749749
}
750750

src/par/src/ArtNetSpec.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ struct ModuleMgr
7979
{
8080
std::vector<std::shared_ptr<Module>> modules;
8181

82-
void addModule(std::shared_ptr<Module> module) { modules.push_back(module); }
82+
void addModule(std::shared_ptr<Module> module)
83+
{
84+
modules.push_back(std::move(module));
85+
}
8386

8487
int getNumModules() const { return modules.size(); }
8588

@@ -94,15 +97,14 @@ class Cluster
9497

9598
int getId() const { return id_; }
9699

97-
const std::vector<odb::dbInst*> getInsts() const { return insts_; }
100+
const std::vector<odb::dbInst*>& getInsts() const { return insts_; }
98101

99102
odb::dbInst* getInst(int i)
100103
{
101104
if (i < insts_.size()) {
102105
return insts_[i];
103-
} else {
104-
return nullptr;
105106
}
107+
return nullptr;
106108
}
107109

108110
void addInst(odb::dbInst* inst) { insts_.push_back(inst); }

0 commit comments

Comments
 (0)