5.3.13 · D4Advanced Microarchitecture

Exercises — VLIW architectures

3,912 words18 min readBack to topic

Before we begin, one picture fixes the vocabulary we will reuse in every solution. It belongs to the whole page, but is referenced most directly by Level 1.

Figure — VLIW architectures

What the figure above shows (used by Level 1): four boxes in a row — the four slots of one VLIW instruction word — with a bracket over all of them saying "one instruction word = one cycle." The memory slot (Slot 2) is drawn in red because it is the single port that becomes the bottleneck in almost every problem on this page. Whenever a solution says "only one memory op per cycle," this is the picture to hold in your head: the red box can be filled by at most one load or store each row.

Levels 2–5 lean on a handful of loop-scheduling terms. We define all of them once, here, in plain words, before any of them is used in a problem.


Level 1 — Recognition

L1-Q1

A superscalar and a VLIW processor both issue 4 operations per cycle. Which one contains hardware to discover at runtime which operations are independent?

Recall Solution

The superscalar. Its out-of-order engine (wakeup/select, reservation stations, register renaming) finds parallelism in hardware every cycle. VLIW pushes that job to the compiler, so the VLIW hardware just executes the pre-packed word with no runtime dependency checking.

L1-Q2

In our 4-slot machine, how many memory (load/store) operations can a single instruction word contain? Why?

Recall Solution

Exactly one. There is a single memory port (Slot 2). Two loads in one cycle would need two ports the hardware does not have, so the compiler is forbidden from packing them together. (This is exactly the red box in the figure at the top of the page.)

L1-Q3

Fill in the blank: In VLIW, if the compiler cannot find parallel work for a slot, it must place a NOP there.

Recall Solution

A NOP. The slot still exists in the fixed-width word, so idle slots are spelled out explicitly. This is why low-parallelism code wastes bits.


Level 2 — Application

L2-Q1

Our 4-slot machine runs the dependent Fibonacci-style body from the parent note, scheduled as 3 real operations across 3 instruction words. Compute the slot utilisation.

Recall Solution

Total slots used . Real operations . The chain temp = fib, fib = fib + prev, prev = temp is fully serial, so only one slot per row can ever be busy.

L2-Q2

A loop body needs 6 memory operations and the machine has 1 memory port. Ignoring recurrences, what is the resource-constrained minimum initiation interval ? (Recall from the vocabulary box: = uses per iteration, = copies of the resource, and .)

Recall Solution

Here the only busy resource is memory, so (six memory ops per iteration) and (one port): Six memory operations through one port simply take six cycles, no matter how many ALU slots sit idle.

L2-Q3

A VLIW word is 128 bits (4 slots × 32 bits). A 100-operation program compiles to VLIW words that are on average 40% full — meaning each word carries on average real operations, where is the average number of real (non-NOP) operations packed per instruction word (so ). How many VLIW instruction words are emitted, and how many bits of NOP are wasted?

Recall Solution

With real operations per word, words needed words. Total slots ; real ops ; NOP slots . Wasted bits bits. More than half the emitted code is NOP — the classic VLIW code-bloat penalty.


Level 3 — Analysis

L3-Q1

Our loop body issues: 4 memory ops, 5 integer ALU ops, 1 branch. Machine: 1 memory port (), 2 integer ALUs (), 1 branch/FP unit (). Find and name the bottleneck resource.

Recall Solution

Evaluate per resource ( = uses per iteration, = copies available):

  • Memory:
  • Integer ALU:
  • Branch/FP: The memory port is the bottleneck. Even though there are more ALU ops in total, the two ALUs share the load, while the one port must serialise all four accesses.

L3-Q2

The same loop has one dependency cycle : a store-to-load recurrence with total latency cycles spanning iterations — meaning a load in this iteration needs a value that a store produced two iterations earlier, so the feedback reaches back 2 iterations. Combine with L3-Q1 to find the true .

Recall Solution

Recurrence bound (from the vocabulary box: = cycles to travel once around the feedback loop, = how many iterations back it reaches): Intuition: 6 cycles of work spread across 2 iterations means at least 3 cycles must separate each iteration start. Overall, applying : Resources still dominate; the recurrence, at 3, is not the binding constraint here.

The two floors and how they compete are shown below (this figure supports L3-Q2).

Figure — VLIW architectures

What the figure above shows (used by L3-Q2): three bars — the memory ResMII (4), the ALU ResMII (3), and the RecMII (3) — measured in cycles per iteration. The tallest bar (memory, in red) is the one that sets , exactly because is the max of all the floors. Pedagogically this is the whole Level-3 idea in one glance: don't average, don't add — find the tallest bar. The red arrow points to that winning bar to hammer home which constraint is binding.

L3-Q3

For the loop of L3-Q1/Q2, if we added a second memory port ( goes from 1 to 2), what would the new become? What does this reveal?

Recall Solution

New memory bound: . Recompute:

  • Memory: , ALU: , Branch: → new .
  • unchanged . Adding the port improved things only from 4 to 3. Now the ALU and the recurrence tie as the new limits — you cannot go below 3 without both more ALUs and a shorter dependency cycle. This is the analyst's lesson: relieve one bottleneck and the next one appears.

Level 4 — Synthesis

