Repository navigation
Conversation
fix counter for diamond recoveries (if two cells were conflicting on DRC only one of them was being counted). retuilize some duplicated code. print instance names which were not sucessfully legalized. Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
There was a problem hiding this comment.
Code Review
This pull request refactors the stall recovery logic in NegotiationLegalizer by introducing helper lambdas (is_stalled and recover_stall) and a helper method (collectIllegalCells) to reduce code duplication between Phase 1 and Phase 2. It also improves logging by printing detailed information about illegal nodes when negotiation fails to converge, and updates diamondRecovery to accurately report the number of recovered cells by rechecking their legality. The review feedback suggests maintaining unique log message IDs across different phases by passing the message ID as a parameter to recover_stall, and optimizing collectIllegalCells by reserving memory for the returned vector.
| auto recover_stall = [&](const int phase, const int violations) { | ||
| print_last_if_needed(); | ||
| const std::vector<int> illegal_cells = collectIllegalCells(active); | ||
| logger_->warn(utl::DPL, | ||
| 700, | ||
| "Negotiation phase {}: violations stuck at {} for 3 " | ||
| "consecutive iterations. Using diamond search for {} " | ||
| "remaining illegal cells.", | ||
| phase, | ||
| violations, | ||
| illegal_cells.size()); | ||
| diamondRecovery(illegal_cells); | ||
| }; |
There was a problem hiding this comment.
In OpenROAD, log message IDs should be unique to allow precise tracking and documentation. Reusing message ID 700 for both Phase 1 and Phase 2 stall warnings violates this convention. Consider passing the message ID as a parameter to recover_stall so that Phase 1 can use 700 and Phase 2 can use 702 as originally defined.
| auto recover_stall = [&](const int phase, const int violations) { | |
| print_last_if_needed(); | |
| const std::vector<int> illegal_cells = collectIllegalCells(active); | |
| logger_->warn(utl::DPL, | |
| 700, | |
| "Negotiation phase {}: violations stuck at {} for 3 " | |
| "consecutive iterations. Using diamond search for {} " | |
| "remaining illegal cells.", | |
| phase, | |
| violations, | |
| illegal_cells.size()); | |
| diamondRecovery(illegal_cells); | |
| }; | |
| auto recover_stall = [&](const int phase, const int msg_id, const int violations) { | |
| print_last_if_needed(); | |
| const std::vector<int> illegal_cells = collectIllegalCells(active); | |
| logger_->warn(utl::DPL, | |
| msg_id, | |
| "Negotiation phase {}: violations stuck at {} for 3 " | |
| "consecutive iterations. Using diamond search for {} " | |
| "remaining illegal cells.", | |
| phase, | |
| violations, | |
| illegal_cells.size()); | |
| diamondRecovery(illegal_cells); | |
| }; |
| if (is_stalled(phase_1_violations)) { | ||
| recover_stall(1, phase_1_violations); | ||
| break; |
There was a problem hiding this comment.
| if (is_stalled(phase_2_violations)) { | ||
| finish_ = Finish::kPhase2Recovery; | ||
| recover_stall(2, phase_2_violations); | ||
| break; |
There was a problem hiding this comment.
Update the call to recover_stall to pass the unique message ID 702 for Phase 2.
| if (is_stalled(phase_2_violations)) { | |
| finish_ = Finish::kPhase2Recovery; | |
| recover_stall(2, phase_2_violations); | |
| break; | |
| if (is_stalled(phase_2_violations)) { | |
| finish_ = Finish::kPhase2Recovery; | |
| recover_stall(2, 702, phase_2_violations); | |
| break; | |
| } |
| std::vector<int> NegotiationLegalizer::collectIllegalCells( | ||
| const std::vector<int>& cells) const | ||
| { | ||
| std::vector<int> illegal; | ||
| for (const int idx : cells) { | ||
| if (!cells_[idx].fixed && !isCellLegal(idx)) { | ||
| illegal.push_back(idx); | ||
| } | ||
| } | ||
| return illegal; | ||
| } |
There was a problem hiding this comment.
To avoid potential multiple reallocations of the illegal vector during the loop, consider reserving memory upfront using cells.size() as an upper bound.
| std::vector<int> NegotiationLegalizer::collectIllegalCells( | |
| const std::vector<int>& cells) const | |
| { | |
| std::vector<int> illegal; | |
| for (const int idx : cells) { | |
| if (!cells_[idx].fixed && !isCellLegal(idx)) { | |
| illegal.push_back(idx); | |
| } | |
| } | |
| return illegal; | |
| } | |
| std::vector<int> NegotiationLegalizer::collectIllegalCells( | |
| const std::vector<int>& cells) const | |
| { | |
| std::vector<int> illegal; | |
| illegal.reserve(cells.size()); | |
| for (const int idx : cells) { | |
| if (!cells_[idx].fixed && !isCellLegal(idx)) { | |
| illegal.push_back(idx); | |
| } | |
| } | |
| return illegal; | |
| } |
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
osamahammad21
left a comment
There was a problem hiding this comment.
I'll leave merging to you once you handle the requested change
| for (const Node* node : illegal_nodes) { | ||
| logger_->report(" {} ({}) at dbu ({}, {})", | ||
| node->name(), | ||
| node->getDbInst()->getMaster()->getName(), | ||
| (core_.xMin() + node->getLeft()).v, | ||
| (core_.yMin() + node->getBottom()).v); | ||
| } |
There was a problem hiding this comment.
This could get out of hand if the number of illegal nodes is very high. saveFailures should already have the detailed list of the failing nodes, so I don't think it's needed.
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Summary
Negotiation legalizer uses the former diamond search algorithm to legalize instances which Negotiation wasn't able to.
This PR makes a few changes to diamond recovery:
diamondSearchsuccesses, so cells made legal by moving a neighbor are counted.Type of Change
Impact
Placement changes only when phase 2 hits its iteration limit; otherwise only log output changes
Verification
./etc/Build.sh).Related Issues
Addresses issue #12262, originated from #12233