Skip to content

Commit

Permalink
rsz: Number of repairs based on path slack, fallback to 1
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Bieganski <[email protected]>
  • Loading branch information
kbieganski committed Dec 4, 2024
1 parent 9a3bac1 commit e8d452c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
48 changes: 31 additions & 17 deletions src/rsz/src/RepairSetup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ bool RepairSetup::repairSetup(const float setup_slack_margin,
}
float fix_rate_threshold = inc_fix_rate_threshold_;
for (const auto& end_original_slack : violating_ends) {
max_repairs_per_iter_ = 10;
Vertex* end = end_original_slack.first;
Slack end_slack = sta_->vertexSlack(end, max_);
Slack worst_slack;
Expand Down Expand Up @@ -325,6 +326,7 @@ bool RepairSetup::repairSetup(const float setup_slack_margin,
// Progress, Save checkpoint so we can back up to here.
resizer_->journalBegin();
} else {
max_repairs_per_iter_ = 1;
// Allow slack to increase to get out of local minima.
// Do not update prev_end_slack so it saves the high water mark.
decreasing_slack_passes++;
Expand Down Expand Up @@ -495,7 +497,7 @@ bool RepairSetup::repairPath(PathRef& path,
const float setup_slack_margin)
{
PathExpanded expanded(&path, sta_);
bool changed = false;
int changed = 0;

if (expanded.size() > 1) {
const int path_length = expanded.size();
Expand Down Expand Up @@ -537,7 +539,19 @@ bool RepairSetup::repairPath(PathRef& path,
|| (pair1.second == pair2.second && pair1.first > pair2.first);
});
// Attack gates with largest load delays first.
int repairs_per_iter = std::round(std::max(-path_slack * 10e9f, 1.0f));
repairs_per_iter = std::min(repairs_per_iter, max_repairs_per_iter_);
debugPrint(logger_,
RSZ,
"repair_setup",
3,
"Path slack: {}, repairs: {}",
delayAsString(path_slack, sta_, 3),
repairs_per_iter);
for (const auto& [drvr_index, ignored] : load_delays) {
if (changed >= repairs_per_iter) {
break;
}
const PathRef* drvr_path = expanded.path(drvr_index);
Vertex* drvr_vertex = drvr_path->vertex(sta_);
const Pin* drvr_pin = drvr_vertex->pin();
Expand All @@ -561,24 +575,21 @@ bool RepairSetup::repairPath(PathRef& path,
drvr_index,
&expanded,
setup_slack_margin)) {
Pin* drvr_pin = drvr_path->pin(this);
Instance* drvr = network_->instance(drvr_pin);
buf_to_remove_.push_back(drvr);
changed = true;
break;
changed++;
continue;
}
}

if (upsizeDrvr(drvr_path, drvr_index, &expanded)) {
changed = true;
break;
changed++;
continue;
}

// Pin swapping
if (!skip_pin_swap) {
if (swapPins(drvr_path, drvr_index, &expanded)) {
changed = true;
break;
changed++;
continue;
}
}

Expand All @@ -600,8 +611,8 @@ bool RepairSetup::repairPath(PathRef& path,
network_->pathName(drvr_pin),
rebuffer_count);
inserted_buffer_count_ += rebuffer_count;
changed = true;
break;
changed++;
continue;
}
}

Expand All @@ -612,8 +623,8 @@ bool RepairSetup::repairPath(PathRef& path,
db_network_->instance(drvr_pin))
== resizer_->inserted_buffer_set_.end()
&& cloneDriver(drvr_path, drvr_index, path_slack, &expanded)) {
changed = true;
break;
changed++;
continue;
}

if (!skip_buffering) {
Expand All @@ -623,8 +634,8 @@ bool RepairSetup::repairPath(PathRef& path,
const int init_buffer_count = inserted_buffer_count_;
splitLoads(drvr_path, drvr_index, path_slack, &expanded);
split_load_buffer_count_ = inserted_buffer_count_ - init_buffer_count;
changed = true;
break;
changed++;
continue;
}
}
}
Expand All @@ -633,7 +644,7 @@ bool RepairSetup::repairPath(PathRef& path,
}
buf_to_remove_.clear();
}
return changed;
return changed > 0;
}

void RepairSetup::debugCheckMultipleBuffers(PathRef& path,
Expand Down Expand Up @@ -866,6 +877,7 @@ bool RepairSetup::removeDrvr(const PathRef* drvr_path,
}

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

for (const auto& end_original_slack : violating_ends) {
max_repairs_per_iter_ = 10;
Vertex* end = end_original_slack.first;
Slack end_slack = sta_->vertexSlack(end, max_);
Slack worst_slack;
Expand Down Expand Up @@ -2007,6 +2020,7 @@ void RepairSetup::repairSetupLastGasp(const OptoParams& params, int& num_viols)
resizer_->journalEnd();
resizer_->journalBegin();
} else {
max_repairs_per_iter_ = 1;
resizer_->journalRestore(resize_count_,
inserted_buffer_count_,
cloned_gate_count_,
Expand Down
1 change: 1 addition & 0 deletions src/rsz/src/RepairSetup.hh
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class RepairSetup : public sta::dbStaState
const Corner* corner_ = nullptr;
LibertyPort* drvr_port_ = nullptr;

int max_repairs_per_iter_ = 1;
int resize_count_ = 0;
int inserted_buffer_count_ = 0;
int split_load_buffer_count_ = 0;
Expand Down

0 comments on commit e8d452c

Please sign in to comment.