Skip to content

Commit 94f0149

Browse files
committed
rsz: Number of repairs based on path slack, fallback to 1
Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
1 parent 852f18b commit 94f0149

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

src/rsz/src/RepairSetup.cc

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ bool RepairSetup::repairSetup(const float setup_slack_margin,
175175
}
176176
float fix_rate_threshold = inc_fix_rate_threshold_;
177177
for (const auto& end_original_slack : violating_ends) {
178+
max_repairs_per_iter_ = 10;
178179
Vertex* end = end_original_slack.first;
179180
Slack end_slack = sta_->vertexSlack(end, max_);
180181
Slack worst_slack;
@@ -325,6 +326,7 @@ bool RepairSetup::repairSetup(const float setup_slack_margin,
325326
// Progress, Save checkpoint so we can back up to here.
326327
resizer_->journalBegin();
327328
} else {
329+
max_repairs_per_iter_ = 1;
328330
// Allow slack to increase to get out of local minima.
329331
// Do not update prev_end_slack so it saves the high water mark.
330332
decreasing_slack_passes++;
@@ -495,7 +497,7 @@ bool RepairSetup::repairPath(PathRef& path,
495497
const float setup_slack_margin)
496498
{
497499
PathExpanded expanded(&path, sta_);
498-
bool changed = false;
500+
int changed = 0;
499501

500502
if (expanded.size() > 1) {
501503
const int path_length = expanded.size();
@@ -537,7 +539,19 @@ bool RepairSetup::repairPath(PathRef& path,
537539
|| (pair1.second == pair2.second && pair1.first > pair2.first);
538540
});
539541
// Attack gates with largest load delays first.
542+
int repairs_per_iter = std::round(std::max(-path_slack * 10e9f, 1.0f));
543+
repairs_per_iter = std::min(repairs_per_iter, max_repairs_per_iter_);
544+
debugPrint(logger_,
545+
RSZ,
546+
"repair_setup",
547+
3,
548+
"Path slack: {}, repairs: {}",
549+
delayAsString(path_slack, sta_, 3),
550+
repairs_per_iter);
540551
for (const auto& [drvr_index, ignored] : load_delays) {
552+
if (changed >= repairs_per_iter) {
553+
break;
554+
}
541555
const PathRef* drvr_path = expanded.path(drvr_index);
542556
Vertex* drvr_vertex = drvr_path->vertex(sta_);
543557
const Pin* drvr_pin = drvr_vertex->pin();
@@ -561,24 +575,21 @@ bool RepairSetup::repairPath(PathRef& path,
561575
drvr_index,
562576
&expanded,
563577
setup_slack_margin)) {
564-
Pin* drvr_pin = drvr_path->pin(this);
565-
Instance* drvr = network_->instance(drvr_pin);
566-
buf_to_remove_.push_back(drvr);
567-
changed = true;
568-
break;
578+
changed++;
579+
continue;
569580
}
570581
}
571582

572583
if (upsizeDrvr(drvr_path, drvr_index, &expanded)) {
573-
changed = true;
574-
break;
584+
changed++;
585+
continue;
575586
}
576587

577588
// Pin swapping
578589
if (!skip_pin_swap) {
579590
if (swapPins(drvr_path, drvr_index, &expanded)) {
580-
changed = true;
581-
break;
591+
changed++;
592+
continue;
582593
}
583594
}
584595

@@ -600,8 +611,8 @@ bool RepairSetup::repairPath(PathRef& path,
600611
network_->pathName(drvr_pin),
601612
rebuffer_count);
602613
inserted_buffer_count_ += rebuffer_count;
603-
changed = true;
604-
break;
614+
changed++;
615+
continue;
605616
}
606617
}
607618

@@ -612,8 +623,8 @@ bool RepairSetup::repairPath(PathRef& path,
612623
db_network_->instance(drvr_pin))
613624
== resizer_->inserted_buffer_set_.end()
614625
&& cloneDriver(drvr_path, drvr_index, path_slack, &expanded)) {
615-
changed = true;
616-
break;
626+
changed++;
627+
continue;
617628
}
618629

619630
if (!skip_buffering) {
@@ -623,8 +634,8 @@ bool RepairSetup::repairPath(PathRef& path,
623634
const int init_buffer_count = inserted_buffer_count_;
624635
splitLoads(drvr_path, drvr_index, path_slack, &expanded);
625636
split_load_buffer_count_ = inserted_buffer_count_ - init_buffer_count;
626-
changed = true;
627-
break;
637+
changed++;
638+
continue;
628639
}
629640
}
630641
}
@@ -633,7 +644,7 @@ bool RepairSetup::repairPath(PathRef& path,
633644
}
634645
buf_to_remove_.clear();
635646
}
636-
return changed;
647+
return changed > 0;
637648
}
638649

639650
void RepairSetup::debugCheckMultipleBuffers(PathRef& path,
@@ -866,6 +877,7 @@ bool RepairSetup::removeDrvr(const PathRef* drvr_path,
866877
}
867878

868879
if (resizer_->canRemoveBuffer(drvr, /* honorDontTouch */ true)) {
880+
buf_to_remove_.push_back(drvr);
869881
removed_buffer_count_++;
870882
return true;
871883
}
@@ -1923,6 +1935,7 @@ void RepairSetup::repairSetupLastGasp(const OptoParams& params, int& num_viols)
19231935
float fix_rate_threshold = inc_fix_rate_threshold_;
19241936

19251937
for (const auto& end_original_slack : violating_ends) {
1938+
max_repairs_per_iter_ = 10;
19261939
Vertex* end = end_original_slack.first;
19271940
Slack end_slack = sta_->vertexSlack(end, max_);
19281941
Slack worst_slack;
@@ -2007,6 +2020,7 @@ void RepairSetup::repairSetupLastGasp(const OptoParams& params, int& num_viols)
20072020
resizer_->journalEnd();
20082021
resizer_->journalBegin();
20092022
} else {
2023+
max_repairs_per_iter_ = 1;
20102024
resizer_->journalRestore(resize_count_,
20112025
inserted_buffer_count_,
20122026
cloned_gate_count_,

src/rsz/src/RepairSetup.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ class RepairSetup : public sta::dbStaState
242242
const Corner* corner_ = nullptr;
243243
LibertyPort* drvr_port_ = nullptr;
244244

245+
int max_repairs_per_iter_ = 1;
245246
int resize_count_ = 0;
246247
int inserted_buffer_count_ = 0;
247248
int split_load_buffer_count_ = 0;

0 commit comments

Comments
 (0)