Skip to content

gpl: add a synthetic design builder with known-answer and metamorphic tests - #12175

Draft
maliberty wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:gpl-design-builder
Draft

maliberty wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:gpl-design-builder

Conversation

@maliberty

Copy link
Copy Markdown
Member

Adds synthetic designs whose good placement is known in advance, and tests that check gpl recovers it. Part of moving gpl's golden tests to semantic C++ tests.

gpl_design_builder is a test-only library. It builds small designs directly in odb on a fixed 20 × 20 µm core, using one master with a pin on each side, so no LEF, DEF or liberty is needed. It has four generators:

  • a chain of cells between two IOs;
  • a lattice of cells tied to IOs on the die edges;
  • cells on no nets;
  • two unrelated lattices, each anchored by an IO on an opposite die edge.

known_answer_test checks the structure of the placement. The connected designs run both with initial placement and with Nesterov placement alone.

Test Check
ChainLinesUpInOrder Chain order is preserved along x (Spearman > 0.95), and the chain stays at mid height.
LatticeKeepsItsShape Columns are ordered along x and rows along y (Spearman > 0.95).
UnrelatedClustersStayApart Each cluster stays on its anchor's side of the core, and their bounding boxes overlap by less than 10%.
DensitySpreadsUnconnectedCells A clump in the core corner spreads evenly under uniform density: every tile of a 5 × 5 grid holds between 0.5× and 1.5× the mean.

metamorphic_test places gcd and compares the result with three changed versions of the design, allowing a 0.2% HPWL difference:

  • the IO pins mirrored left to right;
  • the instance order shuffled;
  • the whole design translated by (1 mm, 2 mm). Cells must also land near their shifted positions.

The measured differences are 0.012–0.034%. The tolerance is tight enough to catch a density force biased to one side, which moves the mirrored HPWL by 0.7%.

I checked the tests by breaking gpl on purpose:

Change to gpl Tests that fail
x wirelength force zeroed the Nesterov-only connected cases and translation
x density force zeroed the unconnected-cells test and all three metamorphic tests
density force 1.5× to the right the unconnected-cells test and mirroring

DensitySpreadsUnconnectedCells skips initial placement. When no cell is on a net, initial placement collapses them all into one stack at the core center. There the density force is zero, and Nesterov placement fails with GPL-0305. That is tracked as a separate fix.

The PR also includes two small fixes:

  • PartialOverlapOverflowsOnlyFullBins now places one cell. The test uses it so that only the fully covered bin overflows, and it asserts the hand-computed overflow, 7.5/64. With two cells, every bin the cells touched overflowed.
  • place_ios_test now depends on //src/utl for the utl/Logger.h it includes, which the layering check requires.

With two stacked cells every touched bin overflowed, the diagonal one
by 0.5e6, so the test never showed lightly covered bins staying under
capacity. Use one cell, which overflows only the bin it covers fully,
and check the hand-computed 7.5e6 / 64e6.

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
@maliberty maliberty self-assigned this Nov 8, 2026
@github-actions github-actions Bot added the size/L label Nov 8, 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 introduces synthetic and metamorphic global placement tests for the gpl module, including a DesignBuilder helper to construct small designs directly in odb. It adds tests verifying that the placer recovers expected structures (chains, lattices, and clusters) and spreads unconnected cells, as well as metamorphic tests comparing placement quality under mirroring, translation, and instance shuffling. Feedback is provided regarding a potential iterator invalidation issue in metamorphic_test.cpp when destroying boxes while iterating over pin->getBoxes().

Comment thread src/gpl/test/metamorphic_test.cpp Resolved
… tests

gpl_design_builder builds small designs directly in odb (chain, lattice,
unconnected cells, and two unrelated clusters) whose good placement is
known in advance.

known_answer_test checks that placement recovers that structure: chain
order along x, lattice rows and columns spread over the core, separated
clusters, and even spreading of unconnected cells under uniform density.
The connected cases run with and without initial placement.

metamorphic_test places gcd and compares it with mirrored IO pins,
shuffled instance order, and a translated design, within 0.2% HPWL.

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
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