Skip to content

mpl: settle MPL-0003 with an exact packing check, and prove what does not fit - #11808

Open
oharboe wants to merge 6 commits into
The-OpenROAD-Project:masterfrom
oharboe:mpl-exact-tilings
Open

oharboe wants to merge 6 commits into
The-OpenROAD-Project:masterfrom
oharboe:mpl-exact-tilings

Conversation

@oharboe

@oharboe oharboe commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Opened for discussion.

When no annealing run finds a tiling for a mixed cluster, MPL-0003 now settles whether one exists with an exact fixed-outline packing check (OR-tools CP-SAT, which OpenROAD already links). Either it finds an arrangement, whose bounding box becomes the tiling, or it proves that none exists and the error names each single change to the core that fixes it. When annealing succeeds, nothing changes: the check runs only after every annealing run has failed.

asap7/aes-block with a 110.5 um core (The-OpenROAD-Project/OpenROAD-flow-scripts#4681), before and after:

[ERROR MPL-0003] There are no valid tilings for mixed cluster: root
[ERROR MPL-0003] There are no valid tilings for mixed cluster root. The blocks, halos included, cannot fit in the 108.432 x 108.270 um outline (proven).
  Cause: the area suffices (83% of the outline), but no arrangement of the blocks does.
  It fits with any one of:
    same width 108.432 um: height >= 109.350 um
    same height 108.270 um: width >= 109.350 um
    same aspect ratio: width >= 109.296 um
  The outline is the core area.

Checked in the ORFS flow: at a 111.35 um core (outline 109.296 um wide) MPL-0003 proves again that the macros do not fit; at 111.402 um (outline 109.350 um, the proposed width) the floorplan completes.

Measured on 18 ORFS designs (asap7, gf180, nangate45):

result
every tiling problem mpl's annealer was asked (285) the check agrees with every annealing result: 165 fit, 120 proven not to fit, 0 undecided; 17 of the 165 are fits that annealing run missed
causes of the 120 proofs block too tall 50, block too wide 28, area 25, arrangement 17
time of the check on those 285 problems 0.7 s in total, slowest 77 ms (annealing them took 32 s)
macro placement on each design's own core, master vs this PR identical macro-net wirelength on all 18 designs in every run (3 per arm); runtime 0.98x to 1.02x, within noise

How these were measured, and the rest of the study: The-OpenROAD-Project/bazel-orfs#1290.

Commits

  1. shapes as a library of its own, so the check depends on Tiling and Interval without object.cpp and odb
  2. the exact fixed-outline packing check
  3. the smallest outline at which a packing fits: same width, same height, same aspect ratio
  4. words for why a packing does not fit
  5. the annealer's question as a packing problem
  6. MPL-0003 settled by the exact check

Tests

C++ gtests that check what the code must do against an independent reference, not golden output: planted packings with known answers, an exhaustive search on small cases, a geometry validator written in the test, the same answer for the same input, a tiny budget answering "undecided" rather than failing, the fixes being the smallest that fit on the given grid, every shape SoftMacro::resizeRandomly produces being one the packing problem allows, and malformed input (an outline without area, a block without a shape, a step <= 0) being refused with an exception rather than answered. The existing Tcl regressions pass unchanged.

#11809 offers the 136 packing problems behind the table above as a gtest, and the bench used to measure.

Limits

  • A problem the check cannot decide within its deterministic budget keeps the plain error; the README says so. None of the 285 tiling problems above needed it.
  • Placement failures (MPL-0040, MPL-0008, MPL-0010) are not covered here.

Claude made the changes and stared at paint drying.

🤖 Generated with Claude Code

Tiling and Interval are plain value types; a library of their own lets
code that needs only them depend on them without object.cpp and odb.
No change in behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@github-actions

Copy link
Copy Markdown
Contributor

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@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 an exact packing feasibility check using OR-Tools CP-SAT to determine if a valid macro tiling exists when annealing fails, integrating it into the hierarchical macro placement flow and providing detailed outline fix suggestions. The review feedback highlights several safety improvements to prevent potential division-by-zero errors in utility functions, a signed integer overflow risk when calculating block areas, and an out-of-bounds access vulnerability if width and height interval sizes mismatch.

Comment thread src/mpl/src/packing.cpp
Comment thread src/mpl/src/packing.cpp
Comment thread src/mpl/src/packing.cpp
Comment thread src/mpl/src/packing.cpp
Comment thread src/mpl/src/packingAdapter.cpp
oharboe and others added 5 commits October 17, 2026 10:50
checkPacking() decides whether rectangles fit in a fixed outline without
overlap, with OR-tools CP-SAT, which OpenROAD already links: rigid blocks
with one or more shapes, soft blocks whose height is floor(area / width)
as SoftMacro computes it, and fixed blocks. The answer is kFits with a
placement, kDoesNotFit with a cause (a block too wide or too tall, the
area, or the arrangement), or kUndecided when the deterministic budget
runs out; it does not depend on machine load or thread scheduling.

Cheap bounds and constructions settle most problems first: a block that
fits nowhere, the area, blocks wider than half the outline that must
stack, identical blocks that must fit as a grid, and a shelf packing. The
rest go to CP-SAT on a ladder of grids, coarse first: rounding blocks up
gives placements legal at full resolution, rounding them down gives
proofs that nothing fits. Nothing calls it yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
smallestHeight(), smallestWidth() and smallestSameAspect() bisect over
exact checks for the one outline change that makes a problem fit, on a
given grid (rows, sites); a bigger outline never makes a packing
impossible, so a bisection is exact. The questions share one budget, and
an undecided one widens the reported range instead of stalling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
explainDoesNotFit() states that the problem is proven not to fit, its
cause, and each single change to the outline that fixes it, in microns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
toPackingProblem() states what an annealer is asked: its sequence-pair
macros inside its outline, each with every shape the annealer can give
it (SoftMacro::resizeRandomly's area per width interval), fixed ones
where they are; terminals and empty macros take no room. The test checks
that every shape the annealer produces is one the problem allows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
MPL-0003 said only that annealing found no tiling. When no run finds
one, the exact check now either finds an arrangement, whose bounding box
becomes the tiling, or proves that none exists, and the error says why
and which single change to the core fixes it, on the row and site grid:

  [ERROR MPL-0003] There are no valid tilings for mixed cluster root.
  The blocks, halos included, cannot fit in the 108.432 x 108.270 um
  outline (proven).
    Cause: the area suffices (83% of the outline), but no arrangement of
    the blocks does.
    It fits with any one of:
      same width 108.432 um: height >= 109.350 um
      same height 108.270 um: width >= 109.350 um
      same aspect ratio: width >= 109.296 um
    The outline is the core area.

That is asap7/aes-block at a core of 110.5 um; a core 109.350 um wide
(2025 sites) places, one site narrower does not. A problem the check
cannot decide within its budget keeps the plain error; the README's
limitations say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
oharboe marked this pull request as ready for review October 17, 2026 09:52
@oharboe
oharboe requested a review from a team as a code owner October 17, 2026 09:52
@oharboe
oharboe requested a review from AcKoucher October 17, 2026 09:52
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