Skip to content

dpl: draw diamond search as a per-instance outline - #11055

Open
gudeh wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
gudeh:dpl-debug-changes
Open

dpl: draw diamond search as a per-instance outline#11055
gudeh wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
gudeh:dpl-debug-changes

Conversation

@gudeh

@gudeh gudeh commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

We currently still use diamond search legacy algorithm as a fall back for corner cases when we fail to legalize an instance with negotiation.

This PR reworks the diamond search debug drawing. Previously when we have a defined debug instance from TCL parameter we would draw in teal the search space. It had an issue where we would not clear the drawing even after clicking continue in debug mode:
image

Now it works more similar to the debug drawing of the negotiation search window. We do not need to set the debug instance from the TCL parameter, we store the search range of each instance and if we click on it we get the diamond search outline, I also changed the drawing so it is just an outline and not draw on top of the layout.
image

Notice we get the negotiation window there (smaller one in teal).

Type of Change

  • Refactoring

Impact

No-op, debug changes only.

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

Record diamond-search candidates for every cell, keyed by dbInst, instead
of only for the debug instance, and clear them per cell at the start of
each search.  drawObjects() then unions the candidates and strokes just the
exterior boundary for the debug instance plus whatever is selected in the
GUI, so a cell's last search can be inspected by selecting it -- the same
workflow as the negotiation search windows.

Filled per-candidate boxes hid the cells underneath and, since consecutive
candidates are one site apart, stacked into an unreadable blob.  Pink is
the one hue not already taken by this renderer.

No effect outside debug mode: the observer only exists after set_debug_dpl
and both call sites are already guarded.

Also report the negotiation best location in absolute dbu so it can be
compared against the reported search windows.

Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@gudeh
gudeh requested a review from a team as a code owner August 3, 2026 20:02
@github-actions github-actions Bot added the size/M label Aug 3, 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 enhances the detailed placement (DPL) debugging graphics by tracking and displaying diamond search candidate regions for multiple cells, using boost::polygon to union overlapping areas and draw their exterior boundaries. The review feedback highlights potential null pointer dereferences on the cell pointer in Graphics::binSearch and Graphics::clearDiamondSearch, and suggests calling clearAllDiamondSearches() at the start of placement to prevent stale visualization data from persisting.

Comment on lines +89 to 92
const odb::dbInst* inst = cell->getDbInst();
if (!inst) {
return;
}

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 cell pointer is dereferenced via cell->getDbInst() without a prior null check. If cell is null, this will cause a null pointer dereference and crash the application. Please add a defensive check for cell before calling getDbInst().

Suggested change
const odb::dbInst* inst = cell->getDbInst();
if (!inst) {
return;
}
if (!cell) {
return;
}
const odb::dbInst* inst = cell->getDbInst();
if (!inst) {
return;
}

Comment on lines +101 to +108
void Graphics::clearDiamondSearch(const Node* cell)
{
auto it = searched_diamond_.find(cell->getDbInst());
if (it != searched_diamond_.end()) {
// Keep the allocation: the same cell gets searched again on later passes.
it->second.clear();
}
}

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 cell pointer is dereferenced via cell->getDbInst() without a prior null check. If cell is null, this will cause a null pointer dereference and crash the application. Please add a defensive check for cell before calling getDbInst().

void Graphics::clearDiamondSearch(const Node* cell)
{
  if (!cell) {
    return;
  }
  const odb::dbInst* inst = cell->getDbInst();
  if (!inst) {
    return;
  }
  auto it = searched_diamond_.find(inst);
  if (it != searched_diamond_.end()) {
    // Keep the allocation: the same cell gets searched again on later passes.
    it->second.clear();
  }
}

Comment on lines +110 to 113
void Graphics::clearAllDiamondSearches()
{
searched_diamond_.clear();
}

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

To prevent stale diamond search outlines from previous placement runs from persisting in the GUI, clearAllDiamondSearches() should also be called inside Graphics::startPlacement(odb::dbBlock* block) when a new placement run begins.

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.

1 participant