Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add partition command to do balanced hypergraph partitioning on a gate-level module #2172

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

boqwxp
Copy link
Contributor

@boqwxp boqwxp commented Jun 18, 2020

This PR adds the partition command to do balanced hypergraph partitioning on a flattened gate-level module. Finding an optimal partitioning is generally an NP-hard problem, but fortunately there are good heuristics for it.

Miscellaneous changes:

This PR makes a few various enabling changes around the code base:

  • Add a Design::select() interface for selecting whole modules (See PR rtlil: Add Design::select() for selecting whole modules #2178 )
  • Add operator+=() to dict<>::iterator and dict<>::const_iterator and add operator+() and operator+=() to ObjIterator. This enables indexing into dicts with an iterator, like auto value = *(dict.begin() + offset), which helps reduce memory by avoiding the need for a node number -> cell dict<int, Cell *> (See PR hashlib, rtlil: Add operator+() and operator+=() to dict iterators #2177 )
  • Break out statdata_t to the Yosys namespace. This is to support the -s option, where we need to measure the size of our module
  • Add unit_gate_cost(), where all gates except NOT and BUF have a unit cost. This is the default cell type cost used for node weights in the hypergraph and for determining module size in the -s option

Solvers, interface, integration:

hMETIS seems to be the most performant solver, but has a very restrictive license. KaHIP has an MIT license but seems to have a nasty dependency on an old version of OpenMPI. minipart is also MIT licensed, but brings in boost dependencies.

@daveshah1 has indicated that he is developing hypergraph partitioning in-tree in nextpnr, so when that is done, I think we all agree to bring that in-tree, and I will update this PR and mark it as ready for review.

Until then, this command makes a temporary directory, writes a .hgr file (spec in this document), invokes minipart (which must be on the PATH), and reads a .sol file with the partition assignments.

Depends:

Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core data structure changes (iterator and selection) are good and can be merged right away as a separate PR.

passes/cmds/partition.cc Outdated Show resolved Hide resolved
passes/cmds/partition.cc Outdated Show resolved Hide resolved
passes/cmds/partition.cc Outdated Show resolved Hide resolved
passes/cmds/partition.cc Outdated Show resolved Hide resolved
passes/cmds/partition.cc Outdated Show resolved Hide resolved
kernel/cost.h Outdated Show resolved Hide resolved
@boqwxp boqwxp force-pushed the partition branch 2 times, most recently from 24ec292 to 83056b0 Compare June 19, 2020 04:38
passes/sat/qbfsat.cc Outdated Show resolved Hide resolved
@boqwxp boqwxp changed the title Add partition command to do balanced hypergraph partitioning on a techmapped module Add partition command to do balanced hypergraph partitioning on a gate-level module Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants