From e8d452c1e1fc2035ab18f011f4c3fd7db0ab8ced Mon Sep 17 00:00:00 2001 From: Krzysztof Bieganski Date: Thu, 7 Nov 2024 11:46:40 +0100 Subject: [PATCH] rsz: Number of repairs based on path slack, fallback to 1 Signed-off-by: Krzysztof Bieganski --- src/rsz/src/RepairSetup.cc | 48 ++++++++++++++++++++++++-------------- src/rsz/src/RepairSetup.hh | 1 + 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/rsz/src/RepairSetup.cc b/src/rsz/src/RepairSetup.cc index 8de7b5a0b00..752e24d6c67 100644 --- a/src/rsz/src/RepairSetup.cc +++ b/src/rsz/src/RepairSetup.cc @@ -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; @@ -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++; @@ -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(); @@ -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(); @@ -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; } } @@ -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; } } @@ -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) { @@ -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; } } } @@ -633,7 +644,7 @@ bool RepairSetup::repairPath(PathRef& path, } buf_to_remove_.clear(); } - return changed; + return changed > 0; } void RepairSetup::debugCheckMultipleBuffers(PathRef& path, @@ -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; } @@ -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; @@ -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_, diff --git a/src/rsz/src/RepairSetup.hh b/src/rsz/src/RepairSetup.hh index 9c627bcd16d..a3167eba9f7 100644 --- a/src/rsz/src/RepairSetup.hh +++ b/src/rsz/src/RepairSetup.hh @@ -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;