L4-Q1

Schedule this loop body on the 4-slot machine (1 mem, 2 ALU, 1 br/FP). Assume all latencies are 1 cycle and no cross-iteration recurrence:

L1: r1 = LD a[i]
L2: r2 = LD b[i]
A1: r3 = r1 + r2      (needs L1, L2)
A2: r4 = r3 * 2       (needs A1)
S1: ST c[i] = r4      (needs A2)

Produce a legal single-iteration VLIW schedule and give its cycle count.

Recall Solution

Constraints: one memory op per cycle (so L1, L2, S1 cannot share a cycle); a RAW (Read After Write) chain — a string of true data dependencies where each op reads what the previous wrote — namely L1,L2 → A1 → A2 → S1.

Slot layout:  [ ALU1        | ALU2 | MEMORY   | BR/FP ]
Cycle 1:      [ NOP         | NOP  | LD r1,a  | NOP   ]
Cycle 2:      [ NOP         | NOP  | LD r2,b  | NOP   ]
Cycle 3:      [ ADD r3,r1,r2| NOP  | NOP      | NOP   ]
Cycle 4:      [ MUL r4,r3,2 | NOP  | NOP      | NOP   ]
Cycle 5:      [ NOP         | NOP  | ST c,r4  | NOP   ]

5 cycles. The two loads must be serialised by the single port; the ADD waits for both; MUL waits for ADD; store waits for MUL. Utilisation — a serial chain does not benefit from wide issue.

L4-Q2

Now software-pipeline the L4-Q1 loop across iterations to raise throughput. The recurrence-free body has (2 loads + 1 store) and . What is the steady-state — the II in the repeating middle of the pipelined loop, after fill and before drain (see the vocabulary box) — and what limits it?

Recall Solution

Apply the two floors from the formula box: With no recurrence, . Therefore: So in steady state a new iteration launches every 3 cycles. Even though one iteration takes 5 cycles standalone (from L4-Q1), pipelining lets the memory port stream its 3 accesses per iteration back-to-back while ALU work from earlier iterations hides in the gaps. Throughput improves from to iterations per cycle. The single memory port is what limits it.

L4-Q3

Using from L4-Q2, how many cycles does the full 100-iteration loop take, if the pipeline prologue (fill) adds a fixed 4 extra cycles before steady state?

Recall Solution

Steady-state cost cycles. Add prologue: cycles. (Formally, total for large ; the prologue is amortised to nearly nothing over 100 iterations.)


Level 5 — Mastery

L5-Q1

A DSP kernel has this dependency cycle: acc = acc + (x[i] * h) where the multiply-add feeds itself every iteration. The multiply-add has latency 3 cycles, and the recurrence spans 1 iteration ( — this iteration's acc needs the immediately previous one). The kernel also issues 2 memory loads per iteration on a 1-port machine. Find , and explain which bound wins and why it cannot be beaten by adding hardware.

Recall Solution
  • (memory port).
  • . The recurrence wins. Crucially, adding memory ports or ALUs would drop but cannot lower : the accumulator at iteration genuinely needs the value from iteration , which takes 3 cycles to produce. This is an algorithmic limit, not a resource limit — no amount of extra silicon removes a true data dependence. (Only restructuring the algorithm — e.g. splitting into partial sums — can shorten the cycle.)

L5-Q2

Compare two schedules of the same loop with : Schedule A achieves ; Schedule B achieves because the compiler failed to rename a register, creating a false WAW dependency in a cycle. Quantify the throughput loss over 300 iterations, and state the one-line fix.

Recall Solution
  • Schedule A: cycles.
  • Schedule B: cycles.
  • Loss: cycles, i.e. Schedule B is slower. Fix: the compiler must rename the register so the WAW (write-after-write) becomes independent. WAW and WAR are false dependencies (see the data-dependence definition box) — they arise from reusing register names, not from real data flow — and in VLIW the compiler (not hardware) must eliminate them. Renaming restores .

L5-Q3 (capstone)

Design decision: You have a loop with , , and a recurrence with , . Your baseline machine has 1 memory port and 2 ALUs. You may add exactly one of: (a) a second memory port, or (b) a third ALU. Which upgrade lowers more, and by how much?

Recall Solution

Baseline:

  • Memory: ; ALU: ; so .
  • .
  • .

(a) Second memory port: memory ; ALU ; ; .

(b) Third ALU: memory (unchanged!); ALU ; ; ⇒ .

Answer: The second memory port (a) cuts from 6 to 3 — a 2× speedup. The third ALU changes nothing because the ALU was never the bottleneck (it sat at 2 while memory sat at 6). Always spend hardware on the binding resource.

The upgrade decision is exactly this "attack the tallest bar" logic (this figure supports L5-Q3):

Figure — VLIW architectures

What the figure above shows (used by L5-Q3): for each resource, a pair of bars — the baseline bound (left, black) and the bound after adding a second memory port (right). Only the memory bar moves, dropping from 6 (in red, because it was the binding tallest bar) down to 3; the ALU and recurrence bars stand still. This makes the capstone lesson visual: money spent on a non-tallest bar (the third ALU) would leave the red bar — and therefore — completely unchanged. You only speed up the loop by shrinking whatever is currently tallest.