CS 152 Computer Architecture and Engineering
CS252A Graduate Computer Architecture Lecture 19 - Multithreading

Chris Fletcher
UC Berkeley, Spring 2026

Thread-Level Parallelism (TLP)

Multithreading: Interleaving Threads

How do we avoid dependences between adjacent instructions without bypassing or interlocks? Interleave 4 threads on a non-bypassed 5-stage pipeline:

t0t1t2t3t4t5t6t7t8
T1: LD x1, 0(x2)FDXMW
T2: ADD x7, x1, x4FDXMW
T3: XORI x5, x4, 12FDXMW
T4: SD 0(x7), x5FDXMW
T1: LD x5, 12(x1)FDXMW

Simple Multithreaded Pipeline

Costs

Thread Scheduling Policies

PolicyExampleHow
Fixed interleaveCDC 6600 peripheral processors (1964), first MT hardwareEach of N threads gets 1 slot every N cycles; bubble if not ready. 10 virtual I/O processors on a 100 ns pipeline: one instruction per 1,000 ns each
Software-controlledTI ASC PPUs (1971)OS allocates S slots among N threads; hardware cycles over them
Hardware-controlledDenelcor HEP (1982)Hardware tracks ready threads, picks by priority

Tera / Cray MTA

Coarse-Grain Multithreading

Check Your Understanding

1. Non-bypassed 6-stage pipeline F D R X M W (read in R, write in W). Minimum threads for round-robin with no RAW hazards?
4. An instruction entering at t0 writes at t5; the thread's next instruction enters F at t4 and reaches R at t6.
2. How does coarse-grain differ from fine-grain MT, and why does a short pipeline help coarse-grain?
Fine-grain switches every cycle; coarse-grain runs one thread until a long stall. A short pipeline loses few cycles when flushed on a switch.

Superscalar Machine Efficiency

  • Vertical waste: cycle with zero issues
  • Horizontal waste: cycle with some, but < W, issues
  • Vertical MT removes vertical waste, not horizontal
  • CMP (two 2-wide cores) cuts horizontal waste but caps a thread at 2 IPC
issue width → vertical horiz. time →

Simultaneous Multithreading (SMT)

Commercial SMT

SMT Performance and the Icount Policy

SMT and Security

Comparing Five Execution Styles

SuperscalarFine-grainedCoarse-grainedCMPSMT 4 issue slots × 8 cycles; colors = threads; white = wasted slots

Check Your Understanding

1. Define vertical and horizontal waste. Which does vertical multithreading fail to remove?
Vertical: a cycle with zero issues. Horizontal: a cycle with some but fewer than W issues. Vertical MT fails to remove horizontal waste: only one thread issues per cycle.
2. Why does Icount fetch from the thread with the fewest instructions in flight?
A stalled thread piles up instructions in shared queues; favoring the fewest-in-flight thread stops it from clogging them and starving fast threads.