Lecture 17: VLIW
Section 1: Superscalar Scaling Limits and the VLIW Philosophy
We have built a remarkably capable machine: virtual memory with hardware TLBs, register renaming, out-of-order issue, speculative load-store disambiguation, and tournament/trace-cache branch speculation. Now step back and ask a brutal hardware engineering question: How does this out-of-order control logic scale as we make the processor wider?
Suppose our processor has Issue Width W (issuing W instructions per cycle) and each instruction has an active Lifetime L cycles in the machine:
- Every newly issued instruction in the W-wide Issue Group must check dependencies against all W \times L previously issued instructions still active in the machine.
- Therefore, the dependency-checking and wakeup hardware grows proportionally to: \text{Control Hardware Complexity} \propto W \times (W \times L) = W^2 \cdot L Let’s unpack this scaling law:
- In an in-order machine, L reflects fixed pipeline execution latencies, and checks happen at issue via interlocks or a scoreboard.
- In an out-of-order machine, L also includes the entire time instructions wait inside the instruction window and ROB, and checks require broadcasting tags to all waiting instructions at completion!
- Worse still: as we increase issue width W, we must use a larger instruction window to find enough independent instructions to keep all W functional units busy—which increases lifetime L! Because L grows along with W, out-of-order control logic grows faster than W^2—roughly as \sim W^3!
Look at the die photo of the MIPS R10000 (1995): a huge portion of the silicon area (IF inst, IF addr, Free List, Grad Unit, Address Queue, Integer Queue, FP Queue, Register Rename) is pure Control Logic dedicated to figuring out what can run in parallel—not caches (Instruction Cache, Data Cache) and not actual compute (Integer Datapath, FP Datapath, FP Mult)!
And look at the absurdity of the Sequential ISA Bottleneck:
- The programmer writes sequential source code (
a = foo(b); for (i=0; ...)). - The superscalar compiler analyzes the code, builds a dependency graph, finds independent operations, and schedules them—only to flatten them back into a sequential machine code stream!
- At runtime, the superscalar processor must burn huge hardware power and \sim W^3 area to re-check instruction dependencies and reconstruct the exact parallel schedule the compiler already knew!
The VLIW (Very Long Instruction Word) Solution
Why not let the compiler tell the hardware explicitly which operations execute in parallel? That is VLIW—also called SPIE (Static Parallel Instruction Execution) by pioneer Joseph A. Fisher (who also coined “memory disambiguation” for the unknown memory address problem).
In a VLIW architecture:
- Multiple operations are packed into one very long instruction word—for example, a 6-slot instruction: [\ \text{Int Op 1}\ |\ \text{Int Op 2}\ |\ \text{Mem Op 1}\ |\ \text{Mem Op 2}\ |\ \text{FP Op 1}\ |\ \text{FP Op 2}\ ]
- Each operation slot maps to a fixed functional unit (e.g., two 1-cycle Integer Units, two 3-cycle Load/Store Units, two 4-cycle Floating-Point Units).
- Constant operation latencies are specified in the ISA.
- The architecture guarantees two rules by compiler contract:
- Parallelism within an instruction \implies no cross-operation RAW checks needed in hardware.
- No data use before data is ready \implies no hardware data interlocks or scoreboards needed!
All of that \sim W^3 issue queues, CAM wakeup logic, and register renaming disappears, replaced by the VLIW compiler, which must:
- Schedule operations to maximize parallel execution.
- Guarantee intra-instruction parallelism.
- Schedule around known latencies to avoid data hazards—typically inserting explicit NOPs wherever data isn’t ready yet.
Historical milestones showed how wide VLIWs could go: the FPS AP120B (1976) was the first commercial wide-instruction array processor (relying on hand-coded software pipelining and loop unrolling); the Multiflow Trace (1987) packed up to 28 operations into a 1024-bit instruction word using trace scheduling; and the Cydrome Cydra-5 (1987) encoded 7 operations into a 256-bit word with a rotating register file.
[Editor Note: removed title slide, previous-lecture recap slide, and Fisher’s personal naming/grant-proposal anecdote.]
✎ Check Your Understanding
Why does out-of-order superscalar control logic grow faster than W^2 (closer to \sim W^3) as issue width W increases? Answer: Each of the W issued instructions must check against W \times L in-flight instructions (\propto W^2 L), and wider machines require deeper instruction windows to uncover enough ILP, causing lifetime L to grow alongside W.
What two architectural guarantees must a VLIW compiler satisfy so hardware can eliminate dependency-checking and interlock logic? Answer: All operations packed into the same VLIW instruction must be mutually independent (no cross-op RAW hazards), and no instruction may read an operand before its producer’s fixed architectural latency has elapsed.
Section 2: Static Loop Scheduling — Loop Unrolling, Software Pipelining, and Trace Scheduling
Since a VLIW processor has no dynamic hardware scheduler, all performance comes from the compiler’s static scheduling. Let’s trace a concrete loop step-by-step on our 6-slot VLIW machine (Int1, Int2, M1, M2, FP+, FPx), assuming Int = 1 cycle, Mem (fld/fsd) = 3 cycles, and FP (fadd) = 4 cycles.
Consider:
for (i = 0; i < N; i++)
B[i] = A[i] + C;Compiled into scalar-style assembly (f0 holds C, x1 points to A, x2 points to B, x3 is the loop bound):
loop: fld f1, 0(x1)
add x1, 8
fadd f2, f0, f1
fsd f2, 0(x2)
add x2, 8
bne x1, x3, loop
Attempt 1: Naive VLIW Scheduling
Look at what happens when we schedule one iteration directly onto the 6-slot VLIW grid:
- Cycle 1:
Int1: add x1,M1: fld(fldtakes 3 cycles, sof1is ready at Cycle 4). - Cycles 2–3: All 6 slots are empty (NOPs)! Nothing else is ready.
- Cycle 4:
FP+: fadd(faddtakes 4 cycles, sof2is ready at Cycle 8). - Cycles 5–7: All 6 slots are empty (NOPs)!
- Cycle 8:
Int1: add x2,Int2: bne,M1: fsd.
Throughput: 1 fadd / 8 cycles = 0.125 FLOPS/cycle! Out of 8 \times 6 = 48 available operation slots, we used only 6!
Attempt 2: Loop Unrolling (4 Ways)
To fill those empty latency cycles, the compiler unrolls the inner loop to perform 4 iterations at once (i += 4, handling non-multiples of 4 with a small cleanup loop):
- Cycle 1:
M1: fld f1 - Cycle 2:
M1: fld f2 - Cycle 3:
M1: fld f3 - Cycle 4:
Int1: add x1,M1: fld f4,FP+: fadd f5(f1just arrived after 3 cycles!) - Cycle 5:
FP+: fadd f6 - Cycle 6:
FP+: fadd f7 - Cycle 7:
FP+: fadd f8 - Cycle 8:
M1: fsd f5(f5just arrived after 4 cycles!) - Cycle 9:
M1: fsd f6 - Cycle 10:
M1: fsd f7 - Cycle 11:
Int1: add x2,Int2: bne,M1: fsd f8
Throughput jumps to 4 fadds / 11 cycles = 0.36 FLOPS/cycle. Better—but notice why we are still wasting 7 of the 11 cycles on FP+: we wait for all 4 loads and adds to finish before starting the next batch of 4 loads!
Attempt 3: Software Pipelining
Why wait to finish iteration k’s stores before starting iteration k+1’s loads? Software pipelining overlaps operations from different loop iterations so the M1, M2, and FP+ units stay busy simultaneously!
Look at our 4-way unrolled loop after software pipelining:
- Prolog (8 cycles): Fills the pipeline—cycles 1–4 issue
fld f1..f4for batch 0; cycles 5–8 computefadd f5..f8for batch 0 while simultaneously loadingfld f1..f4for batch 1! - Steady-State
loop:(4 cycles!): Every single cycle of the steady-state loop runs three batches at once:- Cycle 1 of loop:
M1: fld f1(batch k+2) |M2: fsd f5(batch k) |FP+: fadd f5(batch k+1) - Cycle 2 of loop:
M1: fld f2|M2: fsd f6|FP+: fadd f6 - Cycle 3 of loop:
Int2: add x2|M1: fld f3|M2: fsd f7|FP+: fadd f7 - Cycle 4 of loop:
Int1: add x1|Int2: bne|M1: fld f4|M2: fsd f8|FP+: fadd f8
- Cycle 1 of loop:
- Epilog (5 cycles): Drains the final
fadds andfsds after the loop exits.
Look at the steady-state throughput: 4 fadds / 4 cycles = 1.0 FLOPS/cycle—an 8\times speedup over naive scheduling, keeping FP+ 100% utilized!
Let’s see how a compiler writes a basic software-pipelined loop for the simpler 1-per-iteration case (fld f0, 0(x1) \to fadd f4, f0, f2 \to fsd f4, 0(x1) \to addi x1, x1, -8 \to bne):
- Startup: Run the front of the first two iterations (
flditer 0,fadditer 0,flditer 1,addi x1, x1, -16) to prime the registers. - Main Loop (
Loop'): Each iteration executes three different logical iterations in one pass—store iter i (fsd f4, 16(x1)), add iter i+1 (fadd f4, f0, f2), and load iter i+2 (fld f0, 0(x1)), followed byaddiandbne. (Noticefsdcomes beforefaddandfldin the loop body so it stores the oldf4beforefaddoverwritesf4, andfaddreads the oldf0beforefldoverwritesf0!) - Winddown: Finish the leftover tail (
fsditer N-1,fadditer N,fsditer N).
Compare Software Pipelining vs. Loop Unrolling: Loop unrolling pays startup and wind-down ramp overhead on every unrolled iteration (sawtooth utilization), whereas software pipelining pays startup/wind-down costs only once per loop, keeping execution flat at peak throughput!
What If There Are No Loops? Trace Scheduling
Real programs aren’t just dense numerical loops; control-flow-intensive irregular code has frequent branches that shrink each basic block to only a handful of instructions, leaving little ILP inside any single block.
To extract parallelism across branches in VLIW, Trace Scheduling (Fisher & Ellis) uses profiling feedback or compiler heuristics to pick a string of basic blocks—a trace—representing the most frequent branch path through the control-flow graph. The compiler treats the entire trace as one giant basic block and schedules all of its operations in parallel at once! Whenever an operation moves above or below a side branch, the compiler generates extra fixup (compensation) code along the off-trace branch paths to preserve correctness if execution ever leaves the trace.
✎ Check Your Understanding
In the steady-state software-pipelined
Loop'above (fsd f4, 16(x1),fadd f4, f0, f2,fld f0, 0(x1)), why doesfsdappear beforefaddandfaddbeforefld? Answer: Becausefsdmust read the previous iteration’s sum inf4beforefaddoverwritesf4, andfaddmust read the previous iteration’s loaded value inf0beforefldoverwritesf0—each instruction belongs to a different logical loop iteration (i, i+1, i+2).Why does Trace Scheduling require “fixup code” on branches that exit the trace? Answer: Because scheduling the trace as one block moves instructions across branch boundaries; if runtime execution takes an off-trace branch, fixup code must execute any skipped operations or undo speculative side effects.
Section 3: Classic VLIW Pitfalls, EPIC (IA-64), Rotating Registers, and Speculation
Despite its hardware simplicity, “Classic” VLIW suffered five major practical problems:
- Object-code compatibility: Because hardware latencies and functional unit counts are baked into the instruction encoding, you must recompile all code for every new machine, even two models in the same processor generation!
- Object code size: Empty NOP slots waste instruction memory and I-cache capacity, while loop unrolling and software pipelining replicate code. (Three encoding schemes tried to reduce unused fields: storing a compressed format in memory and expanding on I-cache refill as in the Multiflow Trace—which complicates branch target addressing; marking explicit parallel groups as in TI TMS320C6x DSPs and Intel IA-64; or providing a single-op VLIW instruction like Cydra-5 UniOp.)
- Variable-latency memory operations: Caches and memory bank conflicts introduce latency variability that the compiler cannot predict statically.
- Knowing branch probabilities: Trace scheduling requires profiling runs as a heavy extra step in the software build process.
- Statically unpredictable branches: The optimal schedule changes depending on which branch path is taken at runtime.
Intel Itanium and EPIC (IA-64)
To bring VLIW into mainstream enterprise computing while fixing object-code compatibility, Intel and HP introduced EPIC (Explicitly Parallel Instruction Computing—essentially VLIW) with the IA-64 ISA (implemented in Merced, McKinley, and up to the 8-core, 2-way multithreaded Poulson fetching two 128-bit bundles / 6 instructions per cycle and executing up to 12 instructions/cycle).
How did IA-64 achieve object-code compatibility? Instead of locking operations to fixed machine slots, IA-64 packs three 41-bit instructions plus a 5-bit Template into a 128-bit instruction bundle: [\ \text{Instruction 2}\ |\ \text{Instruction 1}\ |\ \text{Instruction 0}\ |\ \text{Template}\ ] The Template bits encode stop bits marking groups of mutually independent instructions (which can span across bundle boundaries, e.g., group i spanning bundle j-1, bundle j, and bundle j+1). A narrower machine executes a large group over multiple cycles, while a wider machine executes it in one cycle—preserving binary compatibility! IA-64 also provided massive register state: 128 64-bit GPRs, 128 64/80-bit FPRs, and 64 1-bit Predicate Registers.
Three Hardware Features to Help the Compiler
To overcome VLIW’s loop-size, branch, and memory-latency barriers, Cydra-5 and IA-64 introduced three clever architectural features:
Rotating Register Files (for Software Pipelining): Scheduled software-pipelined loops consume lots of registers and duplicate prolog/epilog code. Solution: Add a Rotating Register Base (
RRB) register that points to the base of the current iteration’s register set: \text{Physical Register} = \text{Logical Register Specifier} + \text{RRB} On each loop branch (bloop),RRBdecrements by 1, automatically allocating a fresh set of physical registers for the new iteration without duplicating code! (Usually the register file is split into rotating and non-rotating registers.)Worked Example: Suppose a loop has a 3-cycle load and a 4-cycle
fadd. Look at how the compiler encodes latencies directly in the register specifier differences: \texttt{ld f1, ()} \quad|\quad \texttt{fadd f5, f4, ...} \quad|\quad \texttt{sd f9, ()} \quad|\quad \texttt{bloop} Noticef4 - f1 = 3(load latency) andf9 - f5 = 4(faddlatency)! Let’s traceRRBcounting down from8to1:- Iteration at
RRB = 8:ldwritesP(1+8) = P9. (faddreadsP12, writesP13;sdreadsP17.) - Three iterations later (
RRB = 5):ldwritesP6, andfaddreadsP(4+5) = P9—receiving the exact valueldstarted loading 3 cycles earlier! Meanwhile,faddwritesP(5+5) = P10. - Four iterations later (
RRB = 1):sdreadsP(9+1) = P10—storing the exact sumfaddstarted computing 4 cycles earlier!
- Iteration at
Predicated Execution (for Hard-to-Predict Branches): To eliminate mispredicted branches, almost every IA-64 instruction can execute conditionally under a 1-bit predicate register (becoming a
NOPif its predicate is false). Anif-then-elsediamond spanning four basic blocks (b0: br a==b, b2,b1: else,b2: then,b3: join) collapses into one basic block:Inst 1 Inst 2 p1, p2 <- cmp(a == b) (p1) Inst 3 || (p2) Inst 5 (p1) Inst 4 || (p2) Inst 6 Inst 7 Inst 8Predication removes >50\% of branches on average (Mahlke et al.), Warning: it complicates bypassing! (If
Inst 3andInst 5both target the same register under mutually exclusive predicates, hardware must check predicates before bypassing.)Control Speculation (
Load.s/Chk.s) and Data Speculation (Load.a/Load.c):- Control Speculation: Moving a
Load r1above a branch (br a==b, b2) is illegal normally because if the branch isn’t taken,Load r1might dereference a null pointer and cause a spurious page fault! IA-64 solves this by hoisting a speculative load (Load.s r1) above the branch:Load.snever raises an exception, instead setting a “poison” bit (NaT) on destination registerr1. In the load’s original home block,Chk.s r1checks whether the poison bit is set and jumps to fixup code only if the branch actually took that path. - Data Speculation: Moving
Load r1above an earlierStoreis illegal if their pointers might alias. IA-64 hoists an advanced load (Load.a r1) above theStore, recording its address in an associative address check table. Any interveningStorechecks the table and invalidates matching addresses. In the original location,Load.cchecks whetherr1’s entry is still valid (and not evicted); if invalidated or missing, it jumps to fixup code to reload. (Note: this requires associative CAM hardware in the address check table—creeping right back toward superscalar complexity!)
- Control Speculation: Moving a
Limits of Static Scheduling
Ultimately, despite massive engineering effort, VLIW failed in general-purpose computing—as Donald Knuth famously observed of Itanium, “the wished-for compilers were basically impossible to write,” and Intel formally discontinued Itanium in 2019. Statically unpredictable branches, variable cache-miss latencies, code size explosion, and compiler complexity meant complex VLIW machines approached in-order superscalars in hardware complexity with no advantage on large, irregular applications. However, VLIW has been highly successful in the embedded DSP market, where simpler VLIWs run in constrained environments with predictable loops and deterministic memory!
[Editor Note: removed title slide and acknowledgements slide.]
✎ Check Your Understanding
In a Rotating Register File, suppose a
mulhas a 5-cycle latency and the loop executesmul f2, ...followed byadd ..., f7, ...withRRBdecrementing by 1 each cycle. IfRRB = 10whenmulexecutes, what physical register doesmulwrite, and what willRRBbe whenaddreads that exact physical register? Answer: AtRRB = 10,mulwritesP(2 + 10) = P12. Five cycles later,RRB = 5, andaddreadsP(7 + 5) = P12.Why does IA-64’s
Load.sset a “poison” bit instead of immediately raising a page fault or segmentation fault? Answer: BecauseLoad.swas hoisted speculatively above a branch; if that branch turns out not to enter the load’s original block, the exception would have been spurious. Deferring the check toChk.sin the home block ensures exceptions trigger only when truly needed.