Algorithm Search⌘K

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 G=(V,E)G = (V, E), part of a control data flow graph, with a delay d(v)d(v) and a start step s(v)s(v) 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: uu and vv are mutually exclusive when no execution of the design runs both.
  • A set KK of unit types with an area ck>0c_k > 0 for each k∈Kk \in K, and for each operation the type t(v)∈Kt(v) \in K that runs it.

Let B(v)={s(v),…,s(v)+d(v)−1}B(v) = \{s(v), \ldots, s(v) + d(v) - 1\} be the busy set of vv. Two operations of the same type are compatible when B(u)∩B(v)=∅B(u) \cap B(v) = \emptyset or they are mutually exclusive.

Feasible solutions. A binding β\beta maps each vv to an instance β(v)=(t(v),i)\beta(v) = (t(v), i) with i∈{1,2,…}i \in \{1, 2, \ldots\}, such that β(u)=β(v)\beta(u) = \beta(v) implies that uu and vv are compatible.

Objective. Minimize ∑k∈Kck nk(β)\sum_{k \in K} c_k\, n_k(\beta), where nk(β)n_k(\beta) is the number of instances of type kk that β\beta uses.

Decision form. Given the input and integers (Nk)k∈K(N_k)_{k \in K}, is there a binding with nk(β)≤Nkn_k(\beta) \le N_k for each kk?

Since each operation has one type, the objective splits into one problem per type: minimize nkn_k over the operations of type kk. By the clique argument on the resource compatibility graph page, the least nkn_k is the clique partition number of the compatibility graph GkG_k, which is the chromatic number χ(Gk‾)\chi(\overline{G_k}) 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 B(v)={s(v)}B(v) = \{s(v)\}.
  • Loops. In a loop that starts a new iteration every IIII steps, an operation is busy in the steps B(v) mod IIB(v) \bmod II. Busy sets become arcs of a circle with IIII 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 m1,m2m_1, m_2 in step 1, m3m_3 in step 2, and m4m_4 in steps 3 and 4. At most 2 multiplies are busy in one step, and the binding {m1,m3,m4}\{m_1, m_3, m_4\}, {m2}\{m_2\} uses 2 multipliers.

Conditional code where the busiest step is not enough. Let a variable κ\kappa select one of the cases 1,…,101, \ldots, 10, and put five multiplies m1,…,m5m_1, \ldots, m_5 in step 1, all guarded:

operation runs when κ\kappa is in
m1m_1 {1,5,6}\{1, 5, 6\}
m2m_2 {1,2,7}\{1, 2, 7\}
m3m_3 {2,3,8}\{2, 3, 8\}
m4m_4 {3,4,9}\{3, 4, 9\}
m5m_5 {4,5,10}\{4, 5, 10\}

Each value of κ\kappa runs at most 2 multiplies, so no execution ever has more than 2 busy in step 1. But mim_i and mi+1m_{i+1} (and m5m_5 and m1m_1) run together for one value of κ\kappa, 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 {m1,m3}\{m_1, m_3\}, {m2,m4}\{m_2, m_4\} and {m5}\{m_5\}.

Known algorithms

AlgorithmTimeSpacePropertiesCode
Tseng-Siewiorek clique partitioningO(n^2 m) worstO(n + m) extradeterministicnot exactofflineiterative1 language

Bounds

Lower bound. In every binding, nk≥ω(Gk‾)n_k \ge \omega(\overline{G_k}), the size of the largest set of pairwise conflicting operations of type kk, since they need distinct instances. This is at least the largest number of type-kk 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 nkn_k equals the largest number of type-kk 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 ω=2\omega = 2 and needs 3. Since the construction in the next section realizes every graph as a conflict graph, the ratio χ/ω\chi / \omega is unbounded: there are triangle-free graphs of any chromatic number.

Upper bound. Any greedy coloring of the conflict graph uses at most Δ+1\Delta + 1 instances, with Δ\Delta 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 kk is the clique cover problem on GkG_k, 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 H=(U,F)H = (U, F) and an integer qq. Number the edges and the vertices of HH, so that a variable κ\kappa ranges over F∪UF \cup U. For each vertex uu, build a multiply mum_u in step 1, guarded by the test κ∈Su\kappa \in S_u with

Su={e∈F:u∈e}∪{u}.S_u = \{ e \in F : u \in e \} \cup \{ u \}.

Two multiplies mum_u and mvm_v both run exactly when κ∈Su∩Sv\kappa \in S_u \cap S_v. The private elements uu and vv differ, so Su∩Sv={uv}S_u \cap S_v = \{uv\} when uv∈Fuv \in F and Su∩Sv=∅S_u \cap S_v = \emptyset otherwise. So mum_u and mvm_v conflict exactly when uvuv is an edge of HH, the conflict graph of the multiplies is HH, and qq multipliers suffice exactly when χ(H)≤q\chi(H) \le q. The construction has ∣U∣|U| operations and tests of total size O(∣U∣+∣F∣)O(|U| + |F|). Chromatic number is NP-complete (Karp 1972), so resource binding is NP-hard. The 5-cycle example above is this construction for H=C5H = C_5.

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 O(nlog⁡n)O(n \log n) time for nn 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

  1. 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)
  2. 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)
  3. 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
  4. 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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml