Skip to content

drt: Access Point has independent grid penalization#10244

Open
openroad-ci wants to merge 7 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:drt_ap_own_grid_cost
Open

drt: Access Point has independent grid penalization#10244
openroad-ci wants to merge 7 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:drt_ap_own_grid_cost

Conversation

@openroad-ci
Copy link
Copy Markdown
Collaborator

Summary

GRID_COST is used as a generic penalization during DRT to indicate undesirable edges. Wrong way routing and Off Grid routing are examples, although neither possible in the PDK I'm working on. Near DR Worker border and near Access Point are examples present in my PDK. The main issue is that while wrong way, off grid and worker border are static characteristics, that is, they never change during routing, Near AP is dynamic. There is a penalty for routing near APs of other nets, but during the routing of a specific net all the penalty for the APs that it will use are temporarily removed, and here lies the problem. APs and the other penalties all use the hasGridCost<Dir> group of flags used to indicate the penalty, and these are all marked as false by the router to mean that "there is no penalty for accessing this AP because it belongs to the routed net" but this also removes the penalty for all other static penalties on the region.

By separating AP penalty in their own group o variables not only this issue is fixed but it will allow to tune for AP penalization in the future. Currently GRID_COST is applied as a penalty if either AP penalty or static penalty is detected in order to try and preserve the tool old behavior.

Some unit tests were changed. This is happening because on those cases the routing respects the static penalties, even if close to a pin that is being routed.

Type of Change

  • Bug fix

Impact

[How does this change the tool's behavior?]

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).

Related Issues

@bnmfw bnmfw added the drt Detailed Routing label Apr 23, 2026
@bnmfw bnmfw requested a review from osamahammad21 April 23, 2026 20:41
Copy link
Copy Markdown
Contributor

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

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 introduces Access Point (AP) costs to the FlexGridGraph by utilizing previously unused bits in the Node structure. It adds corresponding getter and setter methods and integrates these costs into the maze router's cost calculation and debug printing. The review feedback highlights an opportunity to improve robustness by adding bounds checks to the new public hasApCost method and suggests a performance optimization in the critical getCosts function to avoid redundant coordinate corrections.

Comment on lines +270 to +285
bool hasApCost(frMIdx x, frMIdx y, frMIdx z, frDirEnum dir) const
{
bool sol = false;
correct(x, y, z, dir);
switch (dir) {
case frDirEnum::E:
sol = hasApCostE(x, y, z);
break;
case frDirEnum::N:
sol = hasApCostN(x, y, z);
break;
default:
sol = hasApCostU(x, y, z);
}
return sol;
}
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 hasApCost method does not check if the indices x, y, z are within valid bounds after the correct call. While the maze router typically ensures validity before calling cost functions, this method is public and could be called in other contexts. For robustness and consistency with other methods like hasEdge, consider adding an isValid(x, y, z) check.

Comment on lines 547 to +548
bool gridCost = hasGridCost(gridX, gridY, gridZ, dir);
bool apCost = hasApCost(gridX, gridY, gridZ, dir);
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

Both hasGridCost and hasApCost are called sequentially, and both internally call the correct function with the same arguments. Since correct modifies its arguments, this results in redundant calculations. Given that getCosts is in the performance-critical inner loop of the maze router, consider consolidating these checks or providing a unified helper method in FlexGridGraph to avoid redundant coordinate corrections.

References
  1. Operations within a loop should be analyzed for redundancy; identical or similar calls should be consolidated to optimize performance in critical sections.
  2. Logic that is duplicated or shared should be encapsulated in helper functions to improve maintainability and avoid redundancy.

@github-actions
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

@osamahammad21 osamahammad21 left a comment

Choose a reason for hiding this comment

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

@bnmfw Please address the merge conflicts.

@osamahammad21 osamahammad21 self-requested a review May 2, 2026 13:51
Copy link
Copy Markdown
Member

@osamahammad21 osamahammad21 left a comment

Choose a reason for hiding this comment

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

address the merge conflicts.

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

Labels

drt Detailed Routing size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants