Skip to content
Merged
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
5 changes: 3 additions & 2 deletions src/mpl/src/SACoreSoftMacro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,9 @@ void SACoreSoftMacro::calSoftBlockagePenalty()
for (const odb::Rect& blockage : soft_blockages_) {
for (const int macro_id : pos_seq_) {
Comment on lines 498 to 499

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

The current nested loop structure iterates over blockages in the outer loop and macros in the inner loop. Since several properties of the macro (such as its bounding box and the macro_dominance calculation) are invariant with respect to the blockage, swapping the loops would allow hoisting these calculations out of the inner loop. This would improve efficiency by reducing redundant calls and calculations, which is particularly beneficial when the number of macros is large.

References
  1. When analyzing code within a loop, consider the entire loop structure to identify and eliminate redundant operations or calculations that can be hoisted or optimized.

const SoftMacro& soft_macro = macros_[macro_id];
if (soft_macro.getNumMacro() > 0) {
Cluster* cluster = soft_macro.getCluster();

if (soft_macro.getNumMacro() > 0 && cluster->getArea() > 0) {
odb::Rect overlap;
blockage.intersection(soft_macro.getBBox(), overlap);

Expand All @@ -507,7 +509,6 @@ void SACoreSoftMacro::calSoftBlockagePenalty()
continue;
}

Cluster* cluster = soft_macro.getCluster();
const float macro_dominance
= cluster->getMacroArea() / static_cast<float>(cluster->getArea());

Expand Down
Loading