Problemcore
Resource binding
Also called functional unit binding, resource sharing.
Assign the operations of a scheduled graph to functional unit instances so that operations in the same step never share a unit and the total cost is least.
Resource binding is the step of high-level synthesis that maps each operation of a scheduled design to one instance of a functional unit, such as multiplier 2 or ALU 1. Two operations may use one instance only if they are never busy in the same step. With the schedule fixed, the least number of instances of a unit type is the least number of cliques that partition the resource compatibility graph of that type. For straight-line code this is easy, but with conditional code it is NP-hard.
In plain words
After scheduling, each calculation has a time slot. Now each one needs a piece of hardware to run on. Two multiplies in different slots can use the same multiplier, but two multiplies in the same slot cannot, unless they sit on the two sides of an if and so never both happen. The task is to give each calculation a unit so that no unit is double booked, and to buy as few units as possible. When the code has no branches, count the busiest slot: that many units of the type are enough. When branches let calculations share a slot without a clash, the puzzle becomes as hard as coloring a map. A second goal is to keep the wiring small, since each extra source on a unit input costs a multiplexer input.
Definition
Input.
- A scheduled sequencing graph , part of a control data flow graph, with a delay and a start step for each operation, as in resource-constrained scheduling. There is no chaining, and units are not pipelined unless the variant says so.
- A relation of mutual exclusion: and are mutually exclusive when no execution of the design runs both.
- A set of unit types with an area for each , and for each operation the type that runs it.
Let be the busy set of . Two operations of the same type are compatible when or they are mutually exclusive.
Feasible solutions. A binding maps each to an instance with , such that implies that and are compatible.
Objective. Minimize , where is the number of instances of type that uses.
Decision form. Given the input and integers , is there a binding with for each ?
Since each operation has one type, the objective splits into one problem per type: minimize over the operations of type . By the clique argument on the resource compatibility graph page, the least is the clique partition number of the compatibility graph , which is the chromatic number of the conflict graph.
This page is about functional units. Register binding is the same kind of problem for values and their lifetimes, and interconnect binding chooses the multiplexers and ports once units and registers are bound.
Variants
- Interconnect cost. The objective adds the multiplexer inputs in front of the units. Then two bindings with the same unit count can differ in cost, and the problem no longer splits by type. See interconnect binding.
- Several types per operation. An add may run on an adder or on an ALU. The binding then also chooses the type, which is the problem of module selection when the types differ in delay.
- Pipelined units. A pipelined unit takes a new operation in each step, so .
- Loops. In a loop that starts a new iteration every steps, an operation is busy in the steps . Busy sets become arcs of a circle with points, and the conflict graph is a circular-arc graph, see circular-arc coloring.
- Binding before scheduling. Some flows bind first and then schedule with the binding as a constraint, or solve both together in one 0-1 program. The definition above fixes the schedule.
Examples
Straight-line code. Take the schedule of the compatibility graph page with the branch removed: multiplies in step 1, in step 2, and in steps 3 and 4. At most 2 multiplies are busy in one step, and the binding , uses 2 multipliers.
Conditional code where the busiest step is not enough. Let a variable select one of the cases , and put five multiplies in step 1, all guarded:
| operation | runs when is in |
|---|---|
Each value of runs at most 2 multiplies, so no execution ever has more than 2 busy in step 1. But and (and and ) run together for one value of , and no other pair does. The conflict graph is the 5-cycle, which needs 3 colors, so the least binding has 3 multipliers, for example , and .
Known algorithms
- Interval partitioning and the left-edge algorithm. Exact for straight-line code with one type per operation: they reach the number of operations in the busiest step. See interval partitioning and the left-edge algorithm.
- Coloring of chordal conflict graphs. Exact when the conflict graph is chordal, in linear time. See chordal graph coloring.
- Tseng-Siewiorek clique partitioning. A greedy merge on the compatibility graph. Heuristic: it can use more units than needed, even on straight-line code. See Tseng-Siewiorek clique partitioning.
- Weighted bipartite matching. Binds step by step with an assignment problem per step to save interconnect. Heuristic for interconnect. See weighted bipartite matching binding.
- Coloring heuristics. For general conflict graphs, greedy coloring and DSatur are fast with no guarantee.
- Integer programming. A 0-1 variable for each operation and instance gives the optimum for small designs, also with interconnect costs. See 0-1 integer programming.
| Algorithm | Time | Space | Properties | Code |
|---|---|---|---|---|
| Tseng-Siewiorek clique partitioning | O(n^2 m) worst | O(n + m) extra | deterministicnot exactofflineiterative | 1 language |
Bounds
Lower bound. In every binding, , the size of the largest set of pairwise conflicting operations of type , since they need distinct instances. This is at least the largest number of type- operations busy in one step of one execution.
Straight-line code. With no mutually exclusive pairs, the busy sets are intervals of steps, the conflict graph is an interval graph, and the least equals the largest number of type- operations busy in one step. Proof: pairwise intersecting intervals share a point, so a largest clique of the conflict graph is a set of operations busy in one common step, which gives the lower bound. The interval coloring depth theorem gives a coloring with that many colors. So for straight-line code, the scheduler already fixes the unit count, and binding only decides the interconnect.
Gap with branches. The 5-cycle example has and needs 3. Since the construction in the next section realizes every graph as a conflict graph, the ratio is unbounded: there are triangle-free graphs of any chromatic number.
Upper bound. Any greedy coloring of the conflict graph uses at most instances, with the largest number of operations that conflict with one operation.
Reductions
To clique cover and coloring. For one type per operation, resource binding of type is the clique cover problem on , and graph coloring on its complement. The proof is on the resource compatibility graph page.
NP-hard with conditional code. The decision form is NP-complete. It is in NP, since a binding is checked pair by pair. For hardness, take any graph and an integer . Number the edges and the vertices of , so that a variable ranges over . For each vertex , build a multiply in step 1, guarded by the test with
Two multiplies and both run exactly when . The private elements and differ, so when and otherwise. So and conflict exactly when is an edge of , the conflict graph of the multiplies is , and multipliers suffice exactly when . The construction has operations and tests of total size . Chromatic number is NP-complete (Karp 1972), so resource binding is NP-hard. The 5-cycle example above is this construction for .
The proof needs a mutual exclusion relation that is exact for these tests. A tool that detects fewer exclusions sees more conflicts, which can only raise the count.
Polynomial case. For straight-line code, the bound above is reached by interval partitioning in time for operations.
Applications
- Datapath synthesis. Every high-level synthesis tool binds operations to units after or during scheduling, as in the flows of De Micheli and of Tseng and Siewiorek.
- Sharing of large units. Dividers, floating point units and memory ports are costly, so sharing them across exclusive branches saves the most area.
- FPGA DSP blocks. On an FPGA with few DSP blocks, binding decides how many multiplies share one block and how many multiplexer inputs they need.
References
- Giovanni De Micheli, Synthesis and Optimization of Digital Circuits, McGraw-Hill, 1994, Chapter 6, Resource Sharing and Binding (sharing and binding of functional resources, compatibility and conflict graphs, and binding with control flow)
- Richard M. Karp, Reducibility among combinatorial problems, in Complexity of Computer Computations, Plenum (1972), 85 to 103, the list of 21 problems (Chromatic number and Clique cover)
- Michael R. Garey and David S. Johnson, Computers and Intractability, A Guide to the Theory of NP-Completeness, W. H. Freeman, 1979, Appendix A1.1, problems GT4, Graph k-colorability, and GT15, Partition into cliques
- Chia-Jeng Tseng and Daniel P. Siewiorek, Automated synthesis of data paths in digital systems, IEEE Transactions on Computer-Aided Design 5(3), 379 to 395, 1986, functional unit allocation as clique partitioning of the operation compatibility graph
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 3GVCMN Edit this page History Report an error Markdown