Skip to content

mpl: avoid division by zero in soft blockage penalty calculation#10063

Merged
eder-matheus merged 1 commit into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:mpl-coverity-issue
Apr 6, 2026
Merged

mpl: avoid division by zero in soft blockage penalty calculation#10063
eder-matheus merged 1 commit into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:mpl-coverity-issue

Conversation

@openroad-ci

Copy link
Copy Markdown
Member

Summary

Fix small defect detected by Coverity. The division by zero could happen if a macro was created with width or height equal to 0 or width and height equal to 1.

Type of Change

  • Bug fix

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Signed-off-by: João Mai <jmai@precisioninno.com>

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates SACoreSoftMacro.cpp to include a check for cluster area and refactors the retrieval of cluster objects within the calSoftBlockagePenalty function. A review comment recommends optimizing the nested loop structure by swapping the blockage and macro loops to reduce redundant calculations.

Comment on lines 498 to 499
for (const odb::Rect& blockage : soft_blockages_) {
for (const int macro_id : pos_seq_) {

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.

@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@joaomai joaomai requested a review from eder-matheus April 6, 2026 14:37
@eder-matheus eder-matheus enabled auto-merge April 6, 2026 14:40
@eder-matheus eder-matheus merged commit c80a771 into The-OpenROAD-Project:master Apr 6, 2026
15 checks passed
@openroad-ci openroad-ci deleted the mpl-coverity-issue branch April 6, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants