Skip to content
BIASED

Instruction-level parallelism

Multiple issue, RAW/WAR/WAW dependences, register renaming, out-of-order and the ROB, speculation and Spectre, the x[i]=k*x[i] loop example.

Multiple issue

A classic pipeline starts ≤1 instruction per cycle. ILP is parallelism inside one stream. Multiple issue raises peak IPC: static (VLIW — compiler packs) or dynamic (superscalar — hardware picks each cycle).

Worked example. Make the in-order core of the baseline two-wide: it starts up to two instructions per cycle, in program order, each when its operands are ready. lw starts at 0 and mul at 3, as before. At cycle 6 sw gets its operand, and addi starts in the second slot of the same cycle. bne needs the new a0 and starts at 7, together with the next iteration’s lw. The next mul starts at 10. One iteration now takes 7 cycles instead of 9, IPC=0.71\mathrm{IPC} = 0.71IPC=0.71: doubling the width gained 29 %. The width is not the limit. The limit is that in program order, the next lw cannot start before mul and sw, although it does not depend on them.

Worked example. Start with a0 mapped to p10, a1 to p11 and a2 to p12, and free registers from p20 on. Renaming two iterations of the loop:

Worked example. One loop runs through this note. It multiplies every element of an integer array by a constant kkk, x[i] = k * x[i]:

Dependences and renaming

RAW (true) carries a value. WAR and WAW are name conflicts from register reuse. Register renaming maps each destination to a fresh physical register via a map table, leaving only RAW.

Worked example. In the loop, bne is taken in every iteration but the last, which a simple predictor learns at once. Without speculation, nothing after bne may enter the window until bne has executed and the front end, three stages deep in the model, has delivered the next instruction. The simulation gives 6.01 cycles per iteration without speculation and 2.54 with it. Speculation applies to other guesses too. A load can execute before an earlier store whose address is not yet known, on the bet that the addresses differ; if they turn out to be equal, the load and everything after it are replayed.

On the example loop: 9 cycles per iteration in order and one-wide, 7 in order and two-wide, 2.54 out of order with renaming, speculation and a 32-entry window.

Give the instructions toy latencies: 3 cycles for the load (a hit in the first-level cache), 3 for the multiply and 1 for everything else. A core that starts one instruction per cycle, in order, each as soon as its operands are ready, starts lw at cycle 0, mul at 3 (it needs t0 from the load), sw at 6 (it needs the product), addi at 7 and bne at 8. The next lw starts at 9. Five instructions take 9 cycles: IPC=5/9=0.56\mathrm{IPC} = 5/9 = 0.56IPC=5/9=0.56. In 4 of the 9 cycles, nothing new starts, because every instruction waits for the one before it, while addi and the next iteration’s lw do not depend on the multiplication at all.

Out-of-order and speculation

Out-of-order execution starts ops when operands are ready; the ROB retires in program order — precise exceptions and mispredict recovery. Speculation runs past unresolved branches; wrong path is squashed. Window ≈ width × latency. Worked loop x[i]=k*x[i]: 9 cycles/iter in-order 1-wide, 7 in-order 2-wide, 2.54 with renaming + speculation + 32-entry window. Spectre: squashed speculative loads still leave a cache footprint that leaks secrets. Multiple issue. A classic pipe starts ≤1 instruction per cycle. Static multiple issue (VLIW) packs independent ops at compile time; dynamic superscalar hardware picks a group each cycle within issue-width limits (often 4–8 on big cores). Peak IPC equals the width; sustained IPC is lower because of dependences and stalls. Dependences. RAW is true: producer → consumer. WAR and WAW are name conflicts from register reuse. Register renaming maps each destination to a fresh physical register via a map table, leaving only RAW. The ROB retires in program order for precise exceptions and mispredict recovery; execution itself may finish out of order when operands are ready. Worked loop x[i]=k*x[i]: about 9 cycles/iter on an in-order 1-wide machine, 7 on in-order 2-wide, 2.54 with renaming + speculation + a 32-entry window in the note’s model. Window size must cover width × latency so enough independent work stays visible. Spectre: squashed speculative loads can still leave a cache footprint; fences and retpolines are software mitigations, microcode and predictor hardening are hardware ones. ILP extracts parallelism from one thread; when one stream is not enough, the next topics add threads and data-parallel hardware. Issue width, rename width and retire width need not match; the narrowest stage caps throughput. A 6-wide machine that can only rename 3 µops/cycle retires at most 3 sustained. Memory-level parallelism (several outstanding cache misses) interacts with ILP: an OoO window that can see past one miss into independent work keeps the core busy while DRAM returns. When every instruction depends on the previous load (pointer chasing), the window cannot help — that is why graph codes look latency-bound on the roofline even on fat cores. Compiler scheduling still matters on in-order superscalars and VLIW DSPs: independent loads should be hoisted so their latency overlaps. On OoO cores the hardware recovers more, but locality and branch regularity remain software’s job. Next: Thread-level parallelism — many cores, coherence, Amdahl. # The loop of the worked example, x[i] = k * x[i]: five instructions per iteration. # Each entry: (operation, destination register, source registers, latency in cycles). BODY = [('lw', 't0', ['a0'], 3), # t0 = x[i] ('mul', 't0', ['t0', 'a2'], 3), # t0 = k * x[i] ('sw', None, ['t0', 'a0'], 1), # x[i] = t0 ('addi', 'a0', ['a0'], 1), # a0 =

Check your understanding

The same questions as in Pulse. Answers are shared between modes.

Full notes

Answers are saved on the server and tied to this browser until you sign in.