Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip known bad vertices in power recovery #5150

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/rsz/src/RecoverPower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ using sta::Edge;
using sta::PathExpanded;
using sta::VertexOutEdgeIterator;

RecoverPower::RecoverPower(Resizer* resizer) : resizer_(resizer)
RecoverPower::RecoverPower(Resizer* resizer)
: resizer_(resizer), bad_vertices_(resizer->graph_)
{
}

Expand Down Expand Up @@ -142,7 +143,7 @@ void RecoverPower::recoverPower(const float recover_power_percent)
//=====================================================================
resizer_->journalBegin();
PathRef end_path = sta_->vertexWorstSlackPath(end, max_);
const bool changed = recoverPower(end_path, end_slack_before);
Vertex* const changed = recoverPower(end_path, end_slack_before);
if (changed) {
resizer_->updateParasitics(true);
sta_->findRequireds();
Expand Down Expand Up @@ -179,6 +180,8 @@ void RecoverPower::recoverPower(const float recover_power_percent)
worst_slack_before,
worst_slack_after);
} else {
// Save the vertex to avoid trying it again.
bad_vertices_.insert(changed);
// Undo the change here.
++failed_move_threshold;
if (failed_move_threshold > failed_move_threshold_limit_) {
Expand Down Expand Up @@ -212,6 +215,7 @@ void RecoverPower::recoverPower(const float recover_power_percent)
}
}
}
bad_vertices_.clear();

resizer_->incrementalParasiticsEnd();
// TODO: Add the appropriate metric here
Expand All @@ -226,7 +230,7 @@ void RecoverPower::recoverPower(const float recover_power_percent)
}

// For testing.
void RecoverPower::recoverPower(const Pin* end_pin)
Vertex* RecoverPower::recoverPower(const Pin* end_pin)
{
init();
resize_count_ = 0;
Expand All @@ -235,21 +239,22 @@ void RecoverPower::recoverPower(const Pin* end_pin)
const Slack slack = sta_->vertexSlack(vertex, max_);
const PathRef path = sta_->vertexWorstSlackPath(vertex, max_);
resizer_->incrementalParasiticsBegin();
recoverPower(path, slack);
Vertex* drvr_vertex = recoverPower(path, slack);
// Leave the parasitices up to date.
resizer_->updateParasitics();
resizer_->incrementalParasiticsEnd();

if (resize_count_ > 0) {
logger_->info(RSZ, 3111, "Resized {} instances.", resize_count_);
}
return drvr_vertex;
}

// This is the main routine for recovering power.
bool RecoverPower::recoverPower(const PathRef& path, const Slack path_slack)
Vertex* RecoverPower::recoverPower(const PathRef& path, const Slack path_slack)
{
PathExpanded expanded(&path, sta_);
bool changed = false;
Vertex* changed = nullptr;

if (expanded.size() > 1) {
const int path_length = expanded.size();
Expand Down Expand Up @@ -295,6 +300,10 @@ bool RecoverPower::recoverPower(const PathRef& path, const Slack path_slack)
for (const auto& [drvr_index, ignored] : load_delays) {
PathRef* drvr_path = expanded.path(drvr_index);
Vertex* drvr_vertex = drvr_path->vertex(sta_);
// If we already tried this vertex and got a worse result, skip it.
if (bad_vertices_.find(drvr_vertex) != bad_vertices_.end()) {
continue;
}
const Pin* drvr_pin = drvr_vertex->pin();
const LibertyPort* drvr_port = network_->libertyPort(drvr_pin);
const LibertyCell* drvr_cell
Expand All @@ -309,7 +318,7 @@ bool RecoverPower::recoverPower(const PathRef& path, const Slack path_slack)
drvr_cell ? drvr_cell->name() : "none",
fanout);
if (downsizeDrvr(drvr_path, drvr_index, &expanded, true, path_slack)) {
changed = true;
changed = drvr_vertex;
break;
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/rsz/src/RecoverPower.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include "db_sta/dbSta.hh"
#include "sta/FuncExpr.hh"
#include "sta/Graph.hh"
#include "sta/MinMax.hh"
#include "sta/StaState.hh"
#include "utl/Logger.h"
Expand Down Expand Up @@ -80,11 +81,11 @@ class RecoverPower : StaState
RecoverPower(Resizer* resizer);
void recoverPower(float recover_power_percent);
// For testing.
void recoverPower(const Pin* end_pin);
Vertex* recoverPower(const Pin* end_pin);

private:
void init();
bool recoverPower(const PathRef& path, Slack path_slack);
Vertex* recoverPower(const PathRef& path, Slack path_slack);
bool meetsSizeCriteria(const LibertyCell* cell,
const LibertyCell* equiv,
bool match_size);
Expand Down Expand Up @@ -130,7 +131,7 @@ class RecoverPower : StaState
// trying
static constexpr int failed_move_threshold_limit_ = 500;

sta::UnorderedMap<LibertyCell*, sta::LibertyPortSet> equiv_pin_map_;
sta::VertexSet bad_vertices_;

static constexpr int decreasing_slack_max_passes_ = 50;
static constexpr int rebuffer_max_fanout_ = 20;
Expand Down
Loading