Skip to content

Commit 3295560

Browse files
authored
Merge pull request #10193 from The-OpenROAD-Project-staging/rmp-tidy-naming
rmp: adjust naming to Google-style (excluding method names)
2 parents 1c67315 + d53b883 commit 3295560

7 files changed

Lines changed: 75 additions & 72 deletions

File tree

src/rmp/include/rmp/Restructure.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ namespace rmp {
4444

4545
enum class Mode
4646
{
47-
AREA_1 = 0,
48-
AREA_2,
49-
AREA_3,
50-
DELAY_1,
51-
DELAY_2,
52-
DELAY_3,
53-
DELAY_4
47+
kArea1 = 0,
48+
kArea2,
49+
kArea3,
50+
kDelay1,
51+
kDelay2,
52+
kDelay3,
53+
kDelay4
5454
};
5555

5656
class Restructure
@@ -165,7 +165,7 @@ class Restructure
165165
std::vector<std::string> lib_file_names_;
166166
std::set<odb::dbInst*> path_insts_;
167167

168-
Mode opt_mode_{Mode::DELAY_1};
168+
Mode opt_mode_{Mode::kDelay1};
169169
bool is_area_mode_{false};
170170
int blif_call_id_{0};
171171
};

src/rmp/src/Restructure.cpp

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ void Restructure::runABC()
192192
"Constants before remap {}",
193193
countConsts(block_));
194194

