Skip to content

drt: pa edge cost refactor and no more division by 2#10739

Open
bnmfw wants to merge 7 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:drt_getEdgeCost_refactor
Open

drt: pa edge cost refactor and no more division by 2#10739
bnmfw wants to merge 7 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:drt_getEdgeCost_refactor

Conversation

@bnmfw

@bnmfw bnmfw commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Slightly refactors the edge cost code to have a constant value for violation and used access points. Implements some early returns and most importantly, eliminates the division by 2 for the standard edge cost. This division by 2 when applies to some integers would cause them to round down and give the wrong value. Now every edge is double the original value, which gives the same results, except no rounding error.

Type of Change

  • Bug fix
  • Refactoring

Impact

In some cases where access points have costs that are only 1 less than the others they would not be chosen as the preferred ones, now they are, as intended.

Verification

  • Secure and ISPD CI Safe
  • 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).

Related Issues

Suports 10486

bnmfw added 2 commits June 22, 2026 19:38
Signed-off-by: bnmfw <bernardoborgessandoval@gmail.com>
Signed-off-by: bnmfw <bernardoborgessandoval@gmail.com>
@bnmfw bnmfw self-assigned this Jun 23, 2026

@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 refactors FlexPA::getEdgeCost to simplify the cost evaluation logic, introduces named constants for repeated access point and violation costs, and modernizes container lookups by replacing .find() != .end() with .contains(). The review feedback highlights a critical bug where cached DRC violations are ignored because has_vio is not checked in the final cost evaluation block, and suggests using inline constexpr instead of static constexpr in the header file to prevent duplicate definitions across translation units.

Comment thread src/drt/src/pa/FlexPA_acc_pattern.cpp Outdated
Comment thread src/drt/src/pa/FlexPA.h Outdated
@bnmfw bnmfw marked this pull request as ready for review June 23, 2026 02:43
@bnmfw bnmfw requested a review from a team as a code owner June 23, 2026 02:43
@bnmfw bnmfw requested a review from maliberty June 23, 2026 02:43
@openroad-ci openroad-ci force-pushed the drt_getEdgeCost_refactor branch from 25d5879 to a5ad11f Compare June 23, 2026 02:44
@openroad-ci openroad-ci force-pushed the drt_getEdgeCost_refactor branch from a5ad11f to 4f8463f Compare June 23, 2026 03:02
Comment thread src/drt/src/pa/FlexPA_acc_pattern.cpp Outdated
return violation_cost;
}

// edge not known to be a violation of not

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

huh?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Typo. vio_edges[] contains either 0 (edge has no violation), 1 (edge has a violation), -1 (not know yet, will be determined in the loop.

@maliberty

Copy link
Copy Markdown
Member

I'm missing where the division by 2 was

@maliberty

Copy link
Copy Markdown
Member

@codex review

@maliberty maliberty requested a review from osamahammad21 June 23, 2026 04:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f8463f800

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/drt/src/pa/FlexPA_acc_pattern.cpp Outdated
@bnmfw

bnmfw commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

I'm missing where the division by 2 was

line 550.

Signed-off-by: bnmfw <bernardoborgessandoval@gmail.com>
Comment thread src/drt/src/pa/FlexPA_acc_pattern.cpp Outdated
return violation_cost;
}

// edge not known to be of violation or not

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry but I still struggle to parse this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants