Algorithm Search⌘K

Problemcore

High-level synthesis

Also called behavioral synthesis, architectural synthesis.

Turn an algorithmic description into a register transfer design by scheduling operations into clock steps, allocating units and binding operations to them.

High-level synthesis turns a description of what a circuit computes, such as a loop body written in C or in a hardware language, into a register transfer design: a datapath of functional units, registers and multiplexers, and a controller that tells the datapath what to do in each clock step. The description is first compiled into a data flow graph, or a control and data flow graph. Then three linked problems are solved: scheduling assigns each operation to a control step, allocation chooses how many units of each type to build, and binding assigns each operation to a unit and each value to a register. The goal is a small design that meets a latency bound, or a fast design within an area bound. Scheduling under a unit limit is NP-hard already for one unit type and unit delays when the number of units is part of the input, while some binding steps are easy, such as register binding for straight-line code, which is interval coloring.

In plain words

A program says "multiply these, add those, compare the result". A chip that runs it needs multipliers, adders, registers to hold values between clock ticks, and a small controller. High-level synthesis builds that chip from the program. First it decides in which clock tick each operation runs. Then it decides how many multipliers and adders to build, and which operation uses which one. Then it decides which register holds each value. With more hardware, more work runs at the same time and the chip is faster. With less hardware, the chip is smaller but slower. The tool looks for a good balance, and the exact best balance is hard to find.

Definition

Input. A data flow graph G=(V,E)G = (V, E) with no cycle, where each operation vv has a type, such as multiply or add. A library that gives, for each unit type, the operation types it can do, its delay δ\delta in control steps, and its area. A constraint, either a latency bound LL or a number aka_k of units of each type kk.

Feasible solutions. A schedule t:V→{1,2,… }t : V \to \{1, 2, \dots\} with t(v)≥t(u)+δ(u)t(v) \ge t(u) + \delta(u) for each edge (u,v)(u, v); a binding β\beta that maps each operation to a unit instance of a type that can do it, so that two operations on one instance never use the same step; and a register binding that maps each value to a register, so that two values that are live in the same step never share a register.

Objective. In the time-constrained form, the latency is at most LL, and the goal is the least area, the sum of the unit areas plus the registers and multiplexers. In the resource-constrained form, the units are given, and the goal is the least latency, max⁡v(t(v)+δ(v)−1)\max_v (t(v) + \delta(v) - 1).

Decision version of scheduling. Given GG, the delays, the unit counts aka_k and LL, is there a schedule with latency at most LL that never uses more than aka_k units of type kk in a step?

Variants

  • Time-constrained or resource-constrained. Fix the latency and minimize the units, or fix the units and minimize the latency. Exploring both gives the Pareto curve of area and latency.
  • Chaining and multicycle operations. Several fast operations may run in one step if their total delay fits the clock period, and slow ones may take several steps.
  • Pipelined units. A unit with a delay of several steps accepts a new operation every step, which changes the resource constraint.
  • Loops and pipelining. A loop body runs again before the last iteration ends, with an initiation interval. This is the hardware form of modulo scheduling.
  • Control flow. Branches let two operations share a unit in the same step when they are on exclusive paths.
  • Binding objectives. Fewest registers, fewest multiplexer inputs, or fewest buses.

Examples

Take the differential equation example of Paulin and Knight, used on the ASAP and ALAP page: six multiplies, v1,v2,v3,v6,v7,v8v_1, v_2, v_3, v_6, v_7, v_8, and five ALU operations, v4,v5,v9,v10,v11v_4, v_5, v_9, v_{10}, v_{11}, each with delay 1.

Area against latency. The least latency for each number of multipliers and ALUs, found by an exhaustive search over schedules, is:

multipliers 1 ALU 2 ALUs 3 ALUs
1 7 7 7
2 5 4 4
3 5 4 4
4 5 4 4

So 4 steps need 2 multipliers and 2 ALUs, and one ALU fewer costs one step. With unlimited units, the ASAP schedule also reaches 4 steps, but it uses 4 multipliers in step 1.

Scheduling and unit binding. Force-directed scheduling at L=4L = 4 gives the multiplies v1,v2v_1, v_2 in step 1, v3,v6v_3, v_6 in step 2 and v7,v8v_7, v_8 in step 3, and the ALU operations v10v_{10} in step 1, v11v_{11} in step 2, v4v_4 in step 3, and v5,v9v_5, v_9 in step 4. Two multipliers and two ALUs suffice, with for example multiplier 1 doing v1,v3,v7v_1, v_3, v_7 and multiplier 2 doing v2,v6,v8v_2, v_6, v_8.

Register binding. A value is held in a register from the step after it is computed to the last step that reads it. The intermediate values live as follows: v1v_1, v2v_2 and v10v_{10} in step 2; v3v_3 and v6v_6 in step 3; v4v_4, v7v_7 and v8v_8 in step 4. At most 3 values are live in one step, so 3 registers are needed, and the left-edge algorithm reaches 3: R1R_1 holds v1,v3,v4v_1, v_3, v_4; R2R_2 holds v2,v6,v7v_2, v_6, v_7; and R3R_3 holds v10,v8v_{10}, v_8.

