Skip to content
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
2 changes: 1 addition & 1 deletion src/stt/include/stt/SteinerTreeBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SteinerTreeBuilder
private:
int computeHPWL(odb::dbNet* net);

static constexpr int flute_accuracy = 3;
static constexpr int kFluteAccuracy = 3;
float alpha_;
std::map<const odb::dbNet*, float> net_alpha_map_;
std::pair<int, float> min_fanout_alpha_;
Expand Down
10 changes: 5 additions & 5 deletions src/stt/src/LinesRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace stt {

LinesRenderer* LinesRenderer::lines_renderer = nullptr;
LinesRenderer* LinesRenderer::lines_renderer_ = nullptr;

void LinesRenderer::highlight(const LineSegments& lines,
const gui::Painter::Color& color)
Expand All @@ -30,9 +30,9 @@ void LinesRenderer::drawObjects(gui::Painter& painter)
void highlightSteinerTree(const Tree& tree, gui::Gui* gui)
{
if (gui::Gui::enabled()) {
if (LinesRenderer::lines_renderer == nullptr) {
LinesRenderer::lines_renderer = new LinesRenderer();
gui->registerRenderer(LinesRenderer::lines_renderer);
if (LinesRenderer::lines_renderer_ == nullptr) {
LinesRenderer::lines_renderer_ = new LinesRenderer();
gui->registerRenderer(LinesRenderer::lines_renderer_);
}
LinesRenderer::LineSegments lines;
for (int i = 0; i < tree.branchCount(); i++) {
Expand All @@ -44,7 +44,7 @@ void highlightSteinerTree(const Tree& tree, gui::Gui* gui)
const int y2 = neighbor.y;
lines.emplace_back(odb::Point(x1, y1), odb::Point(x2, y2));
}
LinesRenderer::lines_renderer->highlight(lines, gui::Painter::kRed);
LinesRenderer::lines_renderer_->highlight(lines, gui::Painter::kRed);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/stt/src/LinesRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LinesRenderer : public gui::Renderer
void highlight(const LineSegments& lines, const gui::Painter::Color& color);
void drawObjects(gui::Painter& /* painter */) override;
// singleton for debug functions
static LinesRenderer* lines_renderer;
static LinesRenderer* lines_renderer_;

private:
LineSegments lines_;
Expand Down
2 changes: 1 addition & 1 deletion src/stt/src/SteinerTreeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Tree SteinerTreeBuilder::makeSteinerTree(const std::vector<int>& x,
}
// Fall back to flute if PD fails.
}
return flute_->flute(x, y, flute_accuracy);
return flute_->flute(x, y, kFluteAccuracy);
}

Tree SteinerTreeBuilder::makeSteinerTree(const std::vector<int>& x,
Expand Down
50 changes: 25 additions & 25 deletions src/stt/src/flt/flute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ static const char* readDecimalInt(const char* s, int& value)
if (negative || *s == '+') {
++s;
}
constexpr int zero_code = int('0');
constexpr int kZeroCode = int('0');
while (*s >= '0' && *s <= '9') {
value = 10 * value + (int(*s) - zero_code);
value = 10 * value + (int(*s) - kZeroCode);
++s;
}
if (negative) {
Expand Down Expand Up @@ -445,15 +445,15 @@ int Flute::flutes_wl_medium_degree(int d,
const int ub = d - 1 - lb;

// Compute scores
constexpr double AAWL = 0.6;
constexpr double BBWL = 0.3;
const float CCWL = 7.4 / ((d + 10.) * (d - 3.));
const float DDWL = 4.8 / (d - 1);
constexpr double kAawl = 0.6;
constexpr double kBbwl = 0.3;
const float ccwl = 7.4 / ((d + 10.) * (d - 3.));
const float ddwl = 4.8 / (d - 1);
Comment on lines +448 to +451

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve consistency with flutes_medium_degree and better adhere to the Google C++ Style Guide, consider using kAa, kBb, cc, and dd instead of the wl-suffixed names. This also avoids the lack of underscores in ccwl and ddwl (which should be cc_wl and dd_wl if the suffix is kept) and ensures tunable parameters are defined as named constants.

Suggested change
constexpr double kAawl = 0.6;
constexpr double kBbwl = 0.3;
const float ccwl = 7.4 / ((d + 10.) * (d - 3.));
const float ddwl = 4.8 / (d - 1);
constexpr double kAa = 0.6;
constexpr double kBb = 0.3;
const float cc = 7.4 / ((d + 10.) * (d - 3.));
const float dd = 4.8 / (d - 1);
References
  1. Variables should use snake_case and constants should use kPascalCase. Consistency across similar functions is also a key maintainability principle. (link)
  2. Define tunable parameters as named constants instead of using hardcoded magic numbers.


// Compute penalty[]
std::vector<float> penalty(degree);
const float dx = CCWL * (xs[d - 2] - xs[1]);
const float dy = CCWL * (ys[d - 2] - ys[1]);
const float dx = ccwl * (xs[d - 2] - xs[1]);
const float dy = ccwl * (ys[d - 2] - ys[1]);
Comment on lines +455 to +456

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Update usages of ccwl to cc for consistency.

Suggested change
const float dx = ccwl * (xs[d - 2] - xs[1]);
const float dy = ccwl * (ys[d - 2] - ys[1]);
const float dx = cc * (xs[d - 2] - xs[1]);
const float dy = cc * (ys[d - 2] - ys[1]);

float pnlty = 0;
for (int r = d / 2; r >= 0; r--, pnlty += dx) {
penalty[r] = pnlty;
Expand Down Expand Up @@ -529,19 +529,19 @@ int Flute::flutes_wl_medium_degree(int d,
for (int r = lb; r <= ub; r++) {
if (si[r] == 0 || si[r] == d - 1) {
score[nbp] = (xs[r + 1] - xs[r - 1]) - penalty[r]
- AAWL * (ys[d - 2] - ys[1]) - DDWL * disty[r];
- kAawl * (ys[d - 2] - ys[1]) - ddwl * disty[r];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Update usages of kAawl and ddwl to kAa and dd for consistency.

Suggested change
- kAawl * (ys[d - 2] - ys[1]) - ddwl * disty[r];
- kAa * (ys[d - 2] - ys[1]) - dd * disty[r];

} else {
score[nbp] = (xs[r + 1] - xs[r - 1]) - penalty[r]
- BBWL * (ys[si[r] + 1] - ys[si[r] - 1]) - DDWL * disty[r];
- kBbwl * (ys[si[r] + 1] - ys[si[r] - 1]) - ddwl * disty[r];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Update usages of kBbwl and ddwl to kBb and dd for consistency.

Suggested change
- kBbwl * (ys[si[r] + 1] - ys[si[r] - 1]) - ddwl * disty[r];
- kBb * (ys[si[r] + 1] - ys[si[r] - 1]) - dd * disty[r];

}
nbp++;

if (s[r] == 0 || s[r] == d - 1) {
score[nbp] = (ys[r + 1] - ys[r - 1]) - penalty[s[r]]
- AAWL * (xs[d - 2] - xs[1]) - DDWL * distx[r];
- kAawl * (xs[d - 2] - xs[1]) - ddwl * distx[r];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Update usages of kAawl and ddwl to kAa and dd for consistency.

Suggested change
- kAawl * (xs[d - 2] - xs[1]) - ddwl * distx[r];
- kAa * (xs[d - 2] - xs[1]) - dd * distx[r];

} else {
score[nbp] = (ys[r + 1] - ys[r - 1]) - penalty[s[r]]
- BBWL * (xs[s[r] + 1] - xs[s[r] - 1]) - DDWL * distx[r];
- kBbwl * (xs[s[r] + 1] - xs[s[r] - 1]) - ddwl * distx[r];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Update usages of kBbwl and ddwl to kBb and dd for consistency.

Suggested change
- kBbwl * (xs[s[r] + 1] - xs[s[r] - 1]) - ddwl * distx[r];
- kBb * (xs[s[r] + 1] - xs[s[r] - 1]) - dd * distx[r];

}
nbp++;
}
Expand Down Expand Up @@ -991,15 +991,15 @@ Tree Flute::flutes_medium_degree(const int d,
const int ub = d - 1 - lb;

// Compute scores
constexpr double AA = 0.6; // 2.0*BB
constexpr double BB = 0.3;
constexpr double kAa = 0.6; // 2.0*BB
constexpr double kBb = 0.3;

const float CC = 7.4 / ((d + 10.) * (d - 3.));
const float DD = 4.8 / (d - 1);
const float cc = 7.4 / ((d + 10.) * (d - 3.));
const float dd = 4.8 / (d - 1);

// Compute penalty[]
const float dx = CC * (xs[d - 2] - xs[1]);
const float dy = CC * (ys[d - 2] - ys[1]);
const float dx = cc * (xs[d - 2] - xs[1]);
const float dy = cc * (ys[d - 2] - ys[1]);
float pnlty = 0;
for (int r = d / 2; r >= 2; r--, pnlty += dx) {
penalty[r] = pnlty, penalty[d - 1 - r] = pnlty;
Expand Down Expand Up @@ -1057,26 +1057,26 @@ Tree Flute::flutes_medium_degree(const int d,
int nbp = 0;
for (int r = lb; r <= ub; r++) {
if (si[r] <= 1) {
score[nbp] = (xs[r + 1] - xs[r - 1]) - penalty[r] - AA * (ys[2] - ys[1])
- DD * disty[r];
score[nbp] = (xs[r + 1] - xs[r - 1]) - penalty[r] - kAa * (ys[2] - ys[1])
- dd * disty[r];
} else if (si[r] >= d - 2) {
score[nbp] = (xs[r + 1] - xs[r - 1]) - penalty[r]
- AA * (ys[d - 2] - ys[d - 3]) - DD * disty[r];
- kAa * (ys[d - 2] - ys[d - 3]) - dd * disty[r];
} else {
score[nbp] = (xs[r + 1] - xs[r - 1]) - penalty[r]
- BB * (ys[si[r] + 1] - ys[si[r] - 1]) - DD * disty[r];
- kBb * (ys[si[r] + 1] - ys[si[r] - 1]) - dd * disty[r];
}
nbp++;

if (s[r] <= 1) {
score[nbp] = (ys[r + 1] - ys[r - 1]) - penalty[s[r]]
- AA * (xs[2] - xs[1]) - DD * distx[r];
- kAa * (xs[2] - xs[1]) - dd * distx[r];
} else if (s[r] >= d - 2) {
score[nbp] = (ys[r + 1] - ys[r - 1]) - penalty[s[r]]
- AA * (xs[d - 2] - xs[d - 3]) - DD * distx[r];
- kAa * (xs[d - 2] - xs[d - 3]) - dd * distx[r];
} else {
score[nbp] = (ys[r + 1] - ys[r - 1]) - penalty[s[r]]
- BB * (xs[s[r] + 1] - xs[s[r] - 1]) - DD * distx[r];
- kBb * (xs[s[r] + 1] - xs[s[r] - 1]) - dd * distx[r];
}
nbp++;
}
Expand Down
Loading