195-
Blif blif_(
195+
Blif blif(
196196
logger_, open_sta_, locell_, loport_, hicell_, hiport_, ++blif_call_id_);
197-
blif_.setReplaceableInstances(path_insts_);
198-
blif_.writeBlif(input_blif_file_name_.c_str(), !is_area_mode_);
197+
blif.setReplaceableInstances(path_insts_);
198+
blif.writeBlif(input_blif_file_name_.c_str(), !is_area_mode_);
199199
debugPrint(
200200
logger_, RMP, "remap", 1, "Writing blif file {}", input_blif_file_name_);
201201
files_to_remove.emplace_back(input_blif_file_name_);
@@ -206,10 +206,10 @@ void Restructure::runABC()
206206

207207
if (is_area_mode_) {
208208
// Area Mode
209-
modes = {Mode::AREA_1, Mode::AREA_2, Mode::AREA_3};
209+
modes = {Mode::kArea1, Mode::kArea2, Mode::kArea3};
210210
} else {
211211
// Delay Mode
212-
modes = {Mode::DELAY_1, Mode::DELAY_2, Mode::DELAY_3, Mode::DELAY_4};
212+
modes = {Mode::kDelay1, Mode::kDelay2, Mode::kDelay3, Mode::kDelay4};
213213
}
214214

215215
child_proc.resize(modes.size(), 0);
@@ -274,8 +274,7 @@ void Restructure::runABC()
274274
int num_instances = 0;
275275
bool success = readAbcLog(abc_log_name, level_gain, delay);
276276
if (success) {
277-
success
278-
= blif_.inspectBlif(output_blif_file_name_.c_str(), num_instances);
277+
success = blif.inspectBlif(output_blif_file_name_.c_str(), num_instances);
279278
logger_->report(
280279
"Optimized to {} instances in iteration {} with max path depth "
281280
"decrease of {}, delay of {}.",
@@ -293,7 +292,7 @@ void Restructure::runABC()
293292
} else {
294293
// Using only DELAY_4 for delay based gain since other modes not
295294
// showing good gains
296-
if (modes[curr_mode_idx] == Mode::DELAY_4) {
295+
if (modes[curr_mode_idx] == Mode::kDelay4) {
297296
best_delay_gain = delay;
298297
best_blif = output_blif_file_name_;
299298
}
@@ -307,7 +306,7 @@ void Restructure::runABC()
307306
|| best_delay_gain < std::numeric_limits<float>::max()) {
308307
// read back netlist
309308
debugPrint(logger_, RMP, "remap", 1, "Reading blif file {}.", best_blif);
310-
blif_.readBlif(best_blif.c_str(), block_);
309+
blif.readBlif(best_blif.c_str(), block_);
311310
debugPrint(logger_,
312311
utl::RMP,
313312
"remap",
@@ -373,21 +372,21 @@ void Restructure::getEndPoints(sta::PinSet& ends,
373372
if (!errors.empty() && errors[0]->size() > 1) {
374373
sta::CheckError* error = errors[0];
375374
bool first = true;
376-
for (auto pinName : *error) {
377-
debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pinName);
378-
if (!first && open_sta_->getDbNetwork()->findPin(pinName.c_str())) {
379-
ends.insert(open_sta_->getDbNetwork()->findPin(pinName.c_str()));
375+
for (auto pin_name : *error) {
376+
debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pin_name);
377+
if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) {
378+
ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str()));
380379
}
381380
first = false;
382381
}
383382
}
384383
if (errors.size() > 1 && errors[1]->size() > 1) {
385384
sta::CheckError* error = errors[1];
386385
bool first = true;
387-
for (auto pinName : *error) {
388-
debugPrint(logger_, RMP, "remap", 1, "Unclocked pin: {}", pinName);
389-
if (!first && open_sta_->getDbNetwork()->findPin(pinName.c_str())) {
390-
ends.insert(open_sta_->getDbNetwork()->findPin(pinName.c_str()));
386+
for (auto pin_name : *error) {
387+
debugPrint(logger_, RMP, "remap", 1, "Unclocked pin: {}", pin_name);
388+
if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) {
389+
ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str()));
391390
}
392391
first = false;
393392
}
@@ -439,7 +438,7 @@ void Restructure::removeConstCells()
439438

440439
open_sta_->clearLogicConstants();
441440
open_sta_->findLogicConstants();
442-
std::set<odb::dbInst*> constInsts;
441+
std::set<odb::dbInst*> const_insts;
443442
int const_cnt = 1;
444443
for (auto inst : block_->getInsts()) {
445444
int outputs = 0;
@@ -462,16 +461,16 @@ void Restructure::removeConstCells()
462461
}
463462
outputs++;
464463
auto pin = open_sta_->getDbNetwork()->dbToSta(iterm);
465-
sta::LogicValue pinVal
464+
sta::LogicValue pin_val
466465
= open_sta_->simLogicValue(pin, open_sta_->cmdMode());
467-
if (pinVal == sta::LogicValue::one || pinVal == sta::LogicValue::zero) {
466+
if (pin_val == sta::LogicValue::one || pin_val == sta::LogicValue::zero) {
468467
odb::dbNet* net = iterm->getNet();
469468
if (net) {
470-
odb::dbMaster* const_master = (pinVal == sta::LogicValue::one)
469+
odb::dbMaster* const_master = (pin_val == sta::LogicValue::one)
471470
? hicell_master
472471
: locell_master;
473472
odb::dbMTerm* const_port
474-
= (pinVal == sta::LogicValue::one) ? hiterm : loterm;
473+
= (pin_val == sta::LogicValue::one) ? hiterm : loterm;
475474
std::string inst_name = "rmp_const_" + std::to_string(const_cnt);
476475
debugPrint(logger_,
477476
RMP,
@@ -495,19 +494,19 @@ void Restructure::removeConstCells()
495494
}
496495
}
497496
if (outputs > 0 && outputs == const_outputs) {
498-
constInsts.insert(inst);
497+
const_insts.insert(inst);
499498
}
500499
}
501500
open_sta_->clearLogicConstants();
502501

503502
debugPrint(
504-
logger_, RMP, "remap", 2, "Removing {} instances...", constInsts.size());
503+
logger_, RMP, "remap", 2, "Removing {} instances...", const_insts.size());
505504

506-
for (auto inst : constInsts) {
505+
for (auto inst : const_insts) {
507506
removeConstCell(inst);
508507
}
509508
logger_->report("Removed {} instances with constant outputs.",
510-
constInsts.size());
509+
const_insts.size());
511510
}
512511

513512
void Restructure::removeConstCell(odb::dbInst* inst)
@@ -572,19 +571,19 @@ void Restructure::writeOptCommands(std::ofstream& script)
572571
script << choice << '\n';
573572
script << choice2 << '\n';
574573

575-
if (opt_mode_ == Mode::AREA_3) {
574+
if (opt_mode_ == Mode::kArea3) {
576575
script << "choice2\n"; // << "scleanup" << std::endl;
577576
} else {
578577
script << "resyn2\n"; // << "scleanup" << std::endl;
579578
}
580579

581580
switch (opt_mode_) {
582-
case Mode::DELAY_1: {
581+
case Mode::kDelay1: {
583582
script << "map -D 0.01 -A 0.9 -B 0.2 -M 0 -p\n";
584583
script << "buffer -p -c\n";
585584
break;
586585
}
587-
case Mode::DELAY_2: {
586+
case Mode::kDelay2: {
588587
script << "choice\n";
589588
script << "map -D 0.01 -A 0.9 -B 0.2 -M 0 -p\n";
590589
script << "choice\n";
@@ -593,7 +592,7 @@ void Restructure::writeOptCommands(std::ofstream& script)
593592
<< "topo\n";
594593
break;
595594
}
596-
case Mode::DELAY_3: {
595+
case Mode::kDelay3: {
597596
script << "choice2\n";
598597
script << "map -D 0.01 -A 0.9 -B 0.2 -M 0 -p\n";
599598
script << "choice2\n";
@@ -602,23 +601,23 @@ void Restructure::writeOptCommands(std::ofstream& script)
602601
<< "topo\n";
603602
break;
604603
}
605-
case Mode::DELAY_4: {
604+
case Mode::kDelay4: {
606605
script << "choice2\n";
607606
script << "amap -F 20 -A 20 -C 5000 -Q 0.1 -m\n";
608607
script << "choice2\n";
609608
script << "map -D 0.01 -A 0.9 -B 0.2 -M 0 -p\n";
610609
script << "buffer -p -c\n";
611610
break;
612611
}
613-
case Mode::AREA_2:
614-
case Mode::AREA_3: {
612+
case Mode::kArea2:
613+
case Mode::kArea3: {
615614
script << "choice2\n";
616615
script << "amap -m -Q 0.1 -F 20 -A 20 -C 5000\n";
617616
script << "choice2\n";
618617
script << "amap -m -Q 0.1 -F 20 -A 20 -C 5000\n";
619618
break;
620619
}
621-
case Mode::AREA_1:
620+
case Mode::kArea1:
622621
default: {
623622
script << "choice2\n";
624623
script << "amap -m -Q 0.1 -F 20 -A 20 -C 5000\n";
@@ -633,27 +632,27 @@ void Restructure::setMode(const char* mode_name)
633632

634633
if (!strcmp(mode_name, "timing")) {
635634
is_area_mode_ = false;
636-
opt_mode_ = Mode::DELAY_1;
635+
opt_mode_ = Mode::kDelay1;
637636
} else if (!strcmp(mode_name, "area")) {
638-
opt_mode_ = Mode::AREA_1;
637+
opt_mode_ = Mode::kArea1;
639638
} else {
640639
logger_->warn(RMP, 10, "Mode {} not recognized.", mode_name);
641640
}
642641
}
643642

644-
void Restructure::setTieHiPort(sta::LibertyPort* tieHiPort)
643+
void Restructure::setTieHiPort(sta::LibertyPort* tie_hi_port)
645644
{
646-
if (tieHiPort) {
647-
hicell_ = tieHiPort->libertyCell()->name();
648-
hiport_ = tieHiPort->name();
645+
if (tie_hi_port) {
646+
hicell_ = tie_hi_port->libertyCell()->name();
647+
hiport_ = tie_hi_port->name();
649648
}
650649
}
651650

652-
void Restructure::setTieLoPort(sta::LibertyPort* tieLoPort)
651+
void Restructure::setTieLoPort(sta::LibertyPort* tie_lo_port)
653652
{
654-
if (tieLoPort) {
655-
locell_ = tieLoPort->libertyCell()->name();
656-
loport_ = tieLoPort->name();
653+
if (tie_lo_port) {
654+
locell_ = tie_lo_port->libertyCell()->name();
655+
loport_ = tie_lo_port->name();
657656
}
658657
}
659658

src/rmp/src/delay_optimization_strategy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "utl/deleter.h"
2121

2222
namespace abc {
23+
// NOLINTBEGIN(readability-identifier-naming)
2324
extern Abc_Ntk_t* Abc_NtkMap(Abc_Ntk_t* pNtk,
2425
Mio_Library_t* userLib,
2526
double DelayTarget,
@@ -37,6 +38,7 @@ extern Abc_Ntk_t* Abc_NtkMap(Abc_Ntk_t* pNtk,
3738
int fVerbose);
3839
extern void Abc_FrameSetLibGen(void* pLib);
3940
extern void Abc_FrameSetDrivingCell(char* pName);
41+
// NOLINTEND(readability-identifier-naming)
4042
} // namespace abc
4143

4244
namespace rmp {

src/rmp/src/genetic_strategy.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ std::vector<GiaOp> GeneticStrategy::RunStrategy(
126126
// Selection
127127
std::ranges::stable_sort(
128128
population, std::ranges::greater{}, &SolutionSlack::WorstSlack);
129-
std::vector<SolutionSlack> newPopulation;
130-
newPopulation.reserve(population_size_);
129+
std::vector<SolutionSlack> new_population;
130+
new_population.reserve(population_size_);
131131
for (int j = 0; j < population_size_; j++) {
132132
std::vector<size_t> tournament(tournament_size_);
133133
std::generate_n(tournament.begin(), tournament_size_, [&]() {
@@ -141,17 +141,17 @@ std::vector<GiaOp> GeneticStrategy::RunStrategy(
141141
static_cast<double>(tournament_probability_));
142142
});
143143
if (winner != tournament.end()) {
144-
newPopulation.emplace_back(population[*winner]);
144+
new_population.emplace_back(population[*winner]);
145145
}
146146
}
147-
removeDuplicates(newPopulation, logger);
147+
removeDuplicates(new_population, logger);
148148

149149
// No winners from tournament, use first candidate
150-
if (newPopulation.empty()) {
151-
newPopulation.emplace_back(population.front());
150+
if (new_population.empty()) {
151+
new_population.emplace_back(population.front());
152152
}
153153

154-
population = std::move(newPopulation);
154+
population = std::move(new_population);
155155

156156
for (const auto& candidate : population) {
157157
debugPrint(logger, RMP, "genetic", 1, candidate.toString());

src/rmp/src/gia.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "utl/unique_name.h"
4444

4545
namespace abc {
46+
// NOLINTBEGIN(readability-identifier-naming)
4647
extern Abc_Ntk_t* Abc_NtkFromAigPhase(Aig_Man_t* pMan);
4748
extern Abc_Ntk_t* Abc_NtkFromCellMappedGia(Gia_Man_t* p, int fUseBuffs);
4849
extern Abc_Ntk_t* Abc_NtkFromDarChoices(Abc_Ntk_t* pNtkOld, Aig_Man_t* pMan);
@@ -79,6 +80,7 @@ extern Vec_Ptr_t* Abc_NtkCollectCiNames(Abc_Ntk_t* pNtk);
7980
extern Vec_Ptr_t* Abc_NtkCollectCoNames(Abc_Ntk_t* pNtk);
8081
extern void Abc_NtkRedirectCiCo(Abc_Ntk_t* pNtk);
8182
extern void Abc_FrameSetLibGen(void* pLib);
83+
// NOLINTEND(readability-identifier-naming)
8284
} // namespace abc
8385

8486
namespace rmp {

src/rmp/src/slack_tuning_strategy.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ std::string SolutionSlack::toString() const
3939
return "[]";
4040
}
4141

42-
std::ostringstream resStream;
43-
resStream << '[' << std::to_string(solution_.front().id);
42+
std::ostringstream res_stream;
43+
res_stream << '[' << std::to_string(solution_.front().id);
4444
for (int i = 1; i < solution_.size(); i++) {
45-
resStream << ", " << std::to_string(solution_[i].id);
45+
res_stream << ", " << std::to_string(solution_[i].id);
4646
}
47-
resStream << "], worst slack: ";
47+
res_stream << "], worst slack: ";
4848

4949
if (worst_slack_) {
50-
resStream << *worst_slack_;
50+
res_stream << *worst_slack_;
5151
} else {
52-
resStream << "not computed";
52+
res_stream << "not computed";
5353
}
54-
return resStream.str();
54+
return res_stream.str();
5555
}
5656

5757
SolutionSlack::ResultOps SolutionSlack::RandomNeighbor(

0 commit comments

Comments
 (0)