Known algorithms

  • ASAP and ALAP. ASAP and ALAP scheduling give the least latency with unlimited units, in O(V+E)O(V + E) time, and the time frame of each operation.
  • List scheduling. List scheduling fills each step with ready operations, by a priority such as the ALAP step or the length of the longest path to a sink, up to the unit limits. It is the usual resource-constrained heuristic.
  • Force-directed scheduling. Force-directed scheduling balances the expected use of each unit type over the steps, for a fixed latency. It is a heuristic.
  • Integer programming. A 0-1 integer program with a variable for each operation and each step in its time frame expresses precedence, unit limits and latency exactly. It is solved by a general solver, for small graphs.
  • Special cases of scheduling. With one unit type, unit delays and a tree of operations, Hu's algorithm is optimal. With two units of one type and unit delays, the Coffman-Graham algorithm is optimal.
  • Register binding. For straight-line code, the lifetimes are intervals, and the left-edge algorithm uses the least number of registers, as in interval partitioning.
  • Unit binding. Group operations into compatible sets, operations of one type in different steps, and pick a grouping that keeps the multiplexers small, by clique partitioning or by matching heuristics.
AlgorithmTimeSpacePropertiesCode
ASAP and ALAP schedulingO(V + E) worstO(V + E) extradeterministicexactofflineiterative1 language
Force-directed schedulingO(V^2 L (E + V L)) worstO(V L + E) extradeterministicnot exactofflineiterative1 language
Static scheduling of synchronous dataflowO(n + E + (n + Q D) D) worstO(n + E) extradeterministicexactofflineiterative1 language

Bounds

Upper bounds (proved).

  • With unlimited units, the least latency is the length of the critical path, found by ASAP in O(V+E)O(V + E) time.
  • With one unit type, mm units and any priority, list scheduling gives a latency at most (2−1/m)(2 - 1/m) times the optimum, by the list scheduling bound of Graham.
  • For straight-line code and a fixed schedule, the least number of registers equals the largest number of values live in one step, and the left-edge algorithm reaches it in O(Vlog⁡V)O(V \log V) time.
  • The scheduling decision version is in NP: a schedule is a certificate, checked in polynomial time.

Lower bounds (proved, as hardness).

  • Resource-constrained scheduling is NP-complete already with one unit type, unit delays and the number of units given as part of the input (Ullman 1975). The time-constrained form is NP-hard by the same result, since "is there a schedule of latency LL with mm units" is the same question.
  • For values that live across the boundary of a loop iteration, the lifetimes are arcs of a circle, and the least number of registers is the chromatic number of a circular-arc graph, which is NP-hard to find (Garey, Johnson, Miller and Papadimitriou 1980).

Measured. Heuristics such as list scheduling and force-directed scheduling are judged by runs on benchmark graphs such as the differential equation example, not by proved bounds. On 750 small random instances with at most 6 operations, made by the random generator of the force-directed scheduling tests, that heuristic needed one unit more than the optimum on 16 of them. This is a measurement on small random graphs only.

Reductions

  • From multiprocessor scheduling. Scheduling unit-time tasks with precedence on mm processors is the special case with one unit type, mm units and unit delays. This gives the NP-hardness above.
  • To integer programming. Scheduling with unit limits and binding become 0-1 integer programs.
  • Register binding to interval coloring. For straight-line code, register binding is the coloring of an interval graph, which is chordal, so a greedy order by start time is optimal.
  • Related compiler problems. Scheduling is close to the instruction scheduling problem, and register binding is close to the register allocation problem. The difference is that high-level synthesis can choose how many units and registers to build.

Applications

  • Hardware accelerators. HLS tools turn C, C++ or SystemC kernels into hardware for FPGAs and ASICs, for signal processing, image processing and machine learning.
  • Design space exploration. Running the flow with many constraints gives the area and latency trade-off before any detailed design.
  • DSP datapaths. Filters and transforms with fixed data flow are the classic case, where the schedule is static.
  • Sequential optimization after HLS. The result is a register transfer design, which then goes through logic synthesis, retiming and technology mapping.

References

  1. Giovanni De Micheli, Synthesis and Optimization of Digital Circuits, McGraw-Hill, 1994, Chapter 4, Architectural Synthesis; Chapter 5, Scheduling Algorithms; Chapter 6, Resource Sharing and Binding
  2. Pierre G. Paulin and John P. Knight, Force-directed scheduling for the behavioral synthesis of ASICs, IEEE Transactions on Computer-Aided Design 8(6), 661 to 679, 1989, time-constrained and resource-constrained scheduling, and the differential equation example
  3. J. D. Ullman, NP-complete scheduling problems, Journal of Computer and System Sciences 10(3), 1975, the NP-completeness of scheduling unit-time tasks with precedence constraints on a given number of processors
  4. Michael R. Garey, David S. Johnson, Gary L. Miller and Christos H. Papadimitriou, The complexity of coloring circular arcs and chords, SIAM Journal on Algebraic and Discrete Methods 1(2), 216 to 227, 1980, the NP-completeness of coloring circular-arc graphs, which is register binding for values that live across a loop boundary

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