Skip to content

gpl: memoize signal pin counts per cell master during initialization - #11073

Open
oharboe wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:gpl-memoize-master-pin-count
Open

gpl: memoize signal pin counts per cell master during initialization#11073
oharboe wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:gpl-memoize-master-pin-count

Conversation

@oharboe

@oharboe oharboe commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

During PlacerBaseCommon::init(), instance pin density calculations previously invoked dbInst::getITerms() and count_signal_pins() for every instance. On large designs (e.g. 2.4 million instances), this caused millions of (N)$ dbNetITermItr::size() linked-list traversals across ODB database structures.

Since an instance's pin count is defined by its LEF cell master (dbMaster), this change memoizes signal pin counts per cell master using a local boost::unordered_flat_map during PlacerBaseCommon::init().

Benefits & Performance

  • Reduces getMTerms() evaluations from (\text{instances})$ (e.g., 2.4 million) to (\text{unique masters})$ (e.g., ~200).
  • Completely eliminates linked-list getITerms() iteration overhead during GPL initialization without altering any central ODB structures.
  • Tested and verified locally with bazelisk test //src/gpl/test:simple01-skip-io-tcl_test //src/gpl/test:gpl_messages_txt_check-py_test.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
oharboe requested a review from a team as a code owner August 5, 2026 10:08
@oharboe
oharboe requested a review from gudeh August 5, 2026 10:08
@github-actions github-actions Bot added the size/S label Aug 5, 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 optimizes the average pin density calculation in PlacerBaseCommon::init by memoizing master signal pin counts using a flat map. However, the implementation changes the pin count types from int to double. The review feedback recommends reverting these types back to int to maintain semantic correctness and consistency with the codebase, while ensuring that proper static casts to double are used during division to avoid integer division bugs.

Comment thread src/gpl/src/placerBase.cpp Outdated
Comment thread src/gpl/src/placerBase.cpp Outdated
Comment thread src/gpl/src/placerBase.cpp Outdated
…teger pin counts

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe

oharboe commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

Applied all Gemini review suggestions in commit b9f6571 (using boost::unordered::unordered_flat_map with discrete int pin counts) and resolved review threads.

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