Exam trainer

249 questions in the style of the written exam, from 38 lessons: exercises with the full table or computation, open questions and quizzes, each with a model answer and a commentary.

Near its end, every lesson has a section "Exam-style questions". Here those questions from all the lessons are collected unchanged, with the same model answers and the same commentary.

First what is known about the real exam, then how to practise, then the questions.

How the real exam works

Everything in this section comes from the course page of AY 2025-26 and from the three official exam texts of 15 July 2024, 10 June 2025 and 22 June 2026. What they do not say, this section does not say.

Two ways to pass

This page trains you for the written exam of Way 1.

The written exam

How the 33 points were split in the three official texts.
TextPractice part · 15Theory part · 18
15 July 2024three exercises, 5 points eachtwo open questions, 5 points each; quizzes, 8 points
10 June 2025three exercises, 5 points eachtwo open questions, 5 points each; quizzes, 8 points
22 June 2026EX1 Tomasulo, EX2 VLIW, EX3 directory protocol, 5 points eachQ1, one open question with eight sub-points, 8 points; quizzes, 10 points

The course page of AY 2025-26 lists three dates for the summer session 2026: 22 June, 17 July and 3 September.

How to practise

Practise the way the paper is taken: closed books, only your own A4 page, a pen and a clock. The exam is written, so write every answer out on paper before you open the model answer — recognising a good answer and producing one are two different skills.

Keep an eye on the clock: the paper gives 1 h 30 min for 33 points, about 2.7 minutes a point — some 14 minutes for a 5-point exercise and 22 for an 8-point question.

A question that comes from a past paper, or follows the form of one, names the paper in its wording, as in "(Exercise 1, 15 July 2024)". Under every model answer a commentary says what a complete answer contains and where the usual traps are. When your answer does not match, follow "open in the lesson" above the box: the lesson explains the rule behind every cell, and the commentary sometimes refers to a table or a widget there.

For a mock paper, press "10 random questions" below and write all the answers before you open any model answer. Answers on this page are not saved: after a reload every question is clean again, ready for a second round a week later.

Questions

The questions follow below, module by module and in lesson order. A module opens with its button, or with its line in the list at the top of the page. Untick a question type or a module to leave it out. The button "10 random questions" assembles a mini exam from what is still ticked; every new press first takes questions that have not been in a selection yet.

Question type
Module

Matching the filters: 249 of 249

Module 1 · Pipelining and performance

19 questions · Notes, chapters 1 and 4 · the RISC-V pipeline, hazards, forwarding, the metrics every exercise ends with

Lesson 1 · The assembly line in silicon

Lesson 1 · The assembly line in silicon · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by a pipelined RISC-V processor:

  1. Pipelining of the instruction execution
  2. The five-stage organisation IF / ID / EX / MEM / WB
  3. The pipeline registers
  4. Separate instruction and data memories
Show model answer

1. Pipelining is an implementation technique that overlaps the execution of consecutive instructions: the execution is divided into stages and each stage works on a different instruction in the same clock cycle. The latency of one instruction does not change (k cycles), but once the pipeline is full one instruction completes per cycle, so the throughput grows by up to k times; n instructions take k + n − 1 cycles instead of nk, and the clock period becomes the time of one stage instead of a whole instruction. Costs: a fill of k − 1 cycles, pipeline-register overhead, and hazards (structural, data, control) that insert stalls.

2. The five stages correspond to five resources used once by every instruction: IF fetches from the instruction memory and computes PC + 4; ID decodes and reads the two source registers (two read ports); EX uses the ALU for the operation, the address or the branch comparison; MEM accesses the data memory (loads and stores only); WB writes the destination register (one write port). Because each stage uses a different resource, five instructions can be in flight without conflicts; every instruction traverses all five stages (idle stages are not skipped), so completion is in order and at most one instruction writes per cycle.

3. The pipeline registers IF/ID, ID/EX, EX/MEM and MEM/WB sit between the stages and are written on every clock edge. They hold everything an in-flight instruction still needs: the instruction and PC + 4 (IF/ID); the operand values, the immediate, the destination register number and the control signals for EX, MEM and WB (ID/EX); the ALU result or address, the store data, the branch target, rd and the MEM/WB control (EX/MEM); the loaded data or ALU result, rd and the WB control (MEM/WB). Benefits: they isolate the stages so that the clock period equals one stage; the control is decoded once and carried along; and they are the source of the values used by forwarding.

4. With a single memory, the instruction fetch of one instruction and the data access of another (IF and MEM of two different instructions in the same cycle) would compete for the memory port: a structural hazard with a stall every time. Separate instruction and data memories (in practice separate L1 caches) give the two stages their own port, so the hazard is designed away. It is a property of the implementation, not of the instruction set.

The 2026 paper asks its 8-point question in exactly this form: "Explain the main concepts and benefits of each one of the following techniques", with a few lines per sub-point. Fill them with the key words — overlap, throughput versus latency, k + n − 1, one resource per stage, the four register names with their contents, "structural hazard" for the memory — and with a cost next to each benefit. A sub-point that only says what the thing is called says nothing.

Lesson 1 · The assembly line in silicon · question 2 of 6 · open in the lesson

Consider the five-stage RISC-V pipeline (IF, ID, EX, MEM, WB) with one clock cycle per stage and no hazards (ideal case). Complete the pipeline diagram for one iteration of the following loop, then give the total number of clock cycles and the execution time with a 2 ns clock. How many cycles would the same five instructions take on a non-pipelined machine that executes the five stages one after another?

LOOP:  LD    F2, 0(R1)
       FADD  F4, F2, F0
       SD    F4, 0(R1)
       ADDUI R1, R1, 8
       BNE   R1, R2, LOOP
Show model answer
C1C2C3C4C5C6C7C8C9
I0 LD F2, 0(R1)IFIDEXMEMWB
I1 FADD F4, F2, F0IFIDEXMEMWB
I2 SD F4, 0(R1)IFIDEXMEMWB
I3 ADDUI R1, R1, 8IFIDEXMEMWB
I4 BNE R1, R2, LOOPIFIDEXMEMWB

Total clock cycles = k + n − 1 = 5 + 5 − 1 = 9 (equivalently IC + 4 = 5 + 4 with no stalls); execution time = 9 × 2 ns = 18 ns. Non-pipelined: 5 × 5 = 25 cycles = 50 ns. Speedup of the pipeline = 50 / 18 = 2.78.

Every row has all five stages, the idle ones included — a row that stops at EX for the FADD or at MEM for the SD is wrong. The diagonal must shift by exactly one column per instruction, and the cycle count must be read from the last WB (C9), not guessed as "5 instructions, 5 cycles".

Lesson 1 · The assembly line in silicon · question 3 of 6 · open in the lesson

An ideal five-stage pipeline with a 2 ns clock executes 100 independent instructions. How many nanoseconds does the execution take?

Show model answer
\[ T_{\text{pipe}} = (k + n - 1)\,T \] \[ = (5 + 100 - 1) \times 2 = 208 \text{ ns} \]

Against 1000 ns without the pipeline: a speedup of 1000 / 208 = 4.81.

The tempting wrong answer is 200 ns (one instruction per cycle, no fill). The four extra cycles are the fill of the five-stage pipeline, the "+4" of the course's cycle formula.

Lesson 1 · The assembly line in silicon · question 4 of 6 · open in the lesson

A non-pipelined processor executes one instruction in 10 ns. A designer splits that work evenly into 10 pipeline stages, but every stage adds 0.5 ns of pipeline-register overhead to the clock period. What is the maximum speedup over the non-pipelined processor, for a very long program of independent instructions? Give two decimals.

Show model answer

Stage time = 10 / 10 = 1 ns; clock period = 1 + 0.5 = 1.5 ns. For n → ∞ the pipeline completes one instruction per clock period, so the speedup tends to 10 / 1.5 = 6.67 — not 10.

This is the "why deeper is not always faster" question. The expected reasoning is: ceiling = time of one instruction / clock period, and the clock period = slowest stage + register overhead. A five-stage pipeline with the same overhead has a ceiling of 10 / 2.5 = 4, so the deeper pipeline is still better here — but by 1.67×, not 2×.

Lesson 1 · The assembly line in silicon · question 5 of 6 · open in the lesson

Which of the following statements about an ideal five-stage pipeline is correct? (Single answer)

  • Each instruction completes in one clock cycle. Each instruction still takes five cycles from fetch to write-back; only the rate of completion changes.
  • Once the pipeline is full, one instruction completes per cycle, but each instruction still takes five cycles. Throughput of one per cycle, latency of five cycles.
  • The latency of each instruction is reduced to one fifth. The latency is unchanged (slightly larger with the register overhead). Pipelining improves throughput, not latency.
  • Five instructions always take exactly five cycles. They take 5 + 5 − 1 = 9 cycles; the first instruction must traverse the whole pipeline before anything completes.
Show model answer

Answer 2. The pipeline overlaps instructions: the time of one instruction is still k cycles, but a new one completes every cycle once the pipeline is full, so n instructions take k + n − 1 cycles.

The quiz tests the latency/throughput distinction — the first bullet of the notes' p. 14. Options 1 and 3 are the same misconception in two forms.

Lesson 1 · The assembly line in silicon · question 6 of 6 · open in the lesson

Which of the following statements are true for the basic five-stage RISC-V pipeline? (Multiple answers)

  • An ALU instruction passes through the MEM stage without using it. The stage is traversed idle, so that every instruction keeps a five-cycle latency.
  • A store skips the WB stage and completes one cycle earlier than a load. A store has nothing to write in WB but still spends the cycle there; no stage is skipped.
  • The destination register number travels in the pipeline registers together with the instruction. rd is copied from ID/EX to EX/MEM to MEM/WB, because the instruction word is no longer available when WB happens.
  • The branch updates the PC in the WB stage. The comparison is in EX and the PC is loaded in MEM (basic pipeline); optimised pipelines decide in ID.
  • The value loaded by a load instruction is available only at the end of its MEM stage. EX computes the address, MEM reads the memory; the value does not exist before the end of MEM.
Show model answer

Answers 1, 3 and 5.

Options 2 and 4 are the two claims of the notes corrected in this lesson (pp. 16–17). The 2026 paper uses "Multiple Choice – Multiple answer" quizzes of exactly this shape.

Lesson 2 · When the line jams: hazards and forwarding

Lesson 2 · When the line jams: hazards and forwarding · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used in a pipelined RISC-V processor:

  1. The split-cycle register file (write in the first half of the clock cycle, read in the second half).
  2. The forwarding paths EX/EX, MEM/EX and MEM/MEM and the forwarding unit.
  3. The load-use hazard and the hazard detection unit.
  4. Static versus dynamic solutions to RAW data hazards.
Show model answer

1. The register file is written in the first half of a clock cycle and read in the second half, so an instruction in WB and an instruction in ID exchange a value within the same cycle. Benefit: a consumer three instructions after its producer needs no stall and no extra datapath; without it a consumer at distance 1, 2 or 3 would pay one more stall. It is the "read and write at the same address in the same cycle" assumption of the exercises.

2. Forwarding (bypassing) feeds a result to a dependent instruction from the pipeline register where it already sits, instead of waiting for WB and a register-file read. EX/EX takes the ALU result from EX/MEM into the ALU input (ALU producer at distance 1); MEM/EX takes a value from MEM/WB into the ALU input (ALU producer at distance 2, or a loaded value); MEM/MEM takes a loaded value from MEM/WB into the data-memory write input (load followed by a store). The forwarding unit compares the destination register numbers in EX/MEM and MEM/WB with the source numbers in ID/EX, gives priority to the newest result and ignores R0. Benefit: all ALU-to-ALU stalls disappear; cost: multiplexers and comparators.

3. A load's value exists only at the end of its MEM stage, so an instruction that uses it immediately would need it in the same cycle: one stall is unavoidable even with forwarding, after which the MEM/EX path delivers the value. The hazard detection unit, in ID, detects the case (the instruction in EX is a load whose destination equals a source the instruction in ID needs in EX; the data register of a store is exempt, since the MEM/MEM path serves it in MEM) and inserts the bubble: it holds the PC and the IF/ID register and zeroes the control signals entering ID/EX. Benefit: correctness with the minimum delay; the compiler can fill the slot with an independent instruction.

4. Static solutions are applied by the compiler: nop insertion (simple, wastes the same cycles as a stall and inflates code and instruction count) and instruction scheduling (fills the gap with independent instructions, free when they exist). Dynamic solutions are applied by the hardware at run time: stalling through interlocks (bubbles, no code growth) and forwarding (the preferred one). Benefit of dynamic solutions: the code is independent of the pipeline depth; benefit of static ones: no detection hardware and the ability to fill slots forwarding cannot remove.

This is the shape of the 8-point question of the June 2026 paper: a few lines per sub-point, each with the concept, the mechanism and the benefit. The examiner is checking the vocabulary (pipeline registers, ID/EX, EX/MEM, MEM/WB, bypass, interlock, bubble), the cost next to the benefit, and the two facts that separate a good answer from a vague one: the forwarding unit compares register numbers, and load-use keeps one stall.

Lesson 2 · When the line jams: hazards and forwarding · question 2 of 6 · open in the lesson

Consider the 5-stage RISC-V pipeline (IF, ID, EX, MEM, WB) with a register file that is written in the first half of the clock cycle and read in the second half. Consider the following code:

I0   LD   R2, 0(R1)
I1   ADD  R3, R2, R4
I2   SUB  R5, R3, R6
I3   SD   R5, 8(R1)
I4   OR   R7, R2, R5

(a) Complete the cycle-by-cycle table without forwarding. (b) Complete it with the EX/EX, MEM/EX and MEM/MEM forwarding paths. For each case give the stall cycles, the total clock cycles (IC + 4 + stalls) and the CPI. (c) Compute the speed-up of (b) over (a).

Show model answer

(a) Without forwarding. RAW on R2 (I0 to I1), R3 (I1 to I2) and R5 (I2 to I3), all at distance 1: 2 stalls each. I4 reads R2 and R5 in cycle 12, both already written: 0 stalls.

123456789101112131415
I0 LD R2, 0(R1)IFIDEXMEMWB
I1 ADD R3, R2, R4IFIDstallstallEXMEMWB
I2 SUB R5, R3, R6IFIFIFIDstallstallEXMEMWB
I3 SD R5, 8(R1)IFIFIFIDstallstallEXMEMWB
I4 OR R7, R2, R5IFIFIFIDEXMEMWB

Stalls = 6; clock cycles = 5 + 4 + 6 = 15 (the cycle of the last WB); CPI = 15 / 5 = 3.0.

(b) With forwarding. I0 to I1 is a load-use pair: 1 stall, then R2 through the MEM/EX path in cycle 5. I1 to I2: EX/EX path in cycle 6, 0 stalls. I2 to I3: R5 forwarded to the store through the EX/EX path in cycle 7, 0 stalls. I4: R5 through the MEM/EX path in cycle 8, R2 from the register file, 0 stalls.

12345678910
I0 LD R2, 0(R1)IFIDEXMEMWB
I1 ADD R3, R2, R4IFIDstallEXMEMWB
I2 SUB R5, R3, R6IFIFIDEXMEMWB
I3 SD R5, 8(R1)IFIDEXMEMWB
I4 OR R7, R2, R5IFIDEXMEMWB

Stalls = 1; clock cycles = 5 + 4 + 1 = 10; CPI = 10 / 5 = 2.0.

(c) Speed-up = 15 / 10 = 1.5 (the CPI drops from 3.0 to 2.0).

Not one of the official papers' exercises: the papers of 2024–2026 test this material through the dependence table of Exercise 1, the CPI line of every table and the quizzes. The form is that of the notes' Example 2 and Figure 9 and of the textbook. What is checked: the stalls per pair from the distance rule, the frozen IF cells of the instruction behind a stall, the one surviving load-use stall, and a total that equals the cycle of the last WB. Writing "S" (or the notes' "ID-Stallo" / "IF-Stallo") for a held cell gives the same cycle count.

Lesson 2 · When the line jams: hazards and forwarding · question 3 of 6 · open in the lesson

The code SUB R2, R1, R3 / AND R12, R2, R5 / OR R13, R6, R2 / ADD R14, R2, R2 / SD R15, 100(R2) runs on the 5-stage pipeline without forwarding, with the split-cycle register file. How many clock cycles does it take, counting the pipeline fill?

Show model answer

Only AND stalls (distance 1 from SUB: 2 stalls); OR is held in IF behind it and reads R2 in cycle 6, after the write in cycle 5; ADD and SD are later still. Clock cycles = IC + 4 + stalls = 5 + 4 + 2 = 11.

The trap is to charge OR for its own distance-2 dependence (one stall by the rule) — but the rule assumes the consumer was not already delayed. The stall of AND has pushed OR past the write. Count on the table, not on the rule alone.

Lesson 2 · When the line jams: hazards and forwarding · question 4 of 6 · open in the lesson

On a 5-stage pipeline with full forwarding (EX/EX, MEM/EX, MEM/MEM) and a split-cycle register file, how many stall cycles does LD R5, 0(R9) immediately followed by ADD R6, R5, R5 cause? (Single answer.)

  • 0 Forwarding cannot deliver a value that does not exist yet: the load's data appears at the end of its MEM stage, in the same cycle as the add's EX would run.
  • 1 One bubble, then the MEM/EX path hands the loaded value from MEM/WB to the ALU.
  • 2 Two stalls is the cost without forwarding; the MEM/EX path saves one of them.
  • 3 Three stalls would mean waiting for the register file without the split-cycle trick; both mechanisms exist here.
Show model answer

Answer 2: 1 stall. The loaded value exists only at the end of the load's MEM stage; the add's EX is delayed one cycle and then takes the value through the MEM/EX path.

A single-answer quiz in the form of the papers' quiz block (none of the 2024–2026 papers asks this exact pair, but it is the one fact of the chapter a quiz can test in one line). The distractor 0 is the notes' "forwarding eliminates stalls".

Lesson 2 · When the line jams: hazards and forwarding · question 5 of 6 · open in the lesson

Which hazards can occur in the basic in-order 5-stage RISC-V pipeline with separate instruction and data memories? (Multiple answers.)

  • RAW data hazards A consumer can reach ID before its producer has reached WB.
  • WAR data hazards Every read happens in ID, three stages before any younger instruction's WB.
  • WAW data hazards All writes go through the single WB stage in program order.
  • Control hazards The next PC is not known when the instruction after a branch should be fetched.
  • Structural hazards on memory Separate instruction and data memories let IF and MEM of two instructions proceed in the same cycle.
Show model answer

Answers 1 and 4. Reads in ID precede any later write in WB and all writes are in order through one WB stage, so WAR and WAW are impossible; split memories remove the IF/MEM conflict; RAW and control hazards remain.

A multiple-answer quiz in the form of the June 2026 paper. The notes' "WAR … rare in RISC" is the distractor to resist.

Lesson 2 · When the line jams: hazards and forwarding · question 6 of 6 · open in the lesson

A compiler targets a 5-stage pipeline with no forwarding and no interlocks, but with the split-cycle register file. How many NOP instructions must it insert between SUB R2, R1, R3 and AND R12, R2, R5 for the AND to read the new R2? Motivate your answer. (Single answer.)

  • 0 Without forwarding the AND would read R2 in cycle 3 while SUB computes it; zero slots is the forwarding answer.
  • 1 The notes' Example 3; with one slot the AND reads in cycle 4 and SUB writes in cycle 5: stale value.
  • 2 With two slots the AND is the third instruction after SUB and reads R2 in cycle 5, the cycle of SUB's WB; the split-cycle file makes that read see the new value.
  • 3 Three slots would be needed only without the split-cycle register file, when the read must come the cycle after the write.
Show model answer

Answer 3: 2 NOPs. Motivation: SUB writes R2 in WB in cycle 5. The consumer at distance \(d\) reads in cycle \(d + 2\); the read must be in cycle 5 or later, so \(d = 3\): two instructions in between. Stalls = max(0, 3 − d) = 0.

The "motivate your answer" line is where the second point is: write the two cycle numbers (write in 5, read in d + 2), not only the count.

Lesson 3 · What “faster” means: the Iron Law, Amdahl and pipeline arithmetic

Lesson 3 · What “faster” means: the Iron Law, Amdahl and pipeline arithmetic · question 1 of 7 · open in the lesson

PERFORMANCE EVALUATION. Given CPU1 with clock frequency 500 MHz and CPU2 with clock frequency 200 MHz, let's consider the two CPUs execute a kernel of 100 instructions with the following frequencies of occurrence and clock cycles:

Instruction TypeInstruction FrequencyCPU1 Clock CyclesCPU2 Clock Cycles
ALU30%21
LOAD10%86
STORE20%23
JUMP30%22
BRANCH10%33

How much is the average CPI for each CPU? CPI1 = … CPI2 = … How much is the CPU time for each CPU? CPUtime1 = … CPUtime2 = … How much is CPU1 faster than CPU2?

Show model answer

CPI1 = 0.3 × 2 + 0.1 × 8 + 0.2 × 2 + 0.3 × 2 + 0.1 × 3 = 0.6 + 0.8 + 0.4 + 0.6 + 0.3 = 2.7

CPI2 = 0.3 × 1 + 0.1 × 6 + 0.2 × 3 + 0.3 × 2 + 0.1 × 3 = 0.3 + 0.6 + 0.6 + 0.6 + 0.3 = 2.4

TCLK1 = 1 / 500 MHz = 2 ns; TCLK2 = 1 / 200 MHz = 5 ns.

CPUtime1 = IC × CPI1 × TCLK1 = 100 × 2.7 × 2 ns = 540 ns; CPUtime2 = 100 × 2.4 × 5 ns = 1200 ns.

CPU1 is faster by the ratio of the execution times: 1200 / 540 = 2.22 times faster, i.e. 122% faster (Perf(CPU1) = (1 + 122/100) × Perf(CPU2)), although its CPI is higher: the clock factor 2.5 outweighs the CPI factor 2.7 / 2.4 = 1.125.

Three things earn the points: the two weighted sums written term by term, the conversion of each frequency to a cycle time in ns before the multiplication, and "faster" expressed as the ratio of the times (2.22×, 122%), not as a difference, not as the CPI ratio and not through MIPS. Part 2 of the same exercise, CPU3 with cache misses, needs the memory-stall formula of lesson 24.

Lesson 3 · What “faster” means: the Iron Law, Amdahl and pipeline arithmetic · question 2 of 7 · open in the lesson

A loop body of m = 6 instructions is executed n = 200 times on the 5-stage RISC pipeline at 2 GHz; each iteration suffers k = 2 stall cycles. Compute: (a) the clock cycles and the CPI of a single iteration; (b) the total clock cycles of the loop; (c) the CPI of the whole loop and the asymptotic CPI; (d) the asymptotic MIPS; (e) the CPU time of the loop.

Show model answer

(a) Single iteration: cycles = m + k + 4 = 6 + 2 + 4 = 12; CPIiter = 12 / 6 = 2.0.

(b) Whole loop: IC = m × n = 1200; clock cycles = n × (m + k) + 4 = 200 × 8 + 4 = 1604 (the fill is paid once).

(c) CPI = 1604 / 1200 = 1.337; CPIAS = (m + k) / m = 8 / 6 = 1.333.

(d) MIPSAS = fCLK / (CPIAS × 106) = 2000 MHz / 1.333 = 1500 MIPS.

(e) TCLK = 1 / 2 GHz = 0.5 ns; CPU time = 1604 × 0.5 ns = 802 ns.

The classic mistake is to add 4 to every iteration (200 × 12 = 2400 cycles) or to forget it for the single iteration (8 cycles, CPI 1.33). Note how close the exact CPI (1.337) already is to the asymptotic one (1.333) after 200 iterations.

Lesson 3 · What “faster” means: the Iron Law, Amdahl and pipeline arithmetic · question 3 of 7 · open in the lesson

An enhancement gives a speedup S = 10 to the part of the execution it affects. Which fraction F of the original execution time must be affected to obtain an overall speedup of 4? Give F as a decimal fraction (three digits).

Show model answer

Speedup = 1 / ((1 − F) + F / S) = 4 ⇒ (1 − F) + F / 10 = 0.25 ⇒ 1 − 0.9 F = 0.25 ⇒ F = 0.75 / 0.9 = 0.833 (83% of the execution time).

This is the 8 January 2026 quiz as the notes reproduce it (single answer, "motivate your answer"; its options were 55%, 83%, 45%, 40% and 25%). Check the answer the way the examiner would: 1 / (1/6 + 1/12) = 1 / (3/12) = 4. The tempting distractors are 40% (the "4/10" guess) and 25% (the reciprocal of the target, 1/4).

Lesson 3 · What “faster” means: the Iron Law, Amdahl and pipeline arithmetic · question 4 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following: 1. the CPU time equation; 2. the weighted average CPI of an instruction mix; 3. MIPS as a performance metric and its limits; 4. Amdahl's law; 5. the pipeline fill and the formula Clock cycles = IC + Stall cycles + 4; 6. the asymptotic CPI of a loop.

Show model answer

1. CPU time = IC × CPI × TCLK = IC × CPI / fCLK: the instructions executed, times the average clock cycles per instruction, times the cycle time. Each factor is set by a different level (compiler and ISA for IC; organisation for CPI; technology and pipeline depth for TCLK) and they interact (a deeper pipeline shortens the cycle but adds stalls). Benefit: it predicts the effect of a design change and makes execution time, the only reliable metric, computable from measurable factors.

2. Total cycles = Σ CPIi × Ii; dividing by IC gives CPI = Σ CPIi × Fi with Fi = Ii / IC the frequency of class i. Benefit: the CPI of a program on a machine from a mix table (e.g. 2.7 vs 2.4), without executing it; it shows which class dominates the time.

3. MIPS = fCLK / (CPI × 106) = IC / (CPU time × 106): millions of instructions per second. Limits: it depends on the instruction set and on the program, and it ignores the work per instruction, so it can vary inversely with performance (software FP: more instructions, higher MIPS, longer time). It is valid only to compare the same program with the same IC; otherwise compare CPU times.

4. If a fraction F of the original execution time is made S times faster, the new time is ((1 − F) + F / S) × old time and the speedup is 1 / ((1 − F) + F / S), bounded by 1 / (1 − F) as S → ∞. Benefit: it tells where to invest ("make the common case fast") and bounds the return of any single enhancement; e.g. F = 0.4, S = 10 gives 1.56, at most 1.67.

5. In a 5-stage pipeline the first instruction completes in cycle 5 and each following one a cycle later, so IC instructions complete in IC + 4 cycles (the 4 fill cycles are the depth minus one, paid once); each stall cycle delays everything behind it by one cycle: Clock cycles = IC + Stall cycles + 4, CPI = cycles / IC, MIPS = fCLK / (CPI × 106). It gives the throughput of pipelined code from a cycle table (e.g. 5 instructions, 2 stalls: 11 cycles, CPI 2.2).

6. For a loop of m instructions and k stall cycles per iteration run n times, cycles = n(m + k) + 4 and CPI(n) = 1 + k/m + 4/(mn) → CPIAS = (m + k)/m = 1 + k/m as n → ∞: the fill becomes negligible and the performance is governed by the stall cycles per instruction, so minimising k (or spreading it over a longer body) is what matters. The ideal CPI 1 is reached only with k = 0.

The paper's open question gives about five lines per sub-point: a definition, the formula with its symbols explained, the benefit, and one number as an example. A concept without its "why" (what the technique buys) loses the point.

Lesson 3 · What “faster” means: the Iron Law, Amdahl and pipeline arithmetic · question 5 of 7 · open in the lesson

Program P runs in 10 s on machine A and in 15 s on machine B. Which statement is correct? (SINGLE ANSWER)

  • Answer 1: A is 33% faster than B 33% is the time A saves as a fraction of B's time, (15 − 10)/15; "faster" is defined on the ratio of the times.
  • Answer 2: A is 50% faster than B Time(B) = (1 + n/100) × Time(A): 15 = 1.5 × 10, so n = 50.
  • Answer 3: B is 50% faster than A B is the slower machine: it takes more time.
  • Answer 4: A is 1.33 times faster than B The ratio of the times is 15/10 = 1.5, not 1.33.
Show model answer

Answer 2: Perf(A)/Perf(B) = Time(B)/Time(A) = 15/10 = 1.5 = 1 + 50/100.

The notes' Example 2. The "33%" trap is the one distractor the examiner expects to catch people with.

Lesson 3 · What “faster” means: the Iron Law, Amdahl and pipeline arithmetic · question 6 of 7 · open in the lesson

On a 5-stage pipeline with no stalls, how many clock cycles do N instructions take? (SINGLE ANSWER)

  • Answer 1: 5N That is the unpipelined count: 5 cycles each, no overlap.
  • Answer 2: N + 4 The first instruction completes in cycle 5, the N-th in cycle N + 4: the fill of depth − 1 cycles is paid once.
  • Answer 3: N Only asymptotically: the fill never disappears, it is diluted.
  • Answer 4: N + 5 Off by one: the fill is depth − 1 = 4 cycles, because the cycle in which the first instruction completes is already one of the N.
Show model answer

Answer 2: Clock cycles = IC + Stall cycles + 4 with Stall cycles = 0.

Fig. 4: five instructions, cycles 1 to 9.

Lesson 3 · What “faster” means: the Iron Law, Amdahl and pipeline arithmetic · question 7 of 7 · open in the lesson

Which of the following statements are correct? (MULTIPLE ANSWERS)

  • Answer 1: Pipelining increases the instruction throughput but does not reduce the execution time of a single instruction Every instruction still walks through all the stages; only the overlap changed (notes, p. 253).
  • Answer 2: The ideal CPI of a single-issue 5-stage pipeline is 1 One instruction completes per cycle once the pipeline is full; stalls and the fill push the real CPI above 1.
  • Answer 3: A higher clock frequency always gives a shorter CPU time CPU time = IC × CPI × TCLK: a faster clock can raise the CPI (loads cost more cycles), as in the June 2025 exercise.
  • Answer 4: A 4-issue processor can have a CPI below 1 Its ideal CPI is 1/4 = 0.25; "CPI is always greater than 1" holds for single issue only.
  • Answer 5: With a large enough S, Amdahl's overall speedup can exceed 1 / (1 − F) 1 / (1 − F) is the limit for S → ∞; no S reaches it, let alone exceeds it.
Show model answer

Answers 1, 2 and 4.

Two of the three distractors are the "always" statements of this lesson's red pens; the third is the frequency fallacy of the hook.

To the filters ↑

Module 2 · Branch prediction

20 questions · Notes, chapter 2 · control hazards, static schemes and the delay slot, history tables, correlating predictors

Lesson 4 · Why the pipeline hates branches: static prediction and the delay slot

Lesson 4 · Why the pipeline hates branches: static prediction and the delay slot · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques for handling branches in a pipelined RISC-V processor: 1. Branch always not taken; 2. Branch always taken with a Branch Target Buffer; 3. Backward taken, forward not taken; 4. Delayed branch with delay-slot scheduling.

Show model answer

1. Branch always not taken. Fetch continues at PC + 4 as if the branch were an ordinary instruction; no hardware and no target address are needed. When the branch is not taken the cost is zero; when it is taken the one instruction fetched after the branch is flushed (turned into a NOP) and fetch restarts at the target: a 1-cycle penalty with the branch solved in ID. Good for if-then-else with a rare else path, bad for loop-closing branches, which are taken almost always.

2. Branch always taken with a BTB. Fetch continues at the target. The target is needed while the branch is still in IF, before decoding, so a Branch Target Buffer — a cache indexed by the address of the branch instruction whose entry holds the predicted target address — supplies it; on a hit the target is fetched in the next cycle. When the branch is not taken the instruction fetched from the target is flushed and fetch resumes at PC + 4 (1 cycle). On a BTB miss the processor falls back to PC + 4 or waits for the target. Good for backward loop branches; without a BTB the scheme has no benefit in a 5-stage pipeline because the target is not known before the outcome.

3. BTFNT. Use the direction of the branch, i.e. the sign of the offset: backward branches (loops) are predicted taken, forward branches (if-then-else, rarely entered paths) not taken. Needs only one bit of the instruction and no learning hardware; better accuracy than either uniform rule on mixed code. Not adaptive: a forward branch that is usually taken is mispredicted most of the time; and the direction is only known after decoding, so the guess is stored in the BTB entry to be usable in IF.

4. Delayed branch. The instruction in the slot after the branch is always executed, whatever the outcome; the branch takes effect after it. The compiler fills the slot with an instruction from before the branch (independent of it: always useful), from the target (useful when taken; must be harmless when not; usually duplicated at the label) or from the fall-through (useful when not taken; harmless when taken). A filled slot hides the 1-cycle bubble of the ID-resolved pipeline; a NOP in the slot is a stall. Benefit: no guessing and no flush logic; drawbacks: the slot ties the ISA to one pipeline depth, deeper or multiple-issue pipelines cannot be covered by one slot, and about half of the slots are not usefully filled — which is why RISC-V has no delay slot.

The 2026 paper gives five lines per sub-point: name the mechanism, say what it costs, what it buys, and when it fails. For point 2 the examiner looks for "indexed by the branch PC" and "target needed in IF"; for point 4 for "always executed" and the three sources with their conditions.

Lesson 4 · Why the pipeline hates branches: static prediction and the delay slot · question 2 of 7 · open in the lesson

Consider the following loop executed on a 5-stage pipeline where the branch is solved in the ID stage (misprediction penalty 1 cycle):

INIT: ADDUI R1, R0, 0
      ADDUI R2, R0, 20
LOOP: LD    F0, 0(R1)
      FADD  F2, F0, F0
      SD    F2, 0(R1)
      ADDUI R1, R1, 4
      BNE   R1, R2, LOOP

For (a) branch always not taken, (b) branch always taken with a BTB that always hits, (c) BTFNT, complete the table (prediction, branch outcome, penalty for each iteration), then give the misprediction rate on the BNE and the total branch stall cycles.

Show model answer

The BNE executes with R1 = 4, 8, 12, 16, 20 against R2 = 20: five executions, outcomes T T T T NT.

Iteration1st2nd3rd4th5th
Branch OutcomeTTTTNT
(a) Prediction: always NTNTNTNTNTNT
(a) Penalty11110
(b) Prediction: always TTTTTT
(b) Penalty00001
(c) Prediction: BTFNT (backward → T)TTTTT
(c) Penalty00001

(a) 4 mispredictions of 5 = 80 %, 4 stall cycles. (b) 1 of 5 = 20 %, 1 stall cycle. (c) LOOP is above the BNE, the offset is negative, the branch is predicted taken: identical to (b), 20 %, 1 stall cycle.

The rate is only worth the point with the row of outcomes underneath it. The commonest slip is counting four executions instead of five: list the values of R1 at the branch before writing anything else.

Lesson 4 · Why the pipeline hates branches: static prediction and the delay slot · question 3 of 7 · open in the lesson

In a program 20 % of the executed instructions are conditional branches and 60 % of the branches are taken. The pipeline solves branches in the ID stage and uses branch always not taken; branches are the only source of stalls and the pipeline fill is negligible. Compute the CPI.

Show model answer
\[ \text{CPI} = 1 + f_b \cdot \text{penalty} \cdot p_{\text{mis}} \] \[ = 1 + 0.2 \cdot 1 \cdot 0.6 = 1.12 \]

Always not taken mispredicts exactly the taken branches, so \(p_{\text{mis}} = 0.6\). For comparison: stalling gives 1.20, always taken with a perfect BTB 1.08; with the PC written in ME (penalty 3) the three become 1.60, 1.36, 1.24.

Write the formula first, then the numbers. The examiner checks that the penalty is 1 for an ID-resolved branch and that the misprediction probability of "not taken" is the taken fraction, not its complement.

Lesson 4 · Why the pipeline hates branches: static prediction and the delay slot · question 4 of 7 · open in the lesson

The pipeline solves branches in ID and has one delay slot that is always executed. Fill the slot of the following loop with the "from target" strategy: write the scheduled code, give the cycles per iteration before and after, and state the conditions that make the transformation legal.

LOOP: LD    F0, 0(R1)
      ADDUI R1, R1, 8
      FADD  F2, F2, F0
      FMUL  F4, F4, F0
      BNE   R1, R2, LOOP
      NOP              # delay slot
Show model answer
      LD    F0, 0(R1)      # copy of the target, runs once
LOOP: ADDUI R1, R1, 8      # new target
      FADD  F2, F2, F0
      FMUL  F4, F4, F0
      BNE   R1, R2, LOOP
      LD    F0, 0(R1)      # delay slot: next iteration's load

Before: 5 instructions + 1 NOP = 6 cycles per iteration (m = 5, k = 1, CPI∞ = 1.2). After: 5 cycles per iteration (k = 0, CPI∞ = 1), because the slot now holds the next iteration's load. Legal because: the moved LD does not produce an operand of the branch (R1, R2); the slot LD writes F0, which the next FADD reads with the ADDUI in between, so no load-use stall appears; the ADDUI stays at least one instruction before the BNE that tests R1 (2-cycle ALU-to-branch latency); and on the exit path the extra load past the end of the array must be harmless — the address readable and F0 dead after the loop. The copy before the loop is the duplication cost of the strategy.

Four things earn the marks: the retargeted label, the copy before the loop, the cycle count before/after, and the exit-path condition. Forgetting the copy makes the first iteration read an F0 that was never loaded.

Lesson 4 · Why the pipeline hates branches: static prediction and the delay slot · question 5 of 7 · open in the lesson

In a 5-stage pipeline where the branch outcome and the target address are computed in the ID stage, the penalty of a mispredicted branch under branch always not taken is:

  • 0 cycles Zero is the cost of a correct guess; the wrong one loses the fetch slot used while the branch was in ID.
  • 1 cycle The instruction fetched in the cycle the branch spends in ID is flushed; fetch restarts from the target in the next cycle.
  • 2 cycles Two would be the penalty of a branch resolved at the end of EX.
  • 3 cycles Three is the penalty of the basic pipeline, where the PC is written at the end of ME.
Show model answer

1 cycle: penalty = resolution stage − 1 = 2 − 1.

The quiz is matched against the course's pipeline, in which "branch solved in ID stage" is the standing assumption.

Lesson 4 · Why the pipeline hates branches: static prediction and the delay slot · question 6 of 7 · open in the lesson

With the delayed branch technique, the instruction placed in the branch delay slot:

  • is executed only if the branch is taken That describes a cancelling ("branch likely") branch predicted taken, not the plain delayed branch of the course.
  • is executed only if the branch is not taken No: the slot does not depend on the outcome at all.
  • is always executed, whatever the outcome The branch takes effect after the slot; the compiler must choose an instruction that is correct on both paths.
  • is flushed whenever the prediction is wrong There is no prediction and no flush in a delayed branch — this is exactly the wording the notes get wrong on pp. 49 and 51.
Show model answer

It is always executed, regardless of the branch outcome.

Single answer. The distractor "flushed" is attractive because of the notes' wording; the rule of the ISA is the one on p. 46.

Lesson 4 · Why the pipeline hates branches: static prediction and the delay slot · question 7 of 7 · open in the lesson

Which statements about the Branch Target Buffer used with branch always taken are true? (Multiple answers.)

  • It is indexed by the address of the branch instruction At fetch time the PC is the only thing the hardware has; the instruction bits are not yet available.
  • It stores the predicted target address Key: branch PC; value: predicted target (the notes' 0x100 → 0x80).
  • It decides whether the branch is taken The direction comes from the static rule (here) or from a history table (lesson 5); the BTB only says where.
  • On a hit the target is fetched in the cycle after the branch's IF That is the whole point: the target is available during IF, before decoding.
  • It is required by branch always not taken too Not taken needs no target: PC + 4 is always known.
Show model answer

True: indexed by the branch PC; stores the predicted target; on a hit the target is fetched in the next cycle. False: it does not decide the direction, and always not taken does not need it.

The 2026 paper has "Multiple Choice – Multiple answer" quizzes; tick every true statement and no false one.

Lesson 5 · Learning from the past: 1-bit and 2-bit history tables, and the BTB

Lesson 5 · Learning from the past: 1-bit and 2-bit history tables, and the BTB · question 1 of 7 · open in the lesson

Let's consider the Dynamic Branch Prediction techniques used in modern microprocessors. (a) What are the main benefits to introduce the dynamic branch prediction in a modern microprocessor? (b) Explain how works a Branch History Table.

Show model answer

(a) The hardware predicts each branch at run time from its past behaviour, so the pipeline keeps fetching instead of stalling. Benefits: fewer mispredictions and hence a lower CPI (in \(\text{CPI} = \text{CPI}_{\text{ideal}} + f_b (1 - a) P\) the predictor raises the accuracy \(a\), the penalty \(P\) is fixed by the pipeline); adaptation to the actual input data and program phases, which a static compile-time rule cannot see; it is essential in deep and wide pipelines, where every misprediction wastes depth × width instructions; it enables speculative execution past unresolved branches, with results committed only when the branch resolves; it needs no compiler support, delay slots or profiling, so existing binaries benefit.

(b) A Branch History Table is a table indexed by the low-order bits of the branch PC, without tags (so two branches may share an entry: aliasing). Each entry is a small finite-state machine: 1 bit storing the last outcome, or a 2-bit machine with the states Strongly Taken, Weakly Taken, Weakly Not Taken, Strongly Not Taken, predicting Taken in the first two. The table is read in IF with the fetch PC and the prediction decides whether to fetch PC + 4 or the target; when the branch resolves the entry is updated with the outcome. With 2 bits a single anomaly, such as a loop exit, moves a strong state to the weak state of the same direction without changing the prediction, so a loop branch is mispredicted once per execution of the loop instead of twice.

The first two of the five sub-points of Question 2 of the January 2026 paper; the June 2026 paper asks the same in one sub-point of the 8-point question. A complete answer has the mechanism (indexed by the PC, no tags, FSM per entry, read in IF, updated at resolution), the 1-bit vs 2-bit contrast with the loop-exit argument, and benefits stated as cause and effect, not as adjectives. Do not write "reduces the penalty": it reduces the rate.

Lesson 5 · Learning from the past: 1-bit and 2-bit history tables, and the BTB · question 2 of 7 · open in the lesson

Explain the main purpose to introduce the Branch Target Buffer.

Show model answer

The branch target address is computed in the ID stage, so even a correct Taken prediction in IF leaves the fetch unit without an address: one bubble on every taken branch. The Branch Target Buffer removes this control hazard. It is a small cache indexed by the branch PC, with tags, whose data is the predicted target address of taken branches (often together with the T/NT prediction bits). On a hit with a Taken prediction the next PC is set to the stored target in the same IF cycle, so a correctly predicted taken branch costs zero cycles. An entry is written when a taken branch resolves and its target is known; on a miss, fetch defaults to PC + 4 and the branch pays the normal penalty if taken. The tags are necessary because a false hit would redirect the fetch of a non-branch instruction — unlike the BHT, which only predicts the direction and can be untagged.

The third sub-point of Question 2 of the January 2026 paper. The examiner looks for "whether versus where", "in the same cycle", "indexed by the PC with tags", "stores taken branches, filled at resolution", and the three cases (predict NT; predict T and hit; predict T and miss). Do not write "eliminates the control hazard" without qualification: it eliminates it on a hit with a correct prediction.

Lesson 5 · Learning from the past: 1-bit and 2-bit history tables, and the BTB · question 3 of 7 · open in the lesson

Let's consider the following LOOP to be executed on a processor with a single-entry 2-bit Branch History Table initialized in the state Strongly Not-Taken:

INIT: ADDUI R1, R0, 0
      ADDUI R2, R0, 20
LOOP: LD    F0, 0(R1)
      FADD  F2, F0, F0
      SD    F2, 0(R1)
      ADDUI R1, R1, 4
      BNE   R1, R2, LOOP

After the last iteration, how much is the misprediction rate on the BNE instruction? Motivate your answer by completing the table (rows Prediction State / Prediction / Branch Outcome, one column per iteration; the first column is given: Strongly Not Taken, Not Taken, Taken).

  • 60 % Five executions (R1 = 4, 8, 12, 16, 20), misses at the 1st, 2nd and 5th: 3/5.
  • 90 % Impossible on five executions (it would be 4.5 misses); read as an accuracy, 90 % is the notes' ten-iteration steady state, not this cold start.
  • 99 % Impossible: after two Taken in a row any 2-bit counter predicts the third Taken correctly.
  • 100 % Impossible for the same reason: the 3rd and 4th executions are predicted right.
  • 80 % Four misses would need the warm-up to last four executions; from SNT it lasts two.
Show model answer

The BNE is executed with R1 = 4, 8, 12, 16, 20: five times, Taken four times and Not Taken at the exit.

Iteration1st2nd3rd4th5th
Prediction StateStrongly Not TakenWeakly Not TakenWeakly TakenStrongly TakenStrongly Taken
PredictionNot TakenNot TakenTakenTakenTaken
Branch OutcomeTakenTakenTakenTakenNot Taken

Mispredictions at the 1st, 2nd and 5th execution: misprediction rate = 3 / 5 = 60 % (Answer 1). With the FSM of the lecture figure the 3rd state is Strongly Taken (WNT → ST on a Taken); the predictions and the rate are the same.

The 10 June 2025 paper, Question 5, worth 1 point for the answer and 1 for the table. Count the executions from the register values, not from the word "iterations", and count the warm-up misses. Write the state names in full, as the paper does.

Lesson 5 · Learning from the past: 1-bit and 2-bit history tables, and the BTB · question 4 of 7 · open in the lesson

Same loop and same Branch History Table. After the last iteration, what is the state of the prediction left in the Branch History Table?

  • Strongly Taken That is the state before the 5th execution; the exit Not Taken moves it one step down.
  • Weakly Taken After four Taken the entry is in Strongly Taken; the final Not Taken moves it to Weakly Taken, in both FSM variants.
  • Strongly Not Taken The initial state; after four Taken the counter is at the other end.
  • Weakly Not Taken One Not Taken from Strongly Taken reaches only the weak Taken state; a second one would be needed.
Show model answer

Before the 5th execution the state is Strongly Taken (after four Taken). The outcome is Not Taken, so the state moves one step: Strongly Taken → Weakly Taken (Answer 2). The question asks for the state after the last update, one transition beyond the last column of the table.

Second part of the same quiz. The trap is to answer with the state used for the last prediction (Strongly Taken) instead of the state left by it.

Lesson 5 · Learning from the past: 1-bit and 2-bit history tables, and the BTB · question 5 of 7 · open in the lesson

Let's consider a processor with a 1-entry 1-bit Branch History Table initialized as Taken, executing the following code (only the BEQ accesses the BHT):

      ADDUI R1, R0, 0
      ADDUI R2, R0, 100
LOOP: BEQ   R1, R2, DONE
      ADD   R5, R5, R4
      ADDUI R1, R1, 1
      J     LOOP
DONE:

How many mispredictions occur on the BEQ? (State also the number of BHT accesses.)

Show model answer

The BEQ is executed with R1 = 0, 1, …, 100: 101 accesses to the BHT. Outcomes: Not Taken 100 times, then Taken at R1 = 100. The entry starts as Taken: 1st access, predict Taken, outcome Not Taken → misprediction, bit ← NT; accesses 2 to 100 predict Not Taken correctly; 101st access, predict Not Taken, outcome Taken → misprediction. Total: 101 accesses, 2 mispredictions (rate 2/101 ≈ 2 %).

Quiz 5 of the May 2025 midterm as the notes report it (its options paired accesses and mispredictions; "101 and 2" is the right pair). A top-tested loop executes its exit branch N + 1 times; the first miss comes from the initialisation, the second from the exit — both are changes of direction, and a 1-bit entry pays one miss per change.

Lesson 5 · Learning from the past: 1-bit and 2-bit history tables, and the BTB · question 6 of 7 · open in the lesson

An inner loop of 8 iterations, closed by a BNE (taken 7 times, then not taken), is executed 3 times by an outer loop. Only the inner BNE accesses a single-entry Branch History Table. (a) With a 1-bit BHT initialized Not Taken, give the number of BHT accesses, the number of mispredictions, the misprediction rate and the final state. (b) Same with a 2-bit BHT initialized Strongly Not Taken. (c) How many mispredictions per execution of the inner loop does each predictor make in steady state?

Show model answer

(a) 3 × 8 = 24 accesses; outcomes T T T T T T T NT, three times. The 1-bit entry mispredicts at access 1 (NT predicted, T), at 8 (exit), at 9 (re-entry: the entry holds NT), at 16, 17 and 24: 6 mispredictions, 6/24 = 25 %, final state Not Taken (the last outcome).

(b) From Strongly Not Taken: access 1 predicts NT (miss, → WNT), access 2 predicts NT (miss, → WT with a saturating counter, → ST with the lecture figure), accesses 3–7 predict T correctly (the state is ST from access 4 at the latest), access 8 predicts T but the branch exits (miss, ST → WT); access 9 predicts T from WT correctly (→ ST), accesses 10–15 hit, 16 misses (→ WT), 17 hits, 18–23 hit, 24 misses (→ WT). Mispredictions at 1, 2, 8, 16, 24: 5, rate 5/24 ≈ 21 %, final state Weakly Taken.

(c) Steady state: 2 per inner-loop execution with 1 bit (exit and re-entry), 1 with 2 bits (exit only). The 2-bit predictor also paid one extra warm-up miss from Strongly Not Taken.

An exercise in the style of the June 2025 quiz with the counting extended over several executions of the loop. The examiner checks the three sources of misses — initialisation, exit, re-entry — and that you know which one the second bit removes. Both 2-bit variants give the same numbers here.

Lesson 5 · Learning from the past: 1-bit and 2-bit history tables, and the BTB · question 7 of 7 · open in the lesson

During the execution of a program, the number of mispredictions depends on the initialization and the size of the Branch History Table (BHT). True or False? Motivate your answer.

  • True Initialisation sets the warm-up misses (a 2-bit entry started Strongly Not Taken misses the first two taken executions of a loop; started Strongly Taken it misses none); the size sets how many branches share an untagged entry, so a small table makes unrelated branches overwrite each other's state (aliasing) and mispredict.
  • False Both effects are real: the June 2025 quiz counts the two warm-up misses from Strongly Not Taken, and an untagged table of 2^k entries aliases every pair of branches with equal low-order PC bits.
Show model answer

True. (1) Initialization: the initial state of the entry decides whether the first executions of a branch are predicted correctly — a loop branch whose entry starts Strongly Not Taken costs two warm-up mispredictions, one that starts Weakly Not Taken costs one, one that starts Taken costs none. (2) Size: the BHT is indexed by k low-order bits of the PC without tags, so with 2^k entries all branches sharing those bits share the entry and interfere (aliasing); a larger table spreads the branches over more entries and reduces the interference. (The number of mispredictions also depends on the predictor's FSM, 1-bit or 2-bit, and on the program's branch patterns.)

Quiz 4 of the May 2025 midterm, a True/False with "motivate". The motivation earns the point: name both mechanisms and the word aliasing.

Lesson 6 · Branches that talk to each other: correlating and two-level predictors

Lesson 6 · Branches that talk to each other: correlating and two-level predictors · question 1 of 6 · open in the lesson

Explain the main concepts of the correlating branch prediction technique and its benefits with respect to a standard Branch History Table.

Show model answer

A standard BHT predicts each branch from its own past only. A correlating (two-level) predictor also uses the outcomes of the branches executed just before it: an m-bit Global History Register, a shift register holding the last m outcomes (1 = Taken), selects one of 2^m tables of n-bit entries (1-bit, or the 2-bit states Strongly/Weakly Taken, Weakly/Strongly Not Taken), and the k low-order bits of the branch PC select the entry inside the selected table. Equivalently the GHR concatenated with the PC bits forms one index of m + k bits into a single table; gshare XORs the history with the PC bits instead, to spread the branches over the whole table and reduce aliasing. After the branch resolves, the entry is updated and the outcome is shifted into the GHR. The benefit: each (branch, recent context) pair has its own counter, so a branch whose outcome depends on previous branches — or on its own recent pattern, such as a loop exit — is predicted correctly after warm-up, where a per-branch counter flip-flops; H&P show a (2,2) predictor of 8 Kbit mispredicting less than a 2-bit BHT with unlimited entries. The cost is one shift register, 2^m × n × 2^k bits of tables, a longer warm-up (every context must be trained) and aliasing in the pattern table.

The wording is the fourth sub-point of Q2 of the January 2026 paper in the notes (p. 498); in the June 2026 format the same material sits inside the sub-point "dynamic branch prediction and speculative execution" of the 8-point question — about five lines either way. The examiner looks for the three mechanisms (history register, table selection, PC indexing), the update rule, the "separate counter per context" argument and one concrete benefit. Naming gshare's XOR earns the aliasing point; the January 2026 solution in the notes mentions "concatenating or XORing", so both words belong in the answer.

Lesson 6 · Branches that talk to each other: correlating and two-level predictors · question 2 of 6 · open in the lesson

Consider the code BNE R1, R0, L1; ADDUI R1, R0, 1; L1: SUBI R3, R1, 1; BNE R3, R0, L2, where the first branch (b1) is taken if d = R1 is not 0 and the second (b2) is taken if d is not 1. The code is executed with d = 2, 0, 2, 0. (a) Fill the prediction table for a 1-bit predictor per branch, both entries initialised Not Taken. (b) Fill it for a (1,1) correlating predictor whose entries (one per branch and per value of the 1-bit global history) are initialised Not Taken, with the global history initialised Not Taken. (c) Count the mispredictions of each and explain the difference.

Show model answer

(a) 1-bit per branch (prediction = bit before, bit after = outcome):

db1 pred.b1 outcomeb2 pred.b2 outcome
2NT (miss)TNT (miss)T
0T (miss)NTT (miss)NT
2NT (miss)TNT (miss)T
0T (miss)NTT (miss)NT

(b) (1,1) predictor, entries written "if last NT / if last T":

dGH before b1b1 entriesb1 pred.b1 outcomeGH before b2b2 entriesb2 pred.b2 outcome
2NTNT/NTNT (miss)TTNT/NTNT (miss)T
0TT/NTNTNTNTNT/TNTNT
2NTT/NTTTTNT/TTT
0TT/NTNTNTNTNT/TNTNT

(c) 8 of 8 mispredicted against 2 of 8. The 1-bit entry always holds the previous outcome, and the outcomes alternate, so it is always one step behind. In the (1,1) predictor the global history bit selects a different entry for "after a taken branch" and "after a not-taken branch": in this code b1 not taken implies b2 not taken and b1 taken implies b2 taken, so each context converges after one miss; b1 is predicted from the previous b2, whose outcome encodes the previous value of d. Only the two cold entries miss.

Marks go to the correct shift of the history (it holds the last outcome, whichever branch produced it), to the two cold-entry misses being the only ones, and to the explanation in (c). A frequent slip: predicting b2 from b2's own previous outcome instead of from the entry the history selects.

Lesson 6 · Branches that talk to each other: correlating and two-level predictors · question 3 of 6 · open in the lesson

A (2,2) correlating predictor has 1024 entries per table. How many bits of prediction storage does it use?

Show model answer
\[ 2^m \cdot n \cdot 2^k = 4 \cdot 2 \cdot 1024 = 8192 \text{ bits} \]

that is 1 KB; a plain 2-bit BHT with the same budget would have 4096 entries.

The m history bits multiply the tables, they do not add bits to an entry: 2^m tables, each of 2^k entries of n bits.

Lesson 6 · Branches that talk to each other: correlating and two-level predictors · question 4 of 6 · open in the lesson

Consider the following assembly code executed by a processor with a 1-entry 1-bit Branch History Table initialised as Taken: ADDI R1, R0, 0; ADDI R2, R0, 100; LOOP: BEQ R1, R2, DONE; ADD R5, R5, R4; ADDI R1, R1, 1; J LOOP; DONE:. Assuming only the branch instruction accesses the BHT, how many accesses to the Branch History Table and how many mispredictions? (Single answer)

  • Answer 1: 101 accesses, 2 mispredictions The BEQ runs for R1 = 0 to 100: 101 executions; the initial Taken misses on the first (Not Taken), the exit misses on the last (Taken).
  • Answer 2: 100 accesses, 1 misprediction 100 counts the iterations, not the executions of the branch: the exit test is the 101st, and the initialisation costs a miss of its own.
  • Answer 3: 99 accesses, 1 misprediction The branch is executed for R1 = 0 as well as for R1 = 100; neither can be dropped.
  • Answer 4: 201 accesses, 2 mispredictions The unconditional J does not access the BHT by assumption; only the BEQ does.
Show model answer

Answer 1. Executions of BEQ: R1 = 0, 1, …, 100 → 101 accesses. Predict Taken at R1 = 0: outcome Not Taken, miss, bit → NT. R1 = 1 … 99: predict NT, outcome NT, 99 hits. R1 = 100: predict NT, outcome Taken, miss. Two mispredictions.

The midterm's quiz, recomputed. The two misses are the two changes of direction the 1-bit entry sees — one artificial (initialisation), one real (exit).

Lesson 6 · Branches that talk to each other: correlating and two-level predictors · question 5 of 6 · open in the lesson

During the execution of a program, the number of mispredictions depends on the initialization and the size of the Branch History Table (BHT). True or False? Motivate your answer.

  • True Initialisation sets the start-up misses; size sets how many branches share an untagged entry (aliasing).
  • False Both matter: a loop branch started Strongly Not Taken misses twice before predicting Taken, and a small untagged table lets unrelated branches overwrite each other's state.
Show model answer

True. (1) Initialisation: the initial state of the entries decides whether the first executions of each branch are predicted right — a 2-bit entry initialised Strongly Not Taken mispredicts the first two taken executions of a loop branch, initialised Strongly Taken it mispredicts none; these start-up misses count in the misprediction rate. (2) Size: the BHT is indexed by the low-order PC bits without tags, so with a small table different branches map to the same entry (aliasing) and interfere, each spoiling the other's state; a larger table reduces the collisions.

Two separate reasons, each with its mechanism, is what the extra "motivate" point pays for. Adding that the counter type (1 bit or 2) and the program's patterns also matter does not hurt.

Lesson 6 · Branches that talk to each other: correlating and two-level predictors · question 6 of 6 · open in the lesson

A loop of 10 iterations, whose body contains no other branch, is executed many times. Which predictor can reach 100 % accuracy on its loop branch after warm-up, exit included? (Single answer)

  • A 2-bit BHT with 4096 entries A counter holds a bias, not a pattern: it mispredicts the exit every time, 90 % at best.
  • A 2-bit BHT with unlimited entries Unlimited entries remove aliasing only; the exit is not an aliasing problem.
  • A two-level predictor with at least 9 bits of local history With h ≥ N − 1 = 9 every position in the pattern T×9 NT has its own history and its own counter; after warm-up all ten executions are predicted.
  • Always Taken Right nine times in ten, wrong at every exit: 90 %.
Show model answer

Answer 3. The exit is predictable because it comes at a fixed position; only a history long enough to distinguish "nine taken in a row" from the earlier positions can represent it, which is what a local (or, with no other branch in the body, global) history of at least 9 bits does. Counters of any size and static rules cannot.

The examiner is checking the difference between bias (what a counter stores) and pattern (what a history register stores).

To the filters ↑

Module 3 · Instruction-level parallelism

12 questions · Notes, chapter 3.1–3.5 · dependences, multi-cycle pipelines and exceptions, multiple issue and the superscalar recipe

Lesson 7 · Three ways instructions collide, and pipelines where EX takes more than a cycle

Lesson 7 · Three ways instructions collide, and pipelines where EX takes more than a cycle · question 1 of 6 · open in the lesson

(10 June 2025, EX1, first part.) Let's consider the following assembly code containing multiple types of intra-loop dependences. Complete the following table by inserting all types of true-data-dependences, anti-dependences and output dependences for each instruction (I0, I1 and I2: None).

I0  FOR: LD    F2, A(R1)
I1       LD    F4, B(R1)
I2       LD    F6, C(R1)
I3       FADD  F4, F2, F4
I4       FADD  F6, F4, F6
I5       SD    F6, A(R1)
I6       ADDUI R1, R1, 8
I7       BNE   R1, R2, FOR
Show model answer
I#True data dependence with I# for FxAnti-dependence with I# for FyOutput dependence with I# for Fz
I0, I1, I2NoneNoneNone
I3with I0 for F2; with I1 for F4Nonewith I1 for F4
I4with I3 for F4; with I2 for F6Nonewith I2 for F6
I5with I4 for F6NoneNone
I6Nonewith I0, I1, I2 and I5 for R1None
I7with I6 for R1NoneNone

Three rules fill the table: nearest earlier writer of each source; every earlier reader of the destination; every earlier writer of the destination. The marks usually lost: forgetting that the ADDUI collects all readers of R1, including the store; writing an anti-dependence for I3 on F4 (nobody reads F4 before I3 — I1 writes it, which is an output dependence); listing I0 as a producer for I4 (I4 reads F4 from I3, the nearest writer). The loop-carried dependence through R1 is not asked.

Lesson 7 · Three ways instructions collide, and pipelines where EX takes more than a cycle · question 2 of 6 · open in the lesson

(In the form of Question 1 of 22 June 2026.) Explain the main concepts and benefits of each one of the following techniques used by modern superscalar processors (Tomasulo-style): 1. Dynamic instruction scheduling; 2. Dynamic register renaming; 3. Out-of-order execution.

Show model answer

Dynamic instruction scheduling. The hardware, not the compiler, decides at run time when each instruction executes. Instructions are issued in program order to reservation stations and start executing as soon as their operands and a functional unit are available, so an instruction stalled on a long-latency producer (a divide, a cache miss) does not block the independent instructions behind it. Benefits: higher ILP and unit utilisation, latency hiding, handling of dependences unknown at compile time (memory, control flow), and binary compatibility — the same code runs efficiently on different pipelines; it is also the base for hardware speculation.

Dynamic register renaming. At issue, each destination register is mapped to a new name — a physical register, a reservation-station tag or a reorder-buffer entry — and later readers are redirected to it, so two instructions that re-use the same architectural register no longer conflict. Benefits: it eliminates WAR and WAW hazards (name dependences), leaving only true RAW dependences, which lets instructions execute out of order and loop iterations overlap without running out of registers.

Out-of-order execution. Instructions execute in the order in which their operands become ready rather than in program order, while issue and commit remain in program order; results are broadcast on the common data bus to the waiting consumers. Benefits: independent instructions fill the cycles that dependent ones would waste, long latencies are overlapped, more ILP is extracted from the instruction window. Cost: renaming, reservation stations and a reorder buffer to keep exceptions precise.

The question gives five lines per technique: write concept, mechanism, benefit and cost as short labelled statements, with "in-order issue, out-of-order execution, in-order commit" somewhere in the answer — that triad is what the examiner looks for. The other five items of the real question — 2 dynamic branch prediction and speculative execution, 3 multiple-issue pipeline, 4 reservation stations, 7 reorder buffer, 8 simultaneous multithreading — are answered in lessons 5–6, 8, 11, 17 and 29.

Lesson 7 · Three ways instructions collide, and pipelines where EX takes more than a cycle · question 3 of 6 · open in the lesson

A 5-stage pipeline is extended with multi-cycle floating-point units of different latencies (a pipelined adder and multiplier, an unpipelined divider), keeping in-order issue. Which new hazards and problems appear, and why? How does a single in-order commit point remove them, and at what cost?

Show model answer

New problems: (1) a structural hazard on the unpipelined divider; (2) several instructions may reach write-back in the same cycle, so the register-file write port must be arbitrated or reserved at issue; (3) WAW hazards, because a short operation issued after a long one to the same register completes first — WAR hazards cannot occur, since operands are still read in order in ID; (4) imprecise exceptions, because a younger instruction may have written its result before an older one faults; (5) more and longer RAW stalls, since forwarding cannot hide a multi-cycle computation.

A single commit point delays every result so that all operations reach the W stage after the same number of cycles: write-back is then in issue order, one per cycle (no WAW, no write-port conflict), and an exception is taken at commit, after all earlier instructions and before any later one (precise). Cost: independent fast instructions wait behind slow ones, and an unpipelined divide or a cache miss stalls the whole pipeline — low ILP, which is what motivates out-of-order execution with a reorder buffer that keeps commit in order while execution reorders.

The examiner checks that you separate the five effects and that you know which hazard cannot occur (WAR) and why. "Precise" must be defined, not just named: older ones done, younger ones without effect, restart at the faulting instruction.

Lesson 7 · Three ways instructions collide, and pipelines where EX takes more than a cycle · question 4 of 6 · open in the lesson

(15 July 2024, quiz 1, single answer.) Let's consider the following loop: for (i=1; i<=100; i++) { X[i] = X[i] + X[i-1]; /*S1*/ Z[i] = X[i] + Y[i-1] /*S2*/ }. How many loop-carried dependencies are in the code?

  • Answer 1: Only one in S2 because Z[i] depends on Y[i-1] Y is never written inside the loop, so Y[i-1] is an input, not a dependence between iterations.
  • Answer 2: Only one in S1 because X[i] depends on X[i-1] S1 reads X[i-1], which S1 wrote in the previous iteration: that is the one loop-carried dependence.
  • Answer 3: Both of them S2 depends on X[i] from the same iteration (intra-iteration) and on Y, which the loop does not write.
Show model answer

Answer 2. S1 reads X[i-1], produced by S1 in iteration i-1: loop-carried. S2's dependence on X[i] is within the iteration, and Y[i-1] is read only.

The exam's own distractor is the array index: "[i-1]" does not make a dependence unless the loop writes that array.

Lesson 7 · Three ways instructions collide, and pipelines where EX takes more than a cycle · question 5 of 6 · open in the lesson

(Multiple answers.) Which hazards can occur in the classic 5-stage in-order pipeline with a single-cycle EX stage?

  • RAW A consumer may need a value before the producer has computed it (a load followed by its user still stalls one cycle even with forwarding).
  • WAR Impossible: every read happens in ID and every write in WB, both in program order, so no younger instruction can write before an older one reads.
  • WAW Impossible: all writes happen in WB, in program order.
  • Structural With one memory for instructions and data, or one register-file port too few, two instructions want the same resource in the same cycle.
  • Control The branch outcome is known in ID or EX, after the next instructions have been fetched.
Show model answer

RAW, structural and control. WAR and WAW cannot occur: reads precede writes in order (no WAR) and all writes happen in WB in order (no WAW). Register renaming therefore buys nothing on this pipeline; it matters only once multi-cycle units (WAW) and out-of-order execution (WAR) appear.

A quiz in the 2026 "multiple answer" form. The trap is to tick WAR and WAW because they exist as dependences in the program; the question asks which can become hazards on this pipeline.

Lesson 7 · Three ways instructions collide, and pipelines where EX takes more than a cycle · question 6 of 6 · open in the lesson

(Single answer.) In a pipeline with in-order issue, functional units of different latencies and no reorder buffer, an FDIV reports a divide-by-zero at the end of its execution. Why is the exception imprecise?

  • Because the FDIV was issued out of order Issue is in order in this pipeline; the order that breaks is completion.
  • Because younger instructions have already written their registers when the fault is reported, so the state is not the sequential state at the FDIV The program cannot be restarted at the FDIV: part of what follows it has already happened.
  • Because the write port was busy when the FDIV wanted to write A write-port conflict delays a write; it does not change which instructions have taken effect.
  • Because the instructions that depend on the FDIV have been squashed Squashing the dependent instructions is harmless: they had not changed the state. The problem is the independent ones that did.
Show model answer

The second option. An exception is precise when all older instructions have completed and no younger one has changed the state; here younger, independent instructions completed and wrote their registers before the older FDIV faulted, so the state corresponds to no point of the sequential program. In-order commit (a reorder buffer) fixes it by holding their results until the FDIV has committed.

Watch for the word "issued": the examiner uses it to check that you know which stages stay in order.

Lesson 8 · Doing more per cycle: superscalar, static vs dynamic scheduling, the limits of ILP

Lesson 8 · Doing more per cycle: superscalar, static vs dynamic scheduling, the limits of ILP · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by modern superscalar processors (Tomasulo-style): 1. Dynamic instruction scheduling; 2. Dynamic branch prediction and speculative execution; 3. Multiple-issue pipeline; 4. Reservation stations; 5. Dynamic register renaming; 6. Out-of-order execution; 7. Reorder buffer; 8. Simultaneous multithreading. (Five lines each.)

Show model answer

1. Dynamic instruction scheduling. The hardware, not the compiler, decides at run time when each instruction executes: instructions are issued in program order to reservation stations and start as soon as their operands and a functional unit are available, so execution and completion are out of order while issue and commit stay in order. Benefits: an instruction stalled on a long-latency producer (FP divide, cache miss) no longer blocks the independent instructions behind it; higher ILP and unit utilisation; latency hiding; dependences unknown at compile time (memory, misses) are handled; the same binary runs efficiently on different pipelines; it is the base for hardware speculation.

2. Dynamic branch prediction and speculative execution. A branch history table (with a branch target buffer) predicts the outcome and the target at fetch time from the past behaviour of the branch; the processor fetches, issues and executes the predicted path before the branch is resolved, keeping the results in the reorder buffer, and squashes them if the prediction was wrong. Benefits: removes most control stalls, keeps the issue slots of a wide machine full and exposes ILP across branches; the cost is the flush on a misprediction, which grows with pipeline depth and issue width.

3. Multiple-issue pipeline. The front end fetches, decodes and issues up to w instructions per cycle (the issue width) into several functional units, so IPC can exceed 1 and the ideal CPI is 1/w. It needs wider fetch and decode, a multi-ported register file, more functional units and hazard checks across the instructions issued together. Benefit: throughput multiplied by the width when enough independent instructions are available; the ideal is a maximum, rarely sustained because of dependences, branches and misses.

4. Reservation stations. Buffers in front of each functional unit that hold the operation, the operand values already available (Vj, Vk) or the tags of the instructions that will produce them (Qj, Qk); an instruction waits in its station and fires when the last operand arrives on the common data bus. Benefits: hazard detection is distributed (no central bottleneck), operands are fetched once at issue, so WAR hazards vanish, the station's tag renames the destination, so WAW hazards vanish, and issue continues past a waiting instruction.

5. Dynamic register renaming. At issue, every destination register is mapped to a new name — a reservation-station tag, a ROB entry or a physical register — and later readers are redirected to that name, so two instructions that reuse the same architectural register no longer conflict. Benefits: WAR and WAW hazards, which are name dependences, are eliminated; only true RAW dependences remain; more instructions can be in flight and loop iterations overlap without unrolling.

6. Out-of-order execution. Instructions execute in the order in which their operands become ready rather than in program order; issue and commit remain in order and results are broadcast on the common data bus to the waiting consumers. Benefits: independent instructions fill the cycles that dependent ones would waste, long latencies (loads, FP operations) are overlapped and more ILP is extracted from the instruction window; the cost is renaming, reservation stations and a reorder buffer to keep exceptions precise.

7. Reorder buffer. A FIFO in program order that holds each result from write-result to commit; the entry at the head commits to the register file (or to memory, for a store) only when it is complete and no longer speculative. Benefits: precise exceptions and an architectural state updated in program order; speculation can be undone by discarding the entries after a mispredicted branch; the register file is written only at commit.

8. Simultaneous multithreading. Several hardware threads issue in the same cycle into the functional units of one out-of-order core, each with its own PC and rename table, sharing the units and the caches. Benefits: thread-level parallelism fills the issue slots that the ILP of one thread leaves empty (both horizontal and vertical waste), so throughput rises at a small hardware cost; the ideal CPI of the core stays 1/w and the ideal per-thread CPI is threads/w; threads contend for caches and units, so single-thread performance can drop.

Five lines per item is the paper's own allowance: name the mechanism in one sentence, then the benefit, then one cost or condition. The examiner looks for the key words of each row (in-order issue, out-of-order execution, tags, broadcast, in-order commit, precise exceptions, threads/w) and for the distinction between items 1 and 6 — dynamic scheduling is the policy, out-of-order execution is what it produces.

Lesson 8 · Doing more per cycle: superscalar, static vs dynamic scheduling, the limits of ILP · question 2 of 6 · open in the lesson

Compare static (VLIW) and dynamic (superscalar) scheduling: who schedules the instructions and when, the main advantages and drawbacks of each approach, and their typical application domains.

Show model answer

Static (VLIW). The compiler, at compile time, packs independent operations into long instruction words, scheduling around the known latencies and inserting NOPs where no operation fits. Advantages: simple hardware (no dependence checks, no renaming, no out-of-order logic), predictable timing, low energy per instruction. Drawbacks: performance depends entirely on the compiler and on the visible ILP; the binary is tied to one machine configuration (units, latencies), so it must be recompiled for a new one; the schedule cannot adapt to run-time events such as cache misses or mispredictions; unused slots become NOPs, lowering the code efficiency IC/(cycles × issues). Domains: embedded, real-time, DSP and domain-specific processors.

Dynamic (superscalar). The hardware, at run time, detects the parallelism with reservation stations, register renaming and a reorder buffer, and issues whatever is ready. Advantages: adapts to unpredictable latencies, keeps binary portability (no recompilation), exploits the hidden parallelism of general-purpose code. Drawbacks: complexity, area and power; the scheduling logic becomes the bottleneck at wide issue widths; timing is hard to verify. Domains: general-purpose x86 and ARM cores. Both aim at IPC above 1; the trade-off between hardware complexity and compiler sophistication decides where each wins.

The two columns of Table 12 in sentences. Say explicitly who and when in the first line of each half; the binary-compatibility point and the NOP/code-efficiency point are the drawbacks the examiner expects to see named.

Lesson 8 · Doing more per cycle: superscalar, static vs dynamic scheduling, the limits of ILP · question 3 of 6 · open in the lesson

Let's consider a dual-issue SMT processor that can manage up to 4 hardware threads. What are the values of the ideal CPI and the ideal per-thread CPI? (Single answer.)

  • Ideal CPI = 1 & ideal per-thread CPI = 0.25 A dual-issue core has ideal CPI 1/2, not 1; and a thread with a quarter of the slots cannot have a CPI below the core's.
  • Ideal CPI = 0.25 & ideal per-thread CPI = 0.25 0.25 would be a quad-issue core; the per-thread CPI is always larger than the core's when several threads share it.
  • Ideal CPI = 0.5 & ideal per-thread CPI = 2 Core: 1/w = 1/2 = 0.5. The four threads share the two slots, so each ideally completes half an instruction per cycle: per-thread CPI = threads/w = 4/2 = 2.
  • Ideal CPI = 0.5 & ideal per-thread CPI = 1 The core is right; 1 per thread would need 2 threads on 2 slots (or 4 threads on 4 slots).
  • Ideal CPI = 0.25 & ideal per-thread CPI = 4 Both numbers belong to other machines: 0.25 is quad-issue, 4 would be 8 threads on 2 slots.
Show model answer

Answer 3: ideal CPI = 1/issue width = 1/2 = 0.5; ideal per-thread CPI = threads/issue width = 4/2 = 2.

The same question is in all three papers, always with five options built from the same numbers permuted: dual-issue with 4 threads in July 2024 and June 2026 (0.5 and 2), quad-issue with 8 threads in June 2025 (0.25 and 2). In 2026 a second point asks for a practical example of SMT scheduling with up to 4 threads on the dual-issue core. The two formulas are all you need here; the reasoning behind them and the scheduling example are lesson 29.

Lesson 8 · Doing more per cycle: superscalar, static vs dynamic scheduling, the limits of ILP · question 4 of 6 · open in the lesson

Considering superscalar processors, which of the following statements are TRUE? (Multiple answers; motivate each.)

  • Doubling the number of issues reduces the CPI metric. True for the ideal CPI = 1/issue width (0.5 becomes 0.25); the achieved CPI improves only as far as the ILP, the dependences and the memory system allow.
  • Out-of-order execution can be generated by data cache misses. True: a missing load stalls its own chain while the dynamic scheduler keeps executing the independent instructions in the window, so later instructions finish earlier — the miss triggers it, the scheduler does it.
  • The introduction of dynamic branch predictors improves the CPI metric. True: fewer mispredictions mean fewer flushes; CPI = CPI_ideal + branch frequency × misprediction rate × penalty.
  • Doubling the issue width halves the execution time of any program. False: only the ideal CPI halves. The serial part of the program (Amdahl), the branches and the misses are untouched, and beyond 3–4 issue slots real programs rarely offer enough independent instructions.
Show model answer

Statements 1, 2 and 3 are true (1 only for the ideal CPI, 1/issue width); statement 4 is false, because dependences, branches and memory stalls do not shrink with the width and Amdahl's law bounds the gain at 1/f.

The first three statements are the True/False quiz of the 5 May 2025 midterm (notes pp. 540–541); the fourth is the standard distractor. The motivation earns the extra point: write "ideal", name the scheduler as the mechanism behind the miss, and write the CPI formula with its branch term.

Lesson 8 · Doing more per cycle: superscalar, static vs dynamic scheduling, the limits of ILP · question 5 of 6 · open in the lesson

A program spends 20 % of its execution time in a part that must run sequentially. The rest is accelerated 4 times by a wider, out-of-order core. What is the overall speedup?

Show model answer

Serial fraction \(f = 0.2\), \(p = 4\):

\[ \mathrm{Speedup} = \frac{1}{0.2 + \dfrac{0.8}{4}} = \frac{1}{0.4} = 2.5 \]

In the formula sheet's form, \(F = 0.8\) and \(S = 4\): \(1/(0.2 + 0.8/4) = 2.5\). The ceiling for this program is \(1/0.2 = 5\).

Read the fraction first: "20 % sequential" is the serial \(f\), so \(F = 0.8\). The typical slip is to put 0.2 into the sheet's \(F\) and get \(1/(0.8 + 0.05) = 1.18\).

Lesson 8 · Doing more per cycle: superscalar, static vs dynamic scheduling, the limits of ILP · question 6 of 6 · open in the lesson

A compiler schedules the 10 operations of one loop iteration on a 3-issue VLIW processor in 7 cycles (delay slot included). How much is the code efficiency for a single iteration, in percent?

Show model answer
\[ \text{code efficiency} = \frac{\mathrm{IC}}{\#\text{cycles} \times \#\text{issues}} \] \[ = \frac{10}{7 \times 3} = \frac{10}{21} = 47.6\,\% \]

The formula is on the example formula sheet; the exam's VLIW exercises ask it after the schedule, together with the critical path, the CPI and the FP operations per cycle (lesson 20). Eleven of the 21 slots are NOPs.

To the filters ↑

Module 4 · Dynamic scheduling: scoreboard, Tomasulo, reorder buffer

67 questions · Notes, chapter 3.6–3.9 and the past papers · the three algorithms the exam tables are built on

Lesson 9 · The chalkboard that beat the pipeline: the scoreboard

Lesson 9 · The chalkboard that beat the pipeline: the scoreboard · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of dynamic scheduling with the scoreboard: (i) the assumptions of the model; (ii) the four stages and the hazard checked in each; (iii) the three data structures and the role of Qj/Qk and Rj/Rk; (iv) the main limitations and how Tomasulo's algorithm overcomes them.

Show model answer

(i) Single-issue, in-order issue; out-of-order read of operands, execution and write-back; no forwarding (a result is visible only after it is written in the register file); several independent functional units ("multiple pipelined FUs" in the notes) with different latencies, each holding one instruction from issue to write result in the tables; no register renaming, so WAW and WAR hazards must be handled by stalls; exceptions are imprecise.

(ii) Issue (in order): structural hazard — the functional unit must be free — and WAW — no pending write to the destination in the register result status. Read Operands (out of order): RAW — both source operands written to the register file (and read ports available). Execute: no hazard, latency of the unit. Write Result (out of order): WAR — no earlier instruction still waiting to read the destination (and a write port free).

(iii) Instruction status: the stage reached by each instruction (the I / RR / E / WB table). Functional-unit status, one row per unit: Busy, Op, Fi (destination), Fj, Fk (sources), Qj, Qk (the units that will produce Fj, Fk; blank if the value is in the register file), Rj, Rk (source ready and not yet read; set to No when the operands are read). Register result status: for each register, the unit that will write it. Qj/Qk say who produces an operand, Rj/Rk say whether it may be read now; Rj = No after the read is what the WAR test of Write Result uses. Benefits: independent instructions overlap, long latencies are hidden, functional units are better used, no compiler support is needed.

(iv) Limits: the parallelism available in the window, the number of scoreboard entries, the number and types of functional units, WAR/WAW stalls because there is no renaming, one extra cycle per RAW dependence because there is no forwarding, centralized control, imprecise exceptions. Tomasulo adds register renaming through reservation stations (WAR and WAW disappear), the Common Data Bus (results forwarded to every waiting station, distributed hazard detection) and, with a reorder buffer, speculation and precise exceptions.

The examiner checks three things: that you put each hazard in its stage (WAW at Issue, RAW at Read Operands, WAR at Write Result — not "the scoreboard checks hazards"), that you say what Qj and Rj are each for, and that part (iv) names concrete limits and the concrete Tomasulo mechanism that removes each. Write short labelled statements, one per line, as the paper's blank lines invite.

Lesson 9 · The chalkboard that beat the pipeline: the scoreboard · question 2 of 7 · open in the lesson

Consider the following program on a processor with dynamic scheduling based on the SCOREBOARD BASIC SCHEME (check for WAW hazards in the ISSUE stage; no forwarding), with 1 Integer unit (loads, stores and integer operations, latency 1 cycle), 1 FP ADD unit (latency 2 cycles), 2 FP MULT units (latency 4 cycles). Fill the table with the cycles of I, RR, E and WB for each instruction, the type of hazard and the unit, and compute the CPI.

I0: LD    F0, 0(R1)
I1: LD    F2, 8(R1)
I2: FMUL  F4, F0, F2
I3: FADD  F2, F0, F6
I4: SD    F4, 16(R1)
I5: ADDUI R1, R1, 8
Show model answer
InstructionIRREWBHazards TypeUnit
I0: LD F0, 0(R1)1234noneInteger
I1: LD F2, 8(R1)5678Structural Integer (I0)Integer
I2: FMUL F4, F0, F2691314RAW F2 (I1)Mult1
I3: FADD F2, F0, F69101213WAW F2 (I1); WAR F2 with I2 costs nothing (I2 read at 9)Add
I4: SD F4, 16(R1)10151617RAW F4 (I2)Integer
I5: ADDUI R1, R1, 818192021Structural Integer (I4); WAR R1 with I4 costs nothing (I4 read at 15)Integer

I1 issues at 5 because the Integer unit is Busy until I0's write at 4. I2 reads at 9 = WB(I1) + 1. I3 cannot issue while the register result status says F2 = Integer (cycles 7–8); it issues at 9 and writes at 13, allowed because I2 has read F2 at 9. I4 issues at 10 and reads at 15 = WB(I2) + 1; it holds the Integer unit until its write at 17, so I5 issues at 18. Total 21 cycles; CPI = 21 / 6 = 3.5.

The marks hide in the Hazards column and in two conventions: a unit is free again the cycle after its WB (I1, I5), and a consumer reads the cycle after the producer's WB (I2, I4). Say explicitly that the WAR of I3 and I5 costs nothing and why; a bare "WAR" in that column reads as a stall you did not find.

Lesson 9 · The chalkboard that beat the pipeline: the scoreboard · question 3 of 7 · open in the lesson

In the fragment of this lesson (I0 LD F2, 0(R1), I1 FMUL F4, F2, F0, I2 FADD F6, F4, F8, I3 LD F8, 8(R1), I4 FMUL F8, F2, F0, I5 SD F6, 16(R1); Integer 1, Add 2, Mult 4; basic scheme), in which cycle does I3 write its result?

Show model answer

I3 completes execution at cycle 7 but I2 (FADD F6, F4, F8) still has to read F8; I2 reads only at cycle 11 (= WB of I1 + 1). WAR on F8: WB(I3) = max(7 + 1, 11 + 1) = 12.

The wrong answer 8 forgets the WAR test; the wrong answer 11 forgets that the write comes the cycle after the read.

Lesson 9 · The chalkboard that beat the pipeline: the scoreboard · question 4 of 7 · open in the lesson

In the basic scoreboard scheme a WAR hazard is resolved by: (single answer)

  • stalling the reader in the Read Operands stage That is what the scoreboard does for a RAW hazard; a WAR hazard is about a writer that is too early.
  • stalling the writer in the Write Result stage until every earlier reader has read the register The write is postponed while a unit row has the register as a source with Rj or Rk still Yes.
  • renaming the destination register The scoreboard has no renaming; that is Tomasulo's answer.
  • stalling the writer in the Issue stage Issue stalls on structural and WAW hazards, not on WAR.
Show model answer

Answer 2: the later writer waits at Write Result until the earlier reader has read its operands (Rj/Rk back to No).

Each hazard has its stage; the quiz checks that you do not put WAR at Issue because "it is checked early".

Lesson 9 · The chalkboard that beat the pipeline: the scoreboard · question 5 of 7 · open in the lesson

In the functional-unit status table, Rj = No means: (single answer)

  • the operand Fj is not ready yet That is one of the two cases, not the only one.
  • the operand Fj has already been read That is the other case, not the only one.
  • either "not ready yet" or "already read" — and both are safe for a later writer, because the basic scheme blocks WAW at Issue The flag means "ready and not yet read"; after the read it is reset to No, and the Write Result test only has to look for a Yes.
  • the unit is idle An idle unit has Busy = No; the flags of an idle row are blank.
Show model answer

Answer 3: Rj, Rk are "ready and not yet read"; No covers both "waiting for the producer" and "already read", and a writer may proceed in both cases.

With the notes' definition ("ready") you can explain why the write of ADDD in the notes' example waits (the Divide row says Rk = Yes for F6) but not why it is released at cycle 22: a flag that only meant "ready" would stay Yes for ever.

Lesson 9 · The chalkboard that beat the pipeline: the scoreboard · question 6 of 7 · open in the lesson

True or false: in the scoreboard, a functional unit becomes free as soon as its instruction completes execution.

  • True The result may still be waiting to be written (a WAR hazard, or a busy write port), and the unit holds it meanwhile.
  • False The unit is Busy from issue through write result; the next instruction for it can issue the cycle after the write.
Show model answer

False: Busy is cleared at Write Result, not at the end of execution. Example: in the fragment of this lesson I0 completes execution at cycle 3 and writes at 4; I3, which needs the same Integer unit, issues at 5, not at 4.

"Motivate your answer" is worth the extra point: give a cycle from a table.

Lesson 9 · The chalkboard that beat the pipeline: the scoreboard · question 7 of 7 · open in the lesson

Why does the basic scoreboard check WAW hazards at the Issue stage rather than at Write Result, and what must change in the hardware if the check is postponed to the write-back phase, as in the "optimised" scheme?

Show model answer

Without renaming the two writes to the same register must land in program order. Checking at Issue is the simplest guarantee: issue is in order, so the instruction being issued is always the later writer, and one lookup in the register result status (a non-blank entry for its destination) settles it. It also keeps the Write Result test simple: because two pending writes to one register can never coexist, a source flag Rj = No can only mean "already read" or "waiting for this very writer", so the WAR test may let the writer through on a No.

If the check is postponed to write-back, the later writer issues and executes early (it no longer blocks the instructions behind it), but the Write Result stage must additionally enforce WB(second) > WB(first) for every earlier pending writer of the same register — i.e. the hardware must track, per register, more than one pending writer and order the writes explicitly.

The second paragraph is what distinguishes a full answer: name the benefit (earlier issue, no in-order stall) and the new obligation (explicit ordering of the writes). Lesson 10 computes the gain on the January 2026 paper: 25 cycles become 21.

Lesson 10 · 62 cycles, one at a time: the scoreboard example and the exam table

Lesson 10 · 62 cycles, one at a time: the scoreboard example and the exam table · question 1 of 7 · open in the lesson

Consider the following program on a CPU with dynamic scheduling based on the SCOREBOARD BASIC SCHEME (check for WAW hazards in the ISSUE stage; no forwarding), with 1 Integer unit for the loads (latency 1, all cache hits), 2 FP MULT units (latency 10), 1 FP ADD unit (latency 2) and 1 FP DIV unit (latency 40). (a) Fill the table with I, RR, E and WB for each instruction, the hazard type and the unit, and compute the CPI. (b) Which hazard delays the write of I5, and until which cycle? (c) Would a second FP ADD unit reduce the total number of cycles? Justify.

I0: LD   F6, 34(R2)
I1: LD   F2, 45(R3)
I2: FMUL F0, F2, F4
I3: FSUB F8, F6, F2
I4: FDIV F10, F0, F6
I5: FADD F6, F8, F2
Show model answer
InstructionIRREWBHazards TypeUnit
I0: LD F6, 34(R2)1234noneInteger
I1: LD F2, 45(R3)5678Structural Integer (I0)Integer
I2: FMUL F0, F2, F4691920RAW F2 (I1)Mult1
I3: FSUB F8, F6, F2791112RAW F2 (I1)Add
I4: FDIV F10, F0, F68216162RAW F0 (I2)Divide
I5: FADD F6, F8, F213141622Structural Add (I3); WAR F6 (I4)Add

(a) 62 cycles; CPI = 62 / 6 ≈ 10.3. I1 issues at 5 because the Integer unit is Busy through I0's WB at 4; I2 and I3 read at 9 = WB(I1) + 1; I4 reads at 21 = WB(I2) + 1; I5 issues at 13, the cycle after I3's WB.

(b) A WAR hazard on F6 with I4: I4 reads F6 only at 21, because it waits for F0 (written at 20); I5 completes at 16 and writes at RR(I4) + 1 = 22.

(c) No. With a second adder I5 issues at 9 and completes at 15, but it still cannot write before I4 has read F6, so WB(I5) = 22; the total is fixed by the chain LD F2 → FMUL → FDIV, which ends at 62 whatever happens to the adds.

Three conventions decide the numbers: the unit is Busy through its WB (I1 at 5, I5 at 13), the consumer reads at WB + 1 (I2, I3, I4), and the WAR delays only the write. Part (c) asks, in effect, whether you know what a critical path is: name the chain and say the add is not on it.

Lesson 10 · 62 cycles, one at a time: the scoreboard example and the exam table · question 2 of 7 · open in the lesson

Consider the program of the January 2026 paper (I0 LD F2, VB(R6); I1 FADD F4, F2, F6; I2 SD F4, VA(R7); I3 LD F4, VC(R6); I4 SD F4, VC(R7); I5 ADDUI R6, R6, 4; I6 ADDUI R7, R7, 4) on the same resources (2 LOAD/STORE units LDU1, LDU2 with latency 3; 1 FP unit FPU1 with latency 3; 1 ALU/BR unit ALU1 with latency 1), with FORWARDING but with the check for WAW hazards still in the ISSUE stage. Row I0 is given: 1, 2, 5, 6, LDU1. Fill the table, compute the CPI and the speedup with respect to the basic scheme (25 cycles).

Show model answer
InstructionIRREWBHazards TypeUnit
I0: LD F2, VB(R6)1256none (given)LDU1
I1: FADD F4, F2, F626910RAW F2 (I0), forwarded: RR = WB(I0)FPU1
I2: SD F4, VA(R7)3101314RAW F4 (I1), forwardedLDU2
I3: LD F4, VC(R6)11121516Structural LDU1/LDU2 (I0, I2), then WAW F4 (I1) at Issue until WB(I1) = 10LDU1
I4: SD F4, VC(R7)15161920Structural LDU1/LDU2 (I3 through 16, I2 through 14): LDU2 at 15; RAW F4 (I3) forwarded, RR = 16LDU2
I5: ADDUI R6, R6, 416171819noneALU1
I6: ADDUI R7, R7, 420212223Structural ALU1 (I5)ALU1

23 cycles; CPI = 23 / 7 ≈ 3.29; speedup = 25 / 23 ≈ 1.09. Forwarding takes one cycle out of each RAW wait (I1, I2, I4); the WAW on F4 still holds I3 at Issue, so the queue behind it moves only with I1's earlier write.

What this variant tests is that forwarding changes the RR rule only (read in the producer's write cycle) and nothing else: I3 still waits at Issue for I1's WB, and the structural rules are untouched. A table that lets I3 issue at 7 has confused this variant with Part B.

Lesson 10 · 62 cycles, one at a time: the scoreboard example and the exam table · question 3 of 7 · open in the lesson

Same program and resources as the January 2026 paper, with the check for WAW hazards postponed to the WRITE BACK phase but NO forwarding. How many clock cycles does the program take (the cycle of the last write-back)?

Show model answer

I1 2–7–10–11 and I2 3–12–15–16 as in the basic scheme (no forwarding). I3 issues at 7 (LDU1 free, no WAW check at Issue), reads at 8, completes at 11 — but may write only after I2 has read F4, at 12 (WAR), and after I1's write at 11 (WAW at write-back): WB = 13. I4 issues at 14 on LDU1, reads F4 at 15 = WB(I3) + 1, E 18, WB 19. I5 15–16–17–18. I6 issues at 19 (ALU1 free after 18), 20, 21, WB = 22. CPI = 22 / 7 ≈ 3.14.

The one row that decides is I3's WB: 12 forgets the WAR with I2, which still reads F4 at 12 because there is no forwarding. Postponing the WAW check never removes the WAR test.

Lesson 10 · 62 cycles, one at a time: the scoreboard example and the exam table · question 4 of 7 · open in the lesson

In a scoreboard with forwarding (columns I, RR, E, WB as in the papers), a consumer of a value produced by instruction P may read its operands at the earliest in cycle: (single answer)

  • E of P In its last execution cycle the producer is still computing; the value exists only at the end of that cycle.
  • WB of P, i.e. E of P + 1 The result leaves the unit at the end of P's last execution cycle and is bypassed around the register file: the consumer reads in the cycle P writes (the notes' solution of January 2026: I0 writes at 6, I1 reads at 6).
  • WB of P + 1 That is the rule without forwarding: the value must be in the register file first.
  • I of P + latency Issue is not where execution starts; the read cycle and any waits come between.
Show model answer

Answer 2: RR = WB of the producer (one cycle earlier than without forwarding).

Do not mix this with Tomasulo's convention of the same papers, where the dependent instruction starts executing the cycle after the producer's WRITE RESULT. Same idea, different column.

Lesson 10 · 62 cycles, one at a time: the scoreboard example and the exam table · question 5 of 7 · open in the lesson

On the program of the January 2026 paper, which single optimisation saves more cycles with respect to the basic scheme (25 cycles)? (single answer)

  • Forwarding (23 cycles) Forwarding saves one cycle per RAW wait — two chained waits here — but leaves I3 stuck at Issue behind the WAW on F4.
  • The WAW check postponed to write-back (22 cycles) I3 issues at 7 instead of 12, and I4, I5, I6 — stuck behind it in the in-order issue queue — move with it.
  • They save the same number of cycles 23 and 22 differ; and with both switched on the total is 21, not 25 − 2 − 3.
  • Neither: the structural hazards fix the total Each one alone saves cycles (23 and 22 instead of 25); the structural waits remain, but they are not the whole story.
Show model answer

Answer 2: postponing the WAW check (22) beats forwarding (23); together they give 21.

"Motivate your answer" is the extra point: say that the WAW stall blocks the in-order issue queue, so removing it moves four instructions at once.

Lesson 10 · 62 cycles, one at a time: the scoreboard example and the exam table · question 6 of 7 · open in the lesson

True or false: in the basic scoreboard scheme a WAR hazard can delay the execution of the later instruction.

  • True The later instruction reads and executes as soon as its own sources are ready; only its write is held.
  • False WAR is checked at Write Result: the writer completes on time and keeps its result in the unit until every earlier reader has read.
Show model answer

False. In the notes' example FADD F6 reads at 14 and completes at 16 although FDIV, an earlier reader of F6, reads only at 21; the WAR delays FADD's write to 22, not its execution.

Give the cycle numbers: they are the motivation the quiz asks for.

Lesson 10 · 62 cycles, one at a time: the scoreboard example and the exam table · question 7 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques of a scoreboard-based CPU, saying for each which hazard it addresses and what it cannot fix: 1. splitting the decode stage into Issue and Read Operands; 2. checking WAW hazards at write-back instead of at issue; 3. forwarding; 4. in-order issue with out-of-order completion.

Show model answer

1. Issue decodes and checks the resources (a free unit, no pending write to the destination: structural and WAW hazards), in order; Read Operands waits for the sources to be in the register file (RAW), separately for every issued instruction. Benefit: an instruction waits in the row of its own unit while independent later instructions issue behind it and may read before it (in the notes' example FADD, issued at 13, reads at 14 while FDIV, issued at 8, reads at 21). Cannot fix: a stall at Issue still blocks every later instruction.

2. The register result table is not consulted at Issue, so a later writer of a busy register issues as soon as a unit is free; Write Result then enforces the order of the two writes (WB of the second after WB of the first) in addition to the WAR test. Benefit: the in-order issue queue is not blocked by an output dependence (January 2026: I3 issues at 7 instead of 12 and the three instructions behind it issue 3 cycles earlier: 25 → 22). Cannot fix: the dependence itself — the two writes are still serialised, and the WAR test can still delay the second write; only renaming removes it.

3. A result is bypassed from the unit to a waiting consumer in the cycle it is written instead of after the register-file write: each RAW wait is one cycle shorter (RR = WB of the producer). Benefit: one cycle per link of every true-dependence chain (January 2026: 25 → 23). Cannot fix: the latency itself, and nothing about structural, WAW or WAR waits.

4. Instructions enter in program order, which keeps the hardware simple (the instruction being issued is always the later writer, so one lookup settles a WAW), and leave as soon as they are done, which lets independent instructions overlap long latencies (in the notes' example the subtract and the add complete inside the load–multiply–divide chain, which alone sets the 62 cycles). Cannot fix: WAR and WAW stalls (no renaming), imprecise exceptions (no reorder buffer), and the stalls of the issue queue behind a blocked instruction.

Four short lines per technique are enough: what it is, which hazard it addresses, what it buys (with a number from an exercise if you have one) and what it does not fix. The last line is what separates a full answer from a definition.

Lesson 11 · Names, not values: Tomasulo’s architecture

Lesson 11 · Names, not values: Tomasulo’s architecture · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by modern superscalar processors (Tomasulo-style): 4. Reservation stations; 5. Dynamic register renaming; 6. Out-of-order execution. (Three of the eight items of Question 1, 22 June 2026 — five lines each.)

Show model answer

Reservation stations. Buffers in front of each functional unit. An issued instruction waits there with its operation, its operand values (Vj, Vk) or the tags of the producers it waits for (Qj, Qk), and a busy bit. They decouple issue from execution: an instruction waits locally for its operands instead of blocking the pipeline, the station’s name is the temporary name of its result (renaming), and the control is distributed — each unit schedules itself. Benefit: no central scoreboard, no stall of the instructions behind a waiting one, more instructions in flight than there are registers.

Dynamic register renaming. At issue the destination register’s status field Qi is set to the station’s tag, and every later consumer records that tag instead of the register name. Results are broadcast with the tag; a register is written only if its Qi still holds that tag (the newest writer owns the register). Benefit: WAR and WAW hazards — name dependences — can never stall or corrupt; only true RAW dependences remain; the renaming is done by hardware, invisible to the ISA, so the register count of the ISA no longer limits scheduling.

Out-of-order execution. An instruction leaves its station for the functional unit as soon as Qj = Qk = 0 and the unit is free, independently of program order; results return out of order over the common data bus. Benefit: independent instructions proceed while a long-latency one (a load, a divide) waits, so stalls are filled and the CPI falls. Cost: completion out of order gives imprecise exceptions unless a reorder buffer restores in-order commit.

The form of the real question is a table with five lines per item: write labelled statements, not an essay. Full marks need the concept (what the structure holds or does), the mechanism (tags, Qi, the CDB) and a benefit stated as a benefit; for item 6, naming the cost (imprecise exceptions) shows you know what the next item, the reorder buffer, is for.

Lesson 11 · Names, not values: Tomasulo’s architecture · question 2 of 6 · open in the lesson

Why does the scoreboard stall on a WAR hazard while Tomasulo’s algorithm does not? Where in Tomasulo’s three stages is the WAR hazard resolved?

Show model answer

In the scoreboard an instruction reads its operands from the register file in the Read Operands stage. A later instruction that writes one of those registers must therefore wait at Write Result until the read has happened, otherwise the reader would get the new value: the WAR hazard costs a stall of the writer. In Tomasulo’s algorithm the reader takes a copy of the operand at Issue (into Vj/Vk) if it is available, or records the producer’s tag (Qj/Qk) and receives the value from the CDB; it never reads the register file later. The later writer cannot overwrite anything the reader still needs; it only sets the register’s Qi to its own station. The WAR hazard is dissolved at Issue — copy or tag — and no stage ever stalls for it.

Two sentences carry the marks: “the reader copies or tags at issue and never returns to the register” and “the writer renames the register to its own station”. The stage asked for is Issue.

Lesson 11 · Names, not values: Tomasulo’s architecture · question 3 of 6 · open in the lesson

Let’s consider the following assembly code containing multiple types of intra-loop dependences. Complete the following table by inserting all types of true-data-dependences, anti-dependences and output dependences for each instruction (I0 and I2: None). (Part 1 of Exercise 1, 22 June 2026.)

I0  FOR: LD    F2, AA(R1)
I1       FADD  F2, F2, F2
I2       LD    F4, BB(R1)
I3       FADD  F2, F2, F4
I4       SD    F2, A(R1)
I5       ADDUI R1, R1, 8
I6       BNE   R1, R2, FOR
Show model answer
I#Dependences
I0None
I1True data dependence with I0 for F2; output dependence with I0 for F2
I2None
I3True data dependence with I1 for F2 and with I2 for F4; anti-dependence with I1 for F2 (I1 reads F2, I3 writes it); output dependence with I1 and with I0 for F2
I4True data dependence with I3 for F2
I5Anti-dependence with I0, I2 and I4 for R1 (they read R1, I5 writes it)
I6True data dependence with I5 for R1

The paper wants every pair named “with I# for Fx”. The ones students miss: the anti-dependences of the ADDUI on every earlier reader of R1 (two loads and the store), and the output dependence of I3 on I0 as well as on I1. In the Tomasulo table of part 2 (lesson 12) all the WAR and WAW entries are “solved by renaming” — but part 1 asks you to find them.

Lesson 11 · Names, not values: Tomasulo’s architecture · question 4 of 6 · open in the lesson

In Tomasulo’s algorithm, a reservation station is released: (single answer)

  • when the instruction is issued into it At issue the station is filled, not freed: it must hold the operands or tags until the instruction can execute.
  • when the instruction starts execution in the functional unit The station stays busy while the unit works; it still has to deliver the result with its tag.
  • when the instruction writes its result on the CDB Write result: broadcast the pair, fill every waiting field, write the register if Qi matches, free the station.
  • when the next instruction of the same type is issued A later instruction can take the station only because it is already free — from the cycle after the write result.
Show model answer

Answer 3: the station is busy from Issue through Write Result and reusable from the next cycle.

The notes themselves say “the RS is now free” during execution on page 155; that is the wrong answer here and the wrong ISSUE column in the exercise.

Lesson 11 · Names, not values: Tomasulo’s architecture · question 5 of 6 · open in the lesson

Which of the following can stall the ISSUE stage of Tomasulo’s algorithm? (multiple answers)

  • a RAW hazard on a source register No: the instruction is issued with the producer’s tag in Qj or Qk and waits inside its station.
  • no free reservation station of the required type The structural hazard — the most common “STRUCTURAL” entry in the exam tables.
  • a WAW hazard on the destination register No: the destination is renamed to the new station; the older writer’s claim is simply forgotten.
  • a full load/store buffer A load or store needs a free buffer of its own kind, exactly as an FP operation needs a free station.
  • an unresolved branch in a machine without speculation Without speculation the instructions after the branch cannot be issued until it resolves — dynamic scheduling stays inside the basic block.
Show model answer

Answers 2, 4 and 5. Data hazards never stall issue in Tomasulo’s algorithm: RAW waits in the station, WAR and WAW are dissolved by the tags.

The question tests the one thing the scoreboard and Tomasulo disagree about at Issue: WAW stalls the scoreboard there and never stalls Tomasulo.

Lesson 11 · Names, not values: Tomasulo’s architecture · question 6 of 6 · open in the lesson

True or false: in Tomasulo’s algorithm a store instruction writes its result on the common data bus.

  • True A store has no destination register; nothing can wait for its tag, so there is nothing to broadcast.
  • False A store waits for its address and its data (the data may arrive from the CDB), then writes memory. It listens on the bus and never speaks on it.
Show model answer

False: the store buffer monitors the CDB for its data and writes memory; it broadcasts nothing. In the exam table its WRITE RESULT entry is the cycle the memory write completes.

“Motivate your answer” is worth the extra point: say what the store waits for and where its result goes.

Lesson 12 · Issue, execute, write result: the three stages and the exam table

Lesson 12 · Issue, execute, write result: the three stages and the exam table · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by modern superscalar processors (Tomasulo-style): 4. Reservation stations; 5. Dynamic register renaming; 6. Out-of-order execution. (Five lines each.)

Show model answer

Reservation stations. Buffers in front of each functional unit, each holding one issued instruction: its operation, its operand values (Vj, Vk) if they were available at issue, otherwise the tags (Qj, Qk) of the stations that will produce them, and a busy bit; the station's name is the tag under which its result will be broadcast. Benefits: the instruction leaves the in-order front end at once (a RAW dependence never stalls issue), waits locally and fires as soon as both operands arrive (data-driven execution); hazard detection is distributed, there is no central scoreboard; the stations give pending results more names than the ISA has registers. Cost: when all stations of a class are busy, issue stalls (structural hazard).

Dynamic register renaming. At issue the destination register's status field Qi is set to the station's tag, so the register always names its youngest writer; a consumer copies the value or the producer's tag at issue and never reads the register later. A result is broadcast with its tag, captured by every waiting station, and written into the register only if Qi still holds that tag. Benefits: WAR and WAW hazards (name dependences created by register reuse in loops and by the compiler's allocation) can neither stall nor corrupt — only true RAW dependences remain; the ISA's register count no longer limits scheduling; it is invisible to the program.

Out-of-order execution. An instruction starts in its unit as soon as Qj = Qk = 0 and the unit is free, independently of program order; results return out of order on the common data bus, one per cycle. Benefits: independent instructions proceed while a long-latency one (a load miss, a divide) waits, so stalls are hidden and throughput rises (lower CPI); latencies unknown at compile time are tolerated. Cost: completion out of order makes exceptions imprecise — a reorder buffer with in-order commit restores them.

The paper gives five blank lines per item: write short labelled statements, mechanism first, then "benefit:", then "cost:" where there is one. A complete answer names the fields of a station, the Qi tag and the "write only if the tag still matches" rule, and the exact firing condition of execution.

Lesson 12 · Issue, execute, write result: the three stages and the exam table · question 2 of 7 · open in the lesson

(Exercise 1, 15 July 2024; registers written without $.) Let's consider the following assembly code containing multiple types of intra-loop dependences. Complete the following table by inserting all types of true-data-dependences, anti-dependences and output dependences for each instruction (I0: None).

I0  FOR: LD    F2, A(R1)
I1       FADD  F2, F2, F2
I2       FADD  F2, F2, F4
I3       SD    F2, A(R1)
I4       ADDUI R1, R1, 8
I5       BNE   R1, R2, FOR

Let's consider the previous assembly code to be executed on a CPU with dynamic scheduling based on TOMASULO algorithm with all cache HITS, a single Common Data Bus and: 2 RESERV. STATIONS (RS1, RS2) with 2 LOAD/STORE units (LDU1, LDU2) with latency 4; 2 RESERVATION STATION (RS3, RS4) with 1 FP unit (FPU1) with latency 3; 2 RESERVATION STATION (RS5, RS6) with 1 INT_ALU/BR unit (ALU1) with latency 2. Please complete the table INSTRUCTION | ISSUE | START EXEC | WRITE RESULT | Hazards Type | RSi | UNIT (row I0 given: 1, 2, 6, None, RS1, LDU1). Calculate the CPI.

Show model answer

Dependences: I1 true with I0 for F2, output with I0 for F2; I2 true with I1 for F2, anti with I1 for F2, output with I0 and I1 for F2; I3 true with I2 for F2; I4 anti with I0 and I3 for R1; I5 true with I4 for R1.

INSTRUCTIONISSUESTART EXECWRITE RESULTHazards TypeRSiUNIT
I0 LD F2, A(R1)126NoneRS1LDU1
I1 FADD F2, F2, F22710RAW with I0 for F2; WAW with I0 (renaming)RS3FPU1
I2 FADD F2, F2, F431114RAW with I1 for F2; WAR with I1, WAW with I0, I1 (renaming)RS4FPU1
I3 SD F2, A(R1)41519RAW with I2 for F2RS2LDU2
I4 ADDUI R1, R1, 8568WAR with I0, I3 for R1 (renaming)RS5ALU1
I5 BNE R1, R2, FOR6911RAW with I4 for R1RS6ALU1

Writes on the CDB at 6, 8, 10, 11, 14 and the memory write at 19: no tie. CPI = 19 / 6 ≈ 3.17.

Every instruction issues one cycle after the previous one: with only one store the two load/store stations suffice. The whole loop is one RAW chain through F2, LD → FADD → FADD → SD; the integer tail runs underneath it. If you name a WAR or a WAW in the Hazards column, add "solved by renaming", so that it cannot be read as a stall.

Lesson 12 · Issue, execute, write result: the three stages and the exam table · question 3 of 7 · open in the lesson

(Exercise 1, 10 June 2025; registers written without $.) Let's consider the following assembly code containing multiple types of intra-loop dependences. Complete the following table by inserting all types of true-data-dependences, anti-dependences and output dependences for each instruction (I0, I1, I2: None).

I0  FOR: LD    F2, A(R1)
I1       LD    F4, B(R1)
I2       LD    F6, C(R1)
I3       FADD  F4, F2, F4
I4       FADD  F6, F4, F6
I5       SD    F6, A(R1)
I6       ADDUI R1, R1, 8
I7       BNE   R1, R2, FOR

Let's consider the previous assembly code to be executed on a CPU with dynamic scheduling based on TOMASULO algorithm with all cache HITS, a single Common Data Bus and: 2 RESERV. STATIONS (RS1, RS2) with 2 LOAD/STORE units (LDU1, LDU2) with latency 4; 2 RESERVATION STATION (RS3, RS4) with 2 FP units (FPU1, FPU2) with latency 3; 2 RESERVATION STATION (RS5, RS6) with 2 INT_ALU/BR units (ALU1, ALU2) with latency 2. Please complete the table INSTRUCTION | ISSUE | START EXEC | WRITE RESULT | Hazards Type | RSi | UNIT (rows given: I0 = 1, 2, 6, None, RS1, LDU1; I1 = 2, 3, 7, None, RS2, LDU2). Calculate the CPI.

Show model answer

Dependences: I3 true with I0 for F2 and I1 for F4, output with I1 for F4; I4 true with I3 for F4 and I2 for F6, output with I2 for F6; I5 true with I4 for F6; I6 anti with I0, I1, I2 and I5 for R1; I7 true with I6 for R1.

INSTRUCTIONISSUESTART EXECWRITE RESULTHazards TypeRSiUNIT
I0 LD F2, A(R1)126NoneRS1LDU1
I1 LD F4, B(R1)237NoneRS2LDU2
I2 LD F6, C(R1)7812Structural: no free load/store RS at 3–6 (RS1 busy until 6)RS1LDU1
I3 FADD F4, F2, F48913RAW with I0 for F2, I1 for F4 (satisfied at issue); WAW with I1 (renaming); issue delayed behind I2; Structural: CDB taken at 12 by I2RS3FPU1
I4 FADD F6, F4, F691417RAW with I3 for F4, I2 for F6; WAW with I2 (renaming); issue delayed behind I2RS4FPU2
I5 SD F6, A(R1)101822RAW with I4 for F6; issue delayed behind I2RS2LDU2
I6 ADDUI R1, R1, 8111214WAR with I0, I1, I2, I5 for R1 (renaming); issue delayed behind I2RS5ALU1
I7 BNE R1, R2, FOR121518RAW with I6 for R1; issue delayed behind I2; Structural: CDB taken at 17 by I4 (17 if the branch takes no CDB slot)RS6ALU2

CPI = 22 / 8 = 2.75.

Two traps. The third load finds both load/store stations busy at cycles 3–6 and issues only at 7, and in-order issue holds every later instruction behind it although the FP and integer units are idle — two stations per class cannot hold three loads at once. And the single CDB produces two ties, at 12 and at 17: the older instruction writes, the younger slips. The second FP unit changes nothing here, because I4 depends on I3 anyway.

Lesson 12 · Issue, execute, write result: the three stages and the exam table · question 4 of 7 · open in the lesson

Consider the loop of Exercise 1 of 22 June 2026 (this lesson's loop) on the same CPU, except that the LOAD/STORE class has 3 reservation stations instead of 2 (still 2 load/store units). Calculate the CPI of one iteration.

Show model answer

The store now finds a free station at cycle 5 (ISSUE 5 instead of 7), ADDUI issues at 6 (6 / 7 / 9) and BNE at 7 (7 / 10 / 12, no tie on the CDB any more). But the store still needs F2 from I3, written at 14: START EXEC 15, WRITE RESULT 15 + 4 = 19. CPI = 19 / 7 ≈ 2.71, unchanged.

The extra station removes the structural stall and the CDB tie, but neither was on the critical path LD → FADD → FADD → SD. The typical wrong answer moves the store's WRITE RESULT two cycles earlier together with its ISSUE (17 / 7 ≈ 2.43).

Lesson 12 · Issue, execute, write result: the three stages and the exam table · question 5 of 7 · open in the lesson

In Tomasulo's algorithm a reservation station is released: (single answer)

  • when the instruction is issued into it Issue is when it is allocated; it then holds the instruction's operands and tags.
  • when the instruction starts execution in the functional unit The station stays busy during execution; the exam counts it busy through the write cycle.
  • when the instruction writes its result on the CDB Step 4 of Write Result frees the station; it can take a new instruction from the next cycle.
  • when the next instruction of the same type is issued If no station is free, the next instruction of that type waits; it never evicts.
Show model answer

Answer 3: a station is busy from ISSUE through WRITE RESULT and reusable from the cycle after the write.

The notes' page 155 suggests answer 2 (the red pen in the section on Execute); every solved table is built on answer 3 (the June 2026 store issues at 7, not at 5).

Lesson 12 · Issue, execute, write result: the three stages and the exam table · question 6 of 7 · open in the lesson

Which of the following can stall the ISSUE stage of Tomasulo's algorithm? (multiple answers)

  • a RAW hazard on a source register No: the instruction is issued with a tag in Qj or Qk and waits inside its station.
  • no free reservation station of the required type The structural hazard of every exam table: the instruction and everything behind it wait.
  • a WAW hazard on the destination register No: the destination is simply renamed to the new station; the older writer's broadcast will be dropped at the register file.
  • a full load/store queue Memory operations need a buffer entry, exactly like a station.
  • an unresolved branch, in a machine without speculation Without speculation the instructions after the branch must wait for it (the notes list it among the issue stalls); without a prediction the next instruction is not even known.
Show model answer

Answers 2, 4 and 5. Data hazards never stall issue: RAW waits in the station, WAW and WAR are dissolved by renaming.

The quiz checks that you separate the issue stall of the scoreboard (a WAW, or a busy unit) from Tomasulo's: a missing station or buffer entry and, without speculation, a pending branch — never a data hazard.

Lesson 12 · Issue, execute, write result: the three stages and the exam table · question 7 of 7 · open in the lesson

True or false: in Tomasulo's algorithm a store instruction writes its result on the Common Data Bus. Motivate your answer.

  • True A store produces no register value; nothing in the machine could be waiting for its tag.
  • False A store writes memory when its address and data are ready; the WRITE RESULT cell of the table is the end of that memory write, and it takes no CDB slot.
Show model answer

False. A store waits in its load/store station for the address and the data (the data may arrive by tag over the CDB), then writes memory; it broadcasts nothing because no later instruction reads a register from it. In the June 2026 table the store's WRITE RESULT = 15 + 4 = 19 is its memory write, and it never competes for the bus.

"Motivate your answer" carries its own point in the papers: name the mechanism (no register result, a memory write, no tag anyone waits for) and, if you can, the cycle from a table.

Lesson 13 · Tomasulo cycle by cycle, and what it fixes compared with the scoreboard

Lesson 13 · Tomasulo cycle by cycle, and what it fixes compared with the scoreboard · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by modern superscalar processors (Tomasulo-style): 4. Reservation stations; 5. Dynamic register renaming; 6. Out-of-order execution.

Show model answer

Reservation stations. Buffers in front of each functional unit. An issued instruction waits there with its opcode, its operand values (Vj, Vk) if they were available at issue, otherwise the tags (Qj, Qk) of the stations that will produce them; the station is itself the tag under which the result will be broadcast. Benefits: the instruction leaves the in-order front end at once (no issue stall on a RAW hazard), waits locally and fires as soon as both operands arrive, results reach every waiting station and the register file in one cycle through the common data bus (forwarding), and hazard detection is distributed instead of centralized in a scoreboard.

Dynamic register renaming. At issue the destination register's status field Qi is set to the station's tag, so the register names its youngest producer; consumers take a value or a tag at issue and never consult the register name again. Benefits: WAR hazards disappear (a reader owns its copy or its producer's tag), WAW hazards disappear (only the broadcast whose tag matches Qi is written; an older writer's result is dropped), so the false dependences created by register reuse no longer serialize execution; more instructions in flight; loop iterations overlap without unrolling.

Out-of-order execution. An instruction executes as soon as its operands and a unit are available, whatever older instructions are doing: issue stays in order, execution and completion do not. Benefits: a long-latency instruction (a cache miss, a 40-cycle divide) no longer blocks independent work behind it — in the classic example FADD, issued after FDIV, writes its result at cycle 13 while FDIV finishes at 59 — giving higher unit utilization and IPC. Cost: results written out of order make exceptions imprecise and speculation hard to undo; the reorder buffer restores in-order commit.

Five lines per item on the paper. The examiner looks for the mechanism (fields, tags, the broadcast, Qi = youngest writer) and for the benefit stated as a hazard class removed or a stall avoided — not for the word "faster". A concrete number from the example ("FADD writes at 13, before the older FDIV") shows you have run it.

Lesson 13 · Tomasulo cycle by cycle, and what it fixes compared with the scoreboard · question 2 of 7 · open in the lesson

Let's consider the following assembly code to be executed on a CPU with dynamic scheduling based on the TOMASULO algorithm with all cache HITS, a single Common Data Bus and: 2 RESERVATION STATIONS (RS1, RS2) with 2 LOAD/STORE units (LDU1, LDU2) with latency 4; 2 RESERVATION STATIONS (RS3, RS4) with 1 FP ADD/SUB unit (FPU1) with latency 3; 2 RESERVATION STATIONS (RS5, RS6) with 1 FP MUL/DIV unit (FPU2) with latency 6 for FMUL and 12 for FDIV. Complete the table (row I0 is given: 1, 2, 6, None, RS1, LDU1) and calculate the CPI.

I0: LD   F6, 34(R2)
I1: LD   F2, 45(R3)
I2: FMUL F0, F2, F4
I3: FSUB F8, F6, F2
I4: FDIV F10, F0, F6
I5: FADD F6, F8, F2
Show model answer
INSTRUCTIONISSUESTART EXECWRITE RESULTHazards TypeRSiUNIT
I0: LD F6, 34(R2)126NoneRS1LDU1
I1: LD F2, 45(R3)237NoneRS2LDU2
I2: FMUL F0, F2, F43814RAW with I1 for F2RS5FPU2
I3: FSUB F8, F6, F24811RAW with I0 for F6, with I1 for F2RS3FPU1
I4: FDIV F10, F0, F651527RAW with I2 for F0, with I0 for F6RS6FPU2
I5: FADD F6, F8, F261215RAW with I3 for F8, with I1 for F2; WAR with I3, I4 and WAW with I0 for F6 solved by renamingRS4FPU1

Checks: I2 starts at 8 = write of I1 + 1; I3 at 8 = max(6 + 1, 7 + 1); I4 at 15 = write of I2 + 1, FPU2 free (I2 executed 8–13); I5 at 12 = write of I3 + 1, FPU1 free since 11. CDB at 6, 7, 11, 14, 15, 27: no collision. CPI = 27 / 6 = 4.5.

Marks go to the three numbers of every row, to the hazard written with its instruction and register, and to the CPI as "last WRITE RESULT / instructions". The row most often wrong is I4: its F6 is still pending at issue with a load latency of 4, so it has two RAW hazards, and it must wait for FPU2 as well as for F0 — here both conditions give 15.

Lesson 13 · Tomasulo cycle by cycle, and what it fixes compared with the scoreboard · question 3 of 7 · open in the lesson

The same six instructions run with latencies load 2, add/sub 2, mult 10, div 40, one adder, one multiplier-divider and two independent load units (the second load starts the cycle after its issue). In which cycle does FDIV write its result?

Show model answer

LD F2: issue 2, start 3, write 5. FMUL: start 6, write 16. FDIV: start 17 (F0 written at 16, the multiplier free), write 17 + 40 = 57. With one load unit held through its write cycle the chain starts two cycles later and the answer is 59.

The examiner checks that you propagated the two cycles along the chain and did not touch anything off it: FADD moves from 13 to 11 too, but it is not asked.

Lesson 13 · Tomasulo cycle by cycle, and what it fixes compared with the scoreboard · question 4 of 7 · open in the lesson

In Tomasulo's algorithm a result is broadcast on the CDB with the tag RS3. The register file writes it into F6 if and only if:

  • F6 is the destination of the broadcasting instruction Not enough: if a younger instruction has renamed F6 since, the write must be skipped.
  • Qi[F6] = RS3 The register file compares the tag with its Qi field: a match means RS3 is still the youngest writer of F6. This is how WAW is handled.
  • no reservation station is reading F6 Readers never block a write in Tomasulo: they hold a value or a tag of their own.
  • RS3 is the oldest busy station Age decides who gets the bus when two results are ready, not whether the register accepts the value.
Show model answer

Answer 2. If Qi[F6] = RS4, a younger writer owns the name and the broadcast is dropped by the register file (the stations waiting for RS3 still take it).

A quiz in the style of the 2026 block: single answer, one point.

Lesson 13 · Tomasulo cycle by cycle, and what it fixes compared with the scoreboard · question 5 of 7 · open in the lesson

Which hazards make a scoreboard stall but are eliminated by Tomasulo's algorithm?

  • RAW only RAW waits remain in both machines: a value that does not exist yet cannot be forwarded.
  • WAR and WAW Renaming through station tags: readers keep their copy or their producer's tag, the register file honours only the youngest tag.
  • structural hazards on the functional units Both machines wait for a busy unit; Tomasulo even adds a structural resource, the single CDB.
  • all data hazards Only the two name hazards; FMUL still waited four cycles in MUL1 for F2.
Show model answer

Answer 2. In the example the scoreboard held FADD's write from 16 to 22 for a WAR with FDIV; Tomasulo wrote it at 13.

The distractor "all data hazards" is the one students pick after reading "no hazards occurred" on page 182.

Lesson 13 · Tomasulo cycle by cycle, and what it fixes compared with the scoreboard · question 6 of 7 · open in the lesson

Which statements about the Common Data Bus are correct? (multiple answers)

  • It carries a value together with the tag of the producing reservation station The pair ⟨tag, value⟩ is what every listener matches against its own tags.
  • Every register of the register file is overwritten by each broadcast Only the register whose Qi equals the tag; the others ignore it.
  • At most one result can be broadcast per cycle on a single CDB The structural limit of the bus: the older instruction goes first, the younger slips.
  • A reservation station whose Qj equals the broadcast tag copies the value and clears Qj That is the capture: Vj takes the value, Qj becomes 0.
  • Stores write their data on the CDB A store writes memory; it never uses the bus, which is why it cannot collide with anybody on it.
Show model answer

Answers 1, 3 and 4.

The "multiple answer" form of the 2026 quizzes: tick every true statement, and nothing is said about penalties, so reason about each option on its own.

Lesson 13 · Tomasulo cycle by cycle, and what it fixes compared with the scoreboard · question 7 of 7 · open in the lesson

Why can the original Tomasulo algorithm not provide precise exceptions, and what is added to fix it?

Show model answer

Results are written into the register file at write result, in completion order, which is not program order: in the classic example FADD writes F6 at cycle 13 while the older FDIV finishes at 59. If FDIV raised an exception, F6 would already hold a value produced by a younger instruction and no earlier instruction could be guaranteed complete — the architectural state is inconsistent and in-place writes cannot be undone. The fix is a reorder buffer: results go to the ROB at write result and are committed to the register file in program order, so at an exception everything older has committed and everything younger is discarded. The scoreboard has the same problem, since it too writes registers in place and out of order.

Three things earn the marks: "out of order" plus "in place", the definition of precise (all before complete, none after visible), and the ROB as an in-order commit point.

Lesson 14 · Tomasulo under pressure: structural squeezes and CDB fights

Lesson 14 · Tomasulo under pressure: structural squeezes and CDB fights · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by a Tomasulo-style processor: (1) reservation stations; (2) tags on the Common Data Bus; (3) in-order issue with out-of-order execution. For each, say what it costs, with an example from an exercise.

Show model answer

(1) A reservation station is a buffer in front of a class of functional units that holds an issued instruction together with its operand values (Vj, Vk) if they are already available, or the tags (Qj, Qk) of the stations that will produce them. Benefits: the instruction leaves the issue stage without waiting for its operands, so later independent instructions can issue; the station is also the renamed destination, which removes WAR and WAW stalls (the February 2025 ADDI overwrites R0 while two stores still hold their copies of the old R0). Cost: the number of stations bounds what can be issued; when every station of a class is busy, issue stalls (RS1 and RS2 busy at cycles 5–8 of the February paper).

(2) When a unit finishes, the result is broadcast on the Common Data Bus as the pair (tag, value), the tag being the station of the producer. Every station and register whose Qj, Qk or tag field matches captures the value in the same cycle, so a consumer can start the next cycle without a trip through the register file and without a stall on name dependences. Cost: one bus delivers one result per cycle; when two are ready the older goes first and the younger waits, keeping its station (midterm 2025, cycles 12–16: five results, I7 writes at 15 instead of 12).

(3) Instructions issue strictly in program order, one per cycle, but start executing as soon as their own operands and a unit are available, and finish out of order: long-latency instructions no longer block independent ones (I6 ADDI executes at 12 while the FP work is pending), the hardware tolerates unpredictable latencies such as cache misses, and the compiler needs no knowledge of the pipeline. Cost: in-order issue means one blocked instruction blocks everything behind it; out-of-order completion makes exceptions imprecise, and nothing can pass an unresolved branch until a reorder buffer (lesson 17) adds speculation.

Each sub-point is worth a short labelled block: concept, benefit, cost, example. A complete answer names the tag as the station, says that WAR/WAW cost nothing and why, and states the structural limits (stations, bus) next to the benefits.

Lesson 14 · Tomasulo under pressure: structural squeezes and CDB fights · question 2 of 7 · open in the lesson

Let's consider the following assembly code containing multiple types of intra-loop dependences. Complete the dependence table (true data dependence with I# for Fx; anti-dependence with I# for Fy; output dependence with I# for Fz). Then consider the code executed on a CPU with dynamic scheduling based on the Tomasulo algorithm with all cache hits, a single Common Data Bus and: 2 reservation stations (RS1, RS2) with 2 load/store units (LDU1, LDU2) with latency 4; 2 reservation stations (RS3, RS4) with 2 FP units (FPU1, FPU2) with latency 3; 2 reservation stations (RS5, RS6) with 2 INT_ALU/BR units (ALU1, ALU2) with latency 2. Complete the table (ISSUE, START EXEC, WRITE RESULT, Hazards Type, RSi, UNIT), rows I0 (1, 2, 6, None, RS1, LDU1) and I1 (2, 3, 7, None, RS2, LDU2) given, and calculate the CPI.

I0: FOR: LD    F2, A(R1)
I1:      LD    F4, B(R1)
I2:      LD    F6, C(R1)
I3:      FADD  F4, F2, F4
I4:      FADD  F6, F4, F6
I5:      SD    F6, A(R1)
I6:      ADDUI R1, R1, 8
I7:      BNE   R1, R2, FOR
Show model answer

Dependences: I0, I1, I2: none. I3: true with I0 for F2 and with I1 for F4; output with I1 for F4. I4: true with I3 for F4 and with I2 for F6; output with I2 for F6. I5: true with I4 for F6. I6: anti with I0, I1, I2 and I5 for R1. I7: true with I6 for R1.

INSTRUCTIONISSUESTART EXECWRITE RESULTHazards TypeRSiUNIT
I0 LD F2126NoneRS1LDU1
I1 LD F4237NoneRS2LDU2
I2 LD F67812Structural (RS1, RS2 busy, cycles 3–6)RS1LDU1
I3 FADD F48913RAW with I0, I1 (ready at issue); Structural (CDB at 12: I2 first)RS3FPU1
I4 FADD F691417RAW with I3 (F4), I2 (F6)RS4FPU2
I5 SD F6101822RAW with I4 (F6)RS2LDU2
I6 ADDUI R1111214None (WAR on R1 renamed)RS5ALU1
I7 BNE121518RAW with I6 (R1); Structural (CDB at 17: I4 first)RS6ALU2

CPI = 22 / 8 = 2.75.

The three moves that earn the points: I2 waits four cycles for a station and drags I3–I7 with it; the single bus pushes I3 (12 → 13) and I7 (17 → 18) by one cycle; the chain I2 → I4 → I5 fixes the end at 22. State the branch-on-CDB convention in one line; 17 with the reason "the branch produces no register value" is a defensible alternative, and the CPI is the same.

Lesson 14 · Tomasulo under pressure: structural squeezes and CDB fights · question 3 of 7 · open in the lesson

The midterm 2025 code of this lesson runs on the same machine but with two FP units (FPU1, FPU2) of latency 4, still a single Common Data Bus. Complete the table and calculate the CPI.

Show model answer

I1 1 / 2 / 6 RS1 LDU1; I2 2 / 3 / 7 RS2 LDU2; I3 3 / 4 / 8 RS3 FPU1; I4 4 / 5 / 9 RS4 FPU2 (no unit wait); I5 7 / 8 / 12 RS1 LDU1 (structural: RS1, RS2 busy at 5–6); I6 8 / 9 / 13 RS2 LDU2; I7 9 / 10 / 14 RS5 ALU1 (ready at 12: CDB taken by I5 at 12 and I6 at 13); I8 10 / 11 / 15 RS6 ALU2 (ready at 13: behind I6 and I7); I9 15 / 16 / 18 RS5 ALU1 (RS5 free after 14; R2 arrives at 15); I10 16 / 19 / 21 RS6 ALU2 (R3 at 18). CPI = 21 / 10 = 2.1.

One cycle better than with one FP unit: the second unit removes I4's wait, but the ADDUIs still queue behind the loads on the bus and hold the integer stations. Write the queue 12–15 into the Hazards column as "Structural (CDB)": it is the reason the numbers are what they are.

Lesson 14 · Tomasulo under pressure: structural squeezes and CDB fights · question 4 of 7 · open in the lesson

In the February 2025 exercise the FP latency becomes 4 instead of 2; everything else is unchanged. Give the last WRITE RESULT cycle and the CPI.

Show model answer

I2 starts 10, writes 14; I3 starts 15, writes 19; I4 starts 15 (F4 at 14), writes 21; I6 11 / 12 / 13 and I7 14 / 15 / 16 unchanged; I5 starts 20 (F6 at 19), writes 26. Write cycles 8, 9, 13, 14, 16, 19, 21, 26: no bus collision. Last WRITE RESULT = 26, CPI = 26 / 8 = 3.25.

Only the two FP operations of the chain move, by two cycles each; the structural hole at 5–8 and the integer tail are untouched.

Lesson 14 · Tomasulo under pressure: structural squeezes and CDB fights · question 5 of 7 · open in the lesson

In the February 2025 exercise the BNE cannot issue at cycle 12 because: (single answer)

  • it has a RAW hazard on R0 It has, but a RAW hazard delays START EXEC, not ISSUE: the instruction would issue with a tag.
  • ALU1 is executing the ADDI The unit is checked at START EXEC; issue only needs a station.
  • the only integer reservation station, RS5, is occupied by the ADDI until its WRITE RESULT Correct: a station is busy from ISSUE through WRITE RESULT (13), so the BNE issues at 14.
  • the Common Data Bus is busy The bus is used at WRITE RESULT; it never blocks an issue directly.
Show model answer

Answer 3: STRUCTURAL on RS5, the single integer station, busy with I6 through cycle 13.

The notes argue on page 552 whether the label should name RS5 or ALU1: in the issue stage it is the station that is checked.

Lesson 14 · Tomasulo under pressure: structural squeezes and CDB fights · question 6 of 7 · open in the lesson

In the Tomasulo algorithm a reservation station is released: (single answer)

  • when the instruction issues At issue the station is just filled.
  • when the instruction starts executing The station keeps the operands and the tag while the unit works.
  • when the instruction writes its result Correct: the station is busy through WRITE RESULT and can be reused from the next cycle.
  • when the next instruction of the same class issues The next instruction of the class needs a free station; it cannot free one.
Show model answer

Answer 3. This is why a result that waits for the bus delays the issue of later instructions.

Calibrate on the given row: a load that writes at 6 lets the next load/store instruction take its station at 7.

Lesson 14 · Tomasulo under pressure: structural squeezes and CDB fights · question 7 of 7 · open in the lesson

True or false: "A single Common Data Bus can delay the issue of later instructions."

  • True Correct: a result that loses the bus keeps its station; an instruction that needs that station cannot issue (midterm: I7 writes at 15 instead of 12 and I9 issues at 16 instead of 13).
  • False The bus delays writes directly, but a delayed write holds a station, and a held station blocks an issue.
Show model answer

True. Motivation: stations are released at WRITE RESULT; a write delayed by bus arbitration keeps the station busy, and in-order issue stalls on the missing station.

The one-point motivation is the chain bus → station → issue; name the cycles of an exercise.

Lesson 15 · Same names, no conflicts: unrolling, renaming and scheduling

Lesson 15 · Same names, no conflicts: unrolling, renaming and scheduling · question 1 of 7 · open in the lesson

(Two sub-points in the form of the June 2026 Question 1, which had eight of them for 8 points.) Explain the main concepts and benefits of each one of the following techniques, five lines each: (a) dynamic register renaming in a Tomasulo-style processor; (b) loop unrolling with static register renaming by the compiler. Say for each what it costs and which hazards it removes.

Show model answer

(a) WAR and WAW are name dependences, caused only by reusing the few ISA register names. At issue, the reservation station that will produce a result becomes its name (tag): the register status records the tag, consumers keep either the value (Vj, Vk) or the producer's tag (Qj, Qk), and results are broadcast on the CDB as (tag, value). Benefits: WAR/WAW never stall, more instructions in flight, loop iterations overlap on unchanged code. Costs: tag comparators in every station, CDB bandwidth, limited by the number of stations. RAW remains.

(b) The compiler copies the loop body u times, folds the addresses into the displacements, keeps one index update and one branch, and gives each copy fresh ISA registers ((u − 1)ρ more), so the copies share no names. Benefits: the overhead is paid once per u elements (w + o/u instructions per element instead of w + o) and a large block of independent instructions can be scheduled — loads first, FP operations next, stores last. Costs: code size, register pressure, a remainder loop when the trip count is not a multiple of u; the latencies must be known at compile time. RAW inside each copy remains.

The examiner checks that the two renamings are kept apart — tags invisible to the ISA versus real register names — and that each technique is credited with removing WAR/WAW only, never RAW. A benefit without its cost is half an answer.

Lesson 15 · Same names, no conflicts: unrolling, renaming and scheduling · question 2 of 7 · open in the lesson

(Midterm of 5 May 2025, Question 3, as reproduced in the notes p. 534.) Let's consider the following loop code where registers R1 and R2 are initialized to 0 and R3 is initialized to 400:

LOOP: LD    F2, 0(R1)
      LD    F4, 0(R2)
      FADD  F6, F2, F4
      SD    F6, 0(R1)
      ADDUI R1, R1, 4
      ADDUI R2, R2, 4
      BNE   R1, R3, LOOP

How many iterations of the loop? How many instructions per iteration? How many instructions due to the loop overhead per iteration? How many instructions are executed globally? How many branch instructions are executed globally? Let's consider a loop unrolling version of the code with unrolling factor 2, and then with unrolling factor 4: answer the same questions, and in addition: how many more registers are needed due to register renaming? What are the registers that need to be renamed? How much is the global instruction count decrease? What is the best unrolling factor between 2 and 4? Explain why.

Show model answer

Original loop: R1 goes 0, 4, …, 396 before the branch falls through at 400, so 400/4 = 100 iterations; 7 instructions per iteration; 3 of them overhead (ADDUI R1, ADDUI R2, BNE), 4 useful; 700 instructions and 100 branches executed.

Unrolling factor 2 — the body with the second copy renamed:

LOOP: LD    F2, 0(R1)
      LD    F4, 0(R2)
      FADD  F6, F2, F4
      SD    F6, 0(R1)
      LD    F8, 4(R1)
      LD    F10, 4(R2)
      FADD  F12, F8, F10
      SD    F12, 4(R1)
      ADDUI R1, R1, 8
      ADDUI R2, R2, 8
      BNE   R1, R3, LOOP

50 iterations (100 is a multiple of 2, no remainder loop); 11 instructions per iteration; overhead still 3; 550 instructions and 50 branches executed. Registers: with the same names, the second copy could not write F2, F4, F6 before the first copy had read them (WAR/WAW), so the copies would stay serialised; F2, F4, F6 are renamed to F8, F10, F12: 3 more registers, (u − 1) × 3. Decrease: (700 − 550)/700 = 21.43 %.

Unrolling factor 4: copies 3 and 4 use F14/F16/F18 and F20/F22/F24 with displacements 8 and 12; ADDUI R1, R1, 16 and ADDUI R2, R2, 16. 25 iterations; 19 instructions per iteration; overhead 3; 475 instructions and 25 branches executed; (4 − 1) × 3 = 9 more registers, F8 … F24 — the same three registers F2, F4, F6 renamed three times. Decrease: (700 − 475)/700 = 32.14 %.

Best factor: 4. Iterations and branches halve again (50 → 25) and the overhead per useful add falls from 1.5 to 0.75 instructions. The price is 12 live FP registers instead of 6 and a 19-instruction body; factor 4 is preferable if the architectural register file holds the 12 live values without spilling and the code size is acceptable, otherwise factor 2 is the safer choice.

Write the unrolled code: the displacements (0, 4 / 0, 4, 8, 12) and the scaled increments (8 / 16) are where points are lost. State explicitly that 100 is a multiple of 2 and of 4, so no remainder loop is needed. The renaming here is the compiler's, with ISA registers — do not write that "the hardware" renames them.

Lesson 15 · Same names, no conflicts: unrolling, renaming and scheduling · question 3 of 7 · open in the lesson

The loop of this lesson, I0 LD F0, 0(R1); I1 FMUL F4, F0, F2; I2 SD F4, 0(R1); I3 SUBI R1, R1, 8; I4 BNE R1, R2, LOOP, runs with R1 initialized to 80 and R2 to 0. (a) How many iterations, instructions per iteration, overhead instructions per iteration, instructions and branches executed globally? (b) Write the unrolled version of the loop with unrolling factor 2 by using register renaming. (c) For the unrolled version: iterations, instructions per iteration, overhead, global instructions and branches, how many more registers and which ones, and the decrease of the global instruction count.

Show model answer

(a) R1 takes the values 80, 72, …, 8 at the top of the body: 80/8 = 10 iterations; 5 instructions per iteration, 2 of them overhead (SUBI, BNE); 50 instructions and 10 branches executed.

(b)

LOOP: LD    F0, 0(R1)
      FMUL  F4, F0, F2
      SD    F4, 0(R1)
      LD    F6, -8(R1)
      FMUL  F8, F6, F2
      SD    F8, -8(R1)
      SUBI  R1, R1, 16
      BNE   R1, R2, LOOP

(c) 5 iterations; 8 instructions per iteration; overhead still 2; 40 instructions and 5 branches executed. 2 more registers, (2 − 1) × 2: F0 → F6 and F4 → F8 in the second copy; F2 is only read and is not renamed. Decrease: (50 − 40)/50 = 20 %.

Two traps: forgetting that F2 needs no fresh name (it is never written), and leaving the second copy's displacements at 0 instead of −8. The SUBI immediate doubles; the branch is unchanged. Part (b) is a real exam request: the paper of 11 February 2025 asked to "Write the unrolled version of the loop with unrolling factor 2 by using Register Renaming" (notes p. 568) before running it through the reorder buffer of lesson 18.

Lesson 15 · Same names, no conflicts: unrolling, renaming and scheduling · question 4 of 7 · open in the lesson

Same loop, R1 = 80 (10 iterations). It is unrolled by a factor of 4; since 10 is not a multiple of 4, the leftover elements are handled by a remainder loop of the original body. How many instructions are executed in total?

Show model answer

10 = 2 × 4 + 2: two iterations of the unrolled body (3 × 4 + 2 = 14 instructions each) and two iterations of the original body (5 each): 2 × 14 + 2 × 5 = 38 instructions, with 2 + 2 = 4 branches; the decrease is (50 − 38)/50 = 24 %, less than the 30 % the formula o(1 − 1/u)/(w + o) promises for u = 4, because the remainder pays full overhead.

The examiner wants the split 8 + 2 elements written down; an answer of 35 (10/4 × 14 with a fractional iteration) shows the remainder loop was not understood.

Lesson 15 · Same names, no conflicts: unrolling, renaming and scheduling · question 5 of 7 · open in the lesson

(Single answer.) In the scheduled, unrolled-by-4 loop, SUBI R1, R1, 32 is moved above the store of the fourth element, originally SD F16, -24(R1). After the move the store must read:

  • SD F16, -24(R1) R1 has already been decreased by 32: this writes to R1 − 56 of the old base, an element of a later iteration.
  • SD F16, 8(R1) The old −24 relative to the old R1 is −24 + 32 = +8 relative to the new one: the same address.
  • SD F16, -56(R1) The correction goes the other way: the base got smaller, so the displacement must grow.
  • SD F16, 0(R1) 0(R1) after the update is the first element of the next block, not the fourth of this one.
Show model answer

SD F16, 8(R1): displacement = old displacement − (change of R1) = −24 − (−32) = 8.

This is the line of the notes' page 192 that the hook asked you to find. Whenever a memory access crosses the index update in a schedule, correct its displacement by the update's immediate.

Lesson 15 · Same names, no conflicts: unrolling, renaming and scheduling · question 6 of 7 · open in the lesson

(15 July 2024, quiz 1, single answer — also in lesson 7; it is the vocabulary of this lesson.) Let's consider the following loop: for (i=1; i<=100; i++) { X[i] = X[i] + X[i-1]; /*S1*/ Z[i] = X[i] + Y[i-1] /*S2*/ }. How many loop-carried dependencies are in the code?

  • Answer 1: Only one in S2 because Z[i] depends on Y[i-1] Y is never written in the loop, so Y[i-1] is an input, not a value produced by an earlier iteration.
  • Answer 2: Only one in S1 because X[i] depends on X[i-1] S1 reads X[i-1], which S1 itself wrote in the previous iteration: a true dependence carried from iteration i − 1 to iteration i.
  • Answer 3: Both of them S2's dependence on X[i] is on the same iteration's S1, not on a previous iteration.
Show model answer

Answer 2. The loop-carried dependence is S1 → S1 through X: iteration i reads X[i−1], produced by iteration i − 1. S2 depends on S1 within the iteration, and Y is read only.

Compare with the loop of this lesson: its only loop-carried true dependence is the index R1, which is why its iterations can be overlapped — a loop like S1 could not be, whatever the renaming.

Lesson 15 · Same names, no conflicts: unrolling, renaming and scheduling · question 7 of 7 · open in the lesson

(True/False, motivate your answer.) "Tomasulo's algorithm performs loop unrolling dynamically: the hardware replicates the loop body in the reservation stations so that several iterations execute together."

  • True Nothing is replicated: every instruction of every iteration is issued once, from the instruction stream, into a station of its own.
  • False Tomasulo overlaps iterations of the unchanged code: fresh stations and tags per instance give the effect of unrolling without copying a single instruction (Table 20).
Show model answer

False. Loop unrolling is a compiler transformation of the program text. Tomasulo issues the instructions of each iteration as they arrive, in order, each into its own reservation station with its own tag; because operands are tracked by tag and not by register name, the LD/FMUL/SD of iteration i + 1 can execute while those of iteration i are still waiting — the "dynamic loop unrolling effect" — but the code is never modified or replicated.

The motivation must name the mechanism — stations and tags per instance — and the word "effect": the examiner wants to see that you know what the hardware does and does not do.

Lesson 16 · Tomasulo meets a loop: eighteen cycles of renaming in action

Lesson 16 · Tomasulo meets a loop: eighteen cycles of renaming in action · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by modern superscalar processors (Tomasulo-style), in about five lines each: (1) dynamic instruction scheduling; (4) reservation stations; (5) dynamic register renaming; (6) out-of-order execution. Use as example the loop LD F0, 0(R1); FMUL F4, F0, F2; SD F4, 0(R1); SUBI R1, R1, 8; BNE R1, R2, LOOP, not unrolled, whose first LD misses in the cache.

Show model answer

Dynamic instruction scheduling. The hardware decides at run time when each instruction executes, preserving the data flow: instructions issue in program order and wait in reservation stations until their operands are available, instead of stalling the pipeline behind the first one that must wait. Benefit: it adapts to latencies known only at run time, such as a cache miss. In the loop the second iteration's LD, FMUL and SD issue at cycles 6, 7 and 8 while the first LD is still missing; the same code runs well on different implementations. Cost: stations, tag-compare logic and a common data bus.

Reservation stations. Buffers in front of the functional units (Load1–3, Mult1–2, Store1–3 in the example) holding the operation, the operand values (Vj, Vk) or the tags of the stations that will produce them (Qj, Qk). An instruction enters a free station even when its operands are missing (the first FMUL at cycle 2 with Qj = Load1) and fires when they arrive on the CDB. Benefits: distributed hazard detection, operands read once, and the station names serve as tags for renaming. Limit: a station is held from issue to write result, so their number bounds the overlap; with two multiply stations the third FMUL cannot issue until cycle 15.

Dynamic register renaming. At issue, the station or buffer that will produce a result becomes the name of that result; the register result status maps each register to its youngest producer (F0: Load1, then Load2 from cycle 6; F4: Mult1, then Mult2). Readers record the tag, not the register, and the register file accepts a broadcast only from the youngest producer: at cycle 10 M[80] goes to Mult1 but not to F0. Benefit: WAR and WAW hazards disappear without stalls, so two iterations using the same F0 and F4 are in flight together (dynamic loop unrolling); only RAW dependences remain.

Out-of-order execution. Instructions execute and complete when their operands are ready, not in program order; issue stays in order. The second LD completes at cycle 10, before the first FMUL starts at 11. Benefit: long latencies (misses, FP operations) are overlapped with independent work, functional units stay busy and CPI drops. Requirements and limits: renaming against WAR and WAW; without a reorder buffer results reach the registers out of order, so exceptions are imprecise and nothing may execute past an unresolved branch.

Four of the eight sub-points of the June 2026 open question, one point each. Give a mechanism and a benefit in every item, with its cost or limit; the numbers of the loop are the evidence. Do not write "Tomasulo is speculative": speculation (item 2) and the reorder buffer (item 7) are the answers of lesson 17.

Lesson 16 · Tomasulo meets a loop: eighteen cycles of renaming in action · question 2 of 6 · open in the lesson

Let's consider the following assembly code containing multiple types of intra-loop dependences. Complete the following table by inserting all types of true-data-dependences, anti-dependences and output dependences for each instruction (I0: None).

I0  LOOP: LD    F0, 0(R1)
I1        FMUL  F0, F0, F2
I2        SD    F0, 0(R1)
I3        SUBI  R1, R1, 8
I4        BNE   R1, R2, LOOP

Let's consider the previous assembly code to be executed on a CPU with dynamic scheduling based on TOMASULO algorithm with all cache HITS, a single Common Data Bus and: 2 RESERVATION STATIONS (RS1, RS2) with 2 LOAD/STORE units (LDU1, LDU2) with latency 4; 2 RESERVATION STATIONS (RS3, RS4) with 1 FP unit (FPU1) with latency 3; 2 RESERVATION STATIONS (RS5, RS6) with 1 INT_ALU/BR unit (ALU1) with latency 2. Please complete the table INSTRUCTION / ISSUE / START EXEC / WRITE RESULT / Hazards Type / RSi / UNIT (row I0 given: 1, 2, 6, None, RS1, LDU1). Calculate the CPI.

Show model answer

Dependences: I0 — None. I1 — true data dependence with I0 for F0; output dependence with I0 for F0. I2 — true data dependence with I1 for F0. I3 — anti-dependence with I0 and I2 for R1. I4 — true data dependence with I3 for R1.

INSTRUCTIONISSUESTART EXECWRITE RESULTHazards TypeRSiUNIT
I0 LD F0, 0(R1)126NoneRS1LDU1
I1 FMUL F0, F0, F22710RAW with I0 for F0; WAW with I0 for F0 (solved by renaming)RS3FPU1
I2 SD F0, 0(R1)31115RAW with I1 for F0RS2LDU2
I3 SUBI R1, R1, 8457WAR with I0, I2 for R1 (solved by renaming)RS5ALU1
I4 BNE R1, R2, LOOP5811RAW with I3 for R1; Structural: CDB taken at 10 by I1RS6ALU1

CPI = 15 / 5 = 3.0.

The timing is cell for cell the table of section 5: reusing F0 as the destination of FMUL costs nothing, because the SD records the tag RS3, not the name F0. Check the dependence table first — the output dependence of I1 with I0 for F0 is the easiest line to forget — and then the CDB conflict at cycle 10. If you assume that a branch does not use the CDB, write 10 for I4 and say so; the CPI does not change.

Lesson 16 · Tomasulo meets a loop: eighteen cycles of renaming in action · question 3 of 6 · open in the lesson

The notes' loop example (first LD misses: 8 cycles; later LDs hit: 1 cycle; FMUL: 4 cycles; 3 load buffers, 3 store buffers, 2 multiply reservation stations; one memory unit serving one access at a time; a store executes in the cycle after its data arrives and writes memory in the next cycle) is redone with the convention of the exam papers: a reservation station becomes free only in the cycle after its WRITE RESULT. In which clock cycle does the store of the third iteration write to memory?

Show model answer

Iterations 1 and 2 do not change: no station is reused before cycle 15. Mult1 writes at 15 and is free at 16, so the third FMUL issues at 16 with both operands ready (F0 = M[64] since cycle 13), executes from 17 to 20 and writes at 21. The third SD issues at 17 into Store3, receives the product at 21, executes at 22 and writes memory at 23.

One convention moves two numbers: the notes refill Mult1 in the cycle it broadcasts (third FMUL at 15, third SD writing at 22). On the paper, use the papers' rule and state it in one line.

Lesson 16 · Tomasulo meets a loop: eighteen cycles of renaming in action · question 4 of 6 · open in the lesson

In the loop example (the first LD misses in the cache, 8 cycles), at cycle 10 the LD of the first iteration writes M[80] on the Common Data Bus. At that moment the register result status of F0 holds Load2. Which units store the value? (single answer)

  • Register F0 only F0's status names Load2, not Load1: the register file ignores a broadcast whose tag is not its youngest writer.
  • Reservation station Mult1 only Mult1's Qj holds Load1, so it copies the value into Vj; F0 waits for Load2.
  • Both F0 and Mult1 That would let an older value overwrite F0 after a younger load has claimed it — exactly the WAW hazard the tag compare prevents.
  • Store buffer Store1 Store1 waits for the tag Mult1, the producer of its data, not for Load1.
Show model answer

Answer 2. Only Mult1, whose Qj = Load1, captures M[80]; the register file writes F0 only if F0's status equals the broadcast tag, and since cycle 6 it equals Load2.

The distractors test the two halves of the rule: stations match on Q fields, the register file on its own status field.

Lesson 16 · Tomasulo meets a loop: eighteen cycles of renaming in action · question 5 of 6 · open in the lesson

In the same example, why can the FMUL of the third iteration not be issued at cycle 12? (single answer; motivate your answer)

  • RAW hazard on F0 A missing operand never stops issue: the FMUL would simply record the tag Load3 — and F0 is ready at 13 anyway.
  • No free multiply reservation station Mult1 and Mult2 are busy until their results are written at 15 and 16; without a station the instruction cannot issue.
  • The Common Data Bus is busy Nothing is written on the bus at cycle 12, and the bus never delays issue.
  • The branch has not been resolved yet The branch is predicted taken and issue proceeds; the LD of the same iteration issued at 11.
Show model answer

Answer 2: a structural hazard on the reservation stations. A station stays busy from issue to write result; Mult1 holds the first FMUL from cycle 2 to 15 because its load missed, Mult2 holds the second until 16. The third FMUL issues at 15, when Mult1 is freed, and in-order issue keeps the third SD behind it until 16.

The motivation point is for naming the station's lifetime — from ISSUE to WRITE RESULT, not to the end of execution — and the knock-on effect on the SD behind it.

Lesson 16 · Tomasulo meets a loop: eighteen cycles of renaming in action · question 6 of 6 · open in the lesson

True or false: in the loop example, the LD of the second iteration — a cache hit issued at cycle 6 — starts executing only at cycle 10 because two loads to the same address must be executed in program order.

  • True The two loads read different addresses (80 and 72), and two loads never need to be ordered: neither writes memory.
  • False It waits for the single memory unit, busy with the first load's miss until cycle 9 (a blocking cache); with a non-blocking cache it would execute at 7.
Show model answer

False. The addresses differ and loads do not conflict with loads; the delay is structural — one memory unit, occupied by the miss from cycle 2 to 9. Memory disambiguation concerns a load and an earlier store to the same address.

The notes give the wrong reason on pages 202 and 208; the statement is built from it.

Lesson 17 · Guess now, pay later: speculation, precise exceptions and the reorder buffer

Lesson 17 · Guess now, pay later: speculation, precise exceptions and the reorder buffer · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by modern superscalar processors (Tomasulo-style), in about five lines each: (2) dynamic branch prediction and speculative execution; (5) dynamic register renaming; (6) out-of-order execution; (7) reorder buffer.

Show model answer

Dynamic branch prediction and speculative execution. The outcome and target of a branch are predicted at fetch from run-time history (BHT, BTB). The instructions after the branch are fetched, issued and executed before the branch resolves; their results are forwarded among them through the CDB and the ROB but kept out of the architectural state until the branch is resolved and the instruction commits. On a misprediction the younger entries of the ROB are flushed and fetch restarts at the correct target. Benefit: branches no longer drain the pipeline, and the window of exploitable ILP spans several basic blocks. Cost: wasted work and recovery time on mispredictions, so accuracy matters.

Dynamic register renaming. Each issued instruction that writes a register gets a fresh name for its result — a reservation station in classic Tomasulo, a ROB entry in the speculative version; the rename table maps the architectural register to its newest producer, and a consumer issuing later takes that producer's value or its tag. Benefit: WAR and WAW (name) hazards disappear, so instructions and loop iterations can be overlapped freely and only true (RAW) dependences remain. Cost: a rename table to keep, to restore after a misprediction, and the copy of each value into the architectural register at commit.

Out-of-order execution. Instructions wait in reservation stations and start as soon as their own operands are ready, independently of program order; results are broadcast on the CDB. Issue and commit remain in order. Benefit: a stalled instruction — a cache miss, a long-latency FP operation — does not block independent later ones; functional units stay busy and CPI drops. It requires renaming against WAR/WAW hazards and in-order commit to keep exceptions precise.

Reorder buffer. A circular FIFO: an entry is allocated at issue in program order, written out of order at Write Result (value, ready bit) and drained in order at Commit from the head (head, ready, not speculative). It supplies operands between completion and commit, provides the names for renaming (the ROB number is the tag) and replaces the store buffers, keeping a store's address and data until commit. Benefits: precise exceptions, since nothing younger than a faulting instruction has touched the state; cheap misprediction recovery by discarding the entries after the branch; speculation made safe. Cost: a finite window — a stalled head stops issue when the buffer fills.

Four of the eight sub-points of the June 2026 open question. The examiner looks for the "what it buys" line in each one and for the pairing cost / benefit; "the ROB makes the processor faster" alone earns nothing — it makes speculation safe, and the speed comes from executing past unresolved branches.

Lesson 17 · Guess now, pay later: speculation, precise exceptions and the reorder buffer · question 2 of 6 · open in the lesson

What is a precise exception (give the three conditions)? Explain how the reorder buffer guarantees precise exceptions in an out-of-order processor, and what happens if an instruction on a mispredicted path raises an exception.

Show model answer

An exception is precise if (1) the processor can stop at a well-defined point corresponding to a specific instruction, (2) all previous instructions are fully committed, and (3) no subsequent instruction has modified the architectural state. With a reorder buffer, results are written to the ROB entry at Write Result, never directly to the register file or memory; only the head commits, in program order. An exception is recorded in the entry of the faulting instruction and taken when that instruction reaches the head: at that moment every older instruction has committed and every younger one is still in the buffer, so the younger entries are discarded and fetch restarts at the handler — the three conditions hold by construction. An exception raised on a mispredicted path never reaches the head: when the branch resolves, the entries after it are flushed together with the recorded exception, so it is never taken.

Give the three conditions as a list and then map each one to a property of the buffer (results parked, in-order commit at the head, flush of the younger entries). The last sentence — a speculative exception is simply discarded — is the part most answers miss.

Lesson 17 · Guess now, pay later: speculation, precise exceptions and the reorder buffer · question 3 of 6 · open in the lesson

(Single answer.) In the speculative Tomasulo algorithm, when is the architectural register file updated?

  • At Write Result, when the CDB broadcasts the value At Write Result the value goes to the ROB entry and to the waiting reservation stations; the CDB no longer reaches the register file (Figure 27).
  • At Issue, when the destination register is mapped to a ROB entry Issue writes the rename table, not the register file: a name, not a value.
  • At Commit, when the instruction is at the head of the ROB with its result ready Only then is the instruction certainly part of the program's path and older than nothing unfinished.
  • As soon as the functional unit finishes That is completion; the result exists, but it is parked in the entry with Ready = Yes.
Show model answer

The third option: at Commit. The register file must reflect only instructions that are certainly part of the program's path; at Write Result the value goes to the ROB entry and to the waiting reservation stations.

Keep the contrast straight: in classic Tomasulo the register file is written at Write Result (Table 21's "commit on write-back"); with the ROB only at Commit. In neither design does the value wait inside the reservation station — the red pen on Table 21 above.

Lesson 17 · Guess now, pay later: speculation, precise exceptions and the reorder buffer · question 4 of 6 · open in the lesson

(Multiple answers.) Which of the following statements about the reorder buffer are true?

  • The tag broadcast on the CDB is the ROB entry number The ROB number is the unique name of the in-flight result, from issue to commit.
  • The reservation station is released at Commit The station is freed at Write Result; it is the ROB entry that is freed at Commit.
  • A store writes memory at Commit Its address and data wait in the entry; the ROB replaced the store buffer.
  • The tail pointer points to the newest issued instruction The tail points to the next free entry, one past the newest instruction.
  • When head = tail the ROB may be either full or empty The busy bit of the entry decides (p. 232).
  • A load may read memory only when no earlier store in the ROB has an unresolved or equal address Memory disambiguation: a RAW hazard through memory (p. 229, step 3).
Show model answer

True: 1, 3, 5, 6. False: 2 (the station is freed at Write Result, the ROB entry at Commit) and 4 (the tail points to the next free entry).

The two false statements are the two confusions the lesson warns against most: which structure is freed when, and what the tail points to.

Lesson 17 · Guess now, pay later: speculation, precise exceptions and the reorder buffer · question 5 of 6 · open in the lesson

(Single answer.) In the Speculative Tomasulo Architecture, what type of hardware block is used to undo speculative instructions in case of a mispredicted branch? Motivate your answer by explaining what happens in the case of a mispredicted branch.

  • Reorder Buffer Speculative results live only in ROB entries; discarding the entries younger than the branch undoes them.
  • Instruction Dispatcher Issue allocates entries; it has no record of results to undo.
  • Store Buffer The speculative design has no store buffer: stores wait in the ROB.
  • Reservation Stations They hold operands and tags, not the commit state; they are squashed as a consequence of the flush.
  • Load Buffers They queue loads before memory access; nothing architectural is kept there.
Show model answer

The Reorder Buffer. A speculative instruction's result is held only in its ROB entry (and in copies inside reservation stations), never in the register file or memory, and the entry is marked speculative. When the branch resolves as mispredicted: all ROB entries younger than the branch are invalidated and the tail is moved back to the entry after the branch; the reservation stations and load buffers working for them are squashed; the rename table is restored to the mapping valid at the branch, so that each register points to its older in-flight producer or to nothing; fetch is redirected to the correct target; the branch itself commits normally. Nothing has to be undone in the architectural state, because nothing speculative ever reached it.

The quiz of the February 2025 paper, as reproduced in the notes (p. 582). The motivation is worth the extra point: name the four actions (invalidate the younger entries, squash their stations, restore the rename table, redirect fetch) and the reason nothing in the registers needs undoing.

Lesson 17 · Guess now, pay later: speculation, precise exceptions and the reorder buffer · question 6 of 6 · open in the lesson

Consider the following instruction sequence executed on a speculative Tomasulo architecture with a 4-entry ROB, 4 load buffers (Load1–Load4), 4 FP reservation stations (FP1–FP4) and 2 integer reservation stations (Int1–Int2). The BNE is predicted taken. Complete the ROB table and the Rename Table (a) when the ROB becomes full, (b) after In has committed, (c) after the BNE has been found mispredicted and the ROB has been flushed.

In:   LD   F0, 0(R1)
In+1: FADD F2, F0, F0
In+2: BNE  R1, R2, NEXT
In+3: FMUL F6, F2, F2
In+4: FADD F8, F6, F2
Show model answer

(a) The ROB is full after four issues: head = tail = ROB0 and the entry is busy. In+3 is speculative because the BNE in ROB2 is unresolved; the BNE itself is not.

ROB#InstructionDest.Res. Alloc.Ready/StatusSpec.
ROB0In: LD F0, 0(R1)F0Load1No, exec.No
ROB1In+1: FADD F2, F0, F0F2FP1No, issuedNo
ROB2In+2: BNE R1, R2, NEXT–Int1No, issuedNo
ROB3In+3: FMUL F6, F2, F2F6FP2No, issuedYes
Reg #F0F2F4F6F8
ROB #ROB0ROB1–ROB3–

(b) In completes (Ready = Yes, value 10 in ROB0, Load1 released) and commits from the head: F0 = 10 in the register file, ROB0 freed, head ROB1, tail ROB0, and the mapping of F0 cleared. In+1 has captured F0 from the CDB and is executing.

ROB#InstructionDest.Res. Alloc.Ready/StatusSpec.
ROB0–––––
ROB1In+1: FADD F2, F0, F0F2FP1No, exec.No
ROB2In+2: BNE R1, R2, NEXT–Int1No, issuedNo
ROB3In+3: FMUL F6, F2, F2F6FP2No, issuedYes
Reg #F0F2F4F6F8
ROB #–ROB1–ROB3–

(c) In+4 has meanwhile issued into ROB0 (FP3, speculative) and In+1 has committed (F2 = 20, head ROB2, tail ROB1). The BNE resolves as mispredicted: ROB3 and ROB0 are flushed, FP2 and FP3 released, the tail moves to ROB3, the mappings of F6 and F8 are cleared (no older producer is in flight), fetch restarts at the fall-through instruction. The branch is Ready at the head and commits next; the register file holds F0 = 10, F2 = 20 and was never touched by the flushed instructions.

ROB#InstructionDest.Res. Alloc.Ready/StatusSpec.
ROB0–––––
ROB1–––––
ROB2In+2: BNE R1, R2, NEXT––YesNo
ROB3–––––
Reg #F0F2F4F6F8
ROB #–––––

The three snapshots are cycles 3, 5 and 8 of the corrected Example 13. Marks go to: the Spec column (Yes only behind the branch, No for the branch itself), the Res. Alloc. names and their release at Write Result, the head and tail positions in each snapshot, and the rename table — "–" after a commit, and after the flush "–" only because no older producer of F6 or F8 is still in flight.

Lesson 18 · The speculative Tomasulo algorithm, stage by stage — and the ROB exam table

Lesson 18 · The speculative Tomasulo algorithm, stage by stage — and the ROB exam table · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by modern superscalar processors (Tomasulo-style): (a) dynamic branch prediction and speculative execution; (b) dynamic register renaming; (c) out-of-order execution; (d) reorder buffer. (Five lines each.)

Show model answer

(a) The outcome and target of a branch are predicted at fetch from run-time history (BHT, BTB); the instructions after the branch are fetched, issued and executed before the branch resolves, their results forwarded among themselves but kept out of the architectural state until the branch is validated; on a misprediction the younger instructions are flushed and fetch restarts. Benefit: branches no longer drain the pipeline, the window of exploitable ILP spans several basic blocks. Cost: wasted work and recovery time on a misprediction, so accuracy matters.

(b) Each issued instruction that writes a register gets a fresh name for its result — a reservation station in classic Tomasulo, a ROB entry in the speculative version; the rename (register status) table maps the architectural register to its newest producer, and consumers receive the value or its tag. Benefit: WAR and WAW (name) hazards disappear, instructions and loop iterations can be overlapped freely; only true RAW dependences remain.

(c) Instructions wait in reservation stations and start as soon as their own operands are ready, regardless of program order (data-flow execution), results being broadcast on the CDB. Benefit: a stalled instruction (cache miss, long FP latency) does not block independent later ones; functional units stay busy; CPI falls. It requires in-order commit to keep exceptions precise.

(d) A circular FIFO allocated at issue in program order, written out of order at write result (value, ready bit) and drained in order at commit from the head; it supplies operands between completion and commit, provides the names for renaming and replaces the store buffer (address and data kept until commit). Benefits: precise exceptions (nothing after the faulting instruction has touched the state), cheap misprediction recovery (discard the entries after the branch), safe speculation. Cost: a finite window — a blocked head stalls issue when the buffer fills.

These are sub-points 2, 5, 6 and 7 of the June 2026 question, which gives five blank lines per sub-point. Each line must pair a mechanism with its benefit: "renaming removes WAR/WAW", "the ROB commits in order, so exceptions are precise". Name the hardware (BHT/BTB, reservation station, CDB, head/tail) rather than describing the idea in prose: short labelled statements fit the lines, an essay does not.

Lesson 18 · The speculative Tomasulo algorithm, stage by stage — and the ROB exam table · question 2 of 7 · open in the lesson

Let's consider the following assembly loop where registers R1 and R2 are initialized at 0 and 40 respectively (the branch is predicted as taken). How many loop iterations? How many instructions per iteration? How many control vs datapath instructions? Write the unrolled version of the loop with unrolling factor 2 by using register renaming, and answer the same three questions. Then execute the unrolled version on the Speculative Tomasulo architecture with a 10-entry ROB and 4 load buffers (Load1–Load4), 4 FP reservation stations (FP1–FP4), 2 integer reservation stations (Int1, Int2): complete the ROB and the Rename Table until the ROB becomes full while the first instruction is still in execution due to a cache miss (*).

L0: LD   F2, 0(R1)
L1: FADD F4, F2, F2
L2: SD   F4, 0(R1)
L3: ADDI R1, R1, 4
L4: BNE  R1, R2, L0
Show model answer

Iterations: 40/4 = 10. Instructions per iteration: 5. Control vs datapath: 2 (ADDI, BNE) vs 3 (LD, FADD, SD). Unrolled by 2 with renaming (second copy on F6, F8 with offset +4; one ADDI of 8; one BNE): L0 LD F2, 0(R1); L1 FADD F4, F2, F2; L2 SD F4, 0(R1); L3 LD F6, 4(R1); L4 FADD F8, F6, F6; L5 SD F8, 4(R1); L6 ADDI R1, R1, 8; L7 BNE R1, R2, L0. Iterations 40/8 = 5; 8 instructions per iteration; 2 control vs 6 datapath.

ROB#InstructionDest.Res. Alloc.Ready/StatusSpec.
ROB0L0: LD F2, 0(R1)F2Load1No, exec.(*)No
ROB1L1: FADD F4, F2, F2F4FP1No, issuedNo
ROB2L2: SD F4, 0(R1)Mem [0+R1]–No, issuedNo
ROB3L3: LD F6, 4(R1)F6Load2No, issuedNo
ROB4L4: FADD F8, F6, F6F8FP2No, issuedNo
ROB5L5: SD F8, 4(R1)Mem [4+R1]–No, issuedNo
ROB6L6: ADDI R1, R1, 8R1Int1No, issuedNo
ROB7L7: BNE R1, R2, L0–Int2No, issuedNo
ROB8L0: LD F2, 0(R1) (iter. 2)F2Load3No, issuedYes
ROB9L1: FADD F4, F2, F2 (iter. 2)F4FP3No, issuedYes

Head = ROB0, tail = ROB0 (busy): full. Rename Table: F0 –; F2 ROB0 ROB8; F4 ROB1 ROB9; F6 ROB3; F8 ROB4 (and R1 → ROB6 if integer registers are listed). Load4 and FP4 remain free.

The marks hide in five places: the corrected offset of L5 (4, not 0); "–" in Res. Alloc. for the stores and Int2 for the branch; "No, issued" everywhere behind the head; Spec = Yes only for ROB8–9; and the rename table pointing to the newest producers with the old ones struck through. The notes' solution (pages 568–573) agrees with this table cell for cell except the store offset.

Lesson 18 · The speculative Tomasulo algorithm, stage by stage — and the ROB exam table · question 3 of 7 · open in the lesson

The loop LD F0, 0(R1); FMUL F4, F0, F2; SD F4, 0(R1); SUBI R1, R1, 8; BNEZ R1, Loop runs on a speculative Tomasulo machine with an 8-entry ROB, 2 load buffers (Load1, Load2), 2 multiplier reservation stations (Mult1, Mult2) and 2 integer reservation stations (Int1, Int2). The first LD misses in the cache; BNEZ is predicted taken. (a) Show the ROB (with the allocated resources) and the Rename Table at the moment the ROB becomes full. (b) BNEZ then resolves as not taken. Show the ROB, head, tail and Rename Table after the recovery.

Show model answer

(a) ROB0 LD F0, 0(R1) · F0 · Load1 · No, exec.(*) · No; ROB1 FMUL F4, F0, F2 · F4 · Mult1 · No, issued · No; ROB2 SD F4, 0(R1) · Mem [0+R1] · – · No, issued · No; ROB3 SUBI R1, R1, 8 · R1 · Int1 · No, issued · No; ROB4 BNEZ R1, Loop · – · Int2 · No, issued · No; ROB5 LD F0, 0(R1) · F0 · Load2 · No, issued · Yes; ROB6 FMUL F4, F0, F2 · F4 · Mult2 · No, issued · Yes; ROB7 SD F4, 0(R1) · Mem [0+R1] · – · No, issued · Yes. Head = ROB0, tail = ROB0 (busy): full. Rename table: F0 ROB0 ROB5, F4 ROB1 ROB6, R1 ROB3.

(b) ROB5, ROB6, ROB7 are flushed (Busy = No); Load2 and Mult2 are released; head still ROB0 (the load has not committed), tail = ROB5; Rename table: F0 → ROB0, F4 → ROB1 (the older producers are still in flight), R1 → ROB3; fetch restarts at the instruction after BNEZ, which will take ROB5 with Spec = No; the BNEZ in ROB4 commits normally when it reaches the head.

Part (b) is where answers diverge: the tail goes back to the entry after the branch, not to 0; the rename table is restored, not emptied — had ROB0 already committed, F0 would read "–" instead. Say explicitly that nothing is undone in the registers or in memory.

Lesson 18 · The speculative Tomasulo algorithm, stage by stage — and the ROB exam table · question 4 of 7 · open in the lesson

The same five-instruction loop runs with R1 initialized at 0, R2 at 96 and the same step of 4. It is unrolled with unrolling factor 4 (register renaming, one index update, one branch). How many instructions are executed in total by the unrolled loop (dynamic instruction count)?

Show model answer

Original: 96/4 = 24 iterations of 5 instructions. Unrolled by 4: 24/4 = 6 iterations of 4 · 3 + 2 = 14 instructions. Dynamic count: 6 × 14 = 84 (down from 120).

The two usual slips: counting 4 · 5 = 20 instructions per unrolled iteration (the index update and the branch are not copied), and forgetting to divide the iteration count by the unrolling factor.

Lesson 18 · The speculative Tomasulo algorithm, stage by stage — and the ROB exam table · question 5 of 7 · open in the lesson

In the speculative Tomasulo algorithm, when is the architectural register file updated? (single answer)

  • At write result, when the CDB broadcasts the value The broadcast reaches the waiting stations and the ROB entry; the registers are not on the CDB any more.
  • At issue, when the destination is renamed Issue writes the rename table and the entry, not a value.
  • At commit, when the instruction is at the head of the ROB with its result ready Only the head writes the architectural state, in program order, and only when Ready and not speculative.
  • As soon as the functional unit finishes That is the moment of write result: the value goes to the entry's Value field.
Show model answer

Answer 3: at commit. The register file must reflect only instructions that are certainly part of the program's path; at write result the value lives in the ROB entry and in the stations that captured it.

Answer 1 is the classic Tomasulo rule (lesson 12) — the quiz checks that you know what the ROB changed.

Lesson 18 · The speculative Tomasulo algorithm, stage by stage — and the ROB exam table · question 6 of 7 · open in the lesson

In the Speculative Tomasulo architecture, what type of hardware block is used to undo speculative instructions in case of a mispredicted branch? (single answer; motivate your answer by explaining what happens in the case of a mispredicted branch)

  • Reorder Buffer The entries younger than the branch are discarded before they commit; the architectural state was never touched.
  • Instruction Dispatcher Issue logic allocates stations and entries; it keeps no record of what to undo.
  • Store Buffer The speculative design has no store buffer: the ROB holds the stores' address and data until commit.
  • Reservation Stations They hold operands and tags, not the commit state; they are squashed as a consequence of the flush, not as its mechanism.
  • Load Buffers Same as the stations: released by the flush, not the thing that performs it.
Show model answer

Answer 1, the Reorder Buffer. Every speculative result is held only in its ROB entry (and in station copies), marked speculative, never in the register file or memory. When the branch resolves wrong: the entries younger than the branch are invalidated and the tail goes back to the entry after the branch; their reservation stations and load buffers are squashed; the rename table is restored to the mapping valid at the branch; fetch is redirected to the correct path; the branch itself commits normally. Nothing has to be undone in the architectural state.

This is the February 2025 quiz. The extra point is the motivation: five concrete actions, and the sentence "nothing speculative ever reached the registers or memory".

Lesson 18 · The speculative Tomasulo algorithm, stage by stage — and the ROB exam table · question 7 of 7 · open in the lesson

Which statements about the reorder buffer are true? (multiple answers)

  • The tag broadcast on the CDB is the ROB entry number The entry is the unique name of the in-flight result from issue to commit.
  • The reservation station is released at commit The station is released at write result; the ROB entry is released at commit.
  • A store writes memory at commit Address and data wait in the entry; memory is written in program order at the head.
  • The tail pointer points to the newest issued instruction The tail points to the next free entry — the one the next issue will take.
  • When head = tail the ROB may be either full or empty The busy bit of that entry tells the two apart.
  • A load may read memory only when no earlier store in the ROB has an unresolved or equal address Memory disambiguation: a RAW hazard through memory, because stores write only at commit.
Show model answer

True: 1, 3, 5, 6. False: 2 (station freed at write result, entry at commit) and 4 (the tail is the next free entry).

Two of the six are about when something is freed; the 2026 paper's multiple-answer quizzes are built from exactly such timing pairs.

To the filters ↑

Module 5 · VLIW and static scheduling

19 questions · Notes, chapter 5 and the past papers · bundles, dependence graphs, list scheduling, unrolling, software pipelining, trace scheduling

Lesson 19 · The compiler takes the wheel: what a VLIW is

Lesson 19 · The compiler takes the wheel: what a VLIW is · question 1 of 5 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by VLIW processors:

  1. Static scheduling by the compiler
  2. Bundle with fixed slots
  3. NOP insertion
  4. Single program counter with at most one branch per bundle
  5. Shared multi-ported register file
  6. Fully pipelined functional units with exposed latencies
  7. Register renaming by the compiler
  8. Hardware support for dynamic events (data-cache misses, branch mispredictions)
Show model answer

1. The compiler analyses data dependences and resource constraints at compile time and decides which operations execute together and in which cycle; the hardware executes the schedule without checking it. Benefit: no dynamic scheduling hardware (no scoreboard, reservation stations or run-time dependence checks), hence less area and power; the compiler sees a much larger instruction window than any hardware. Cost: it must know all latencies and cannot see run-time events.

2. Independent operations are grouped into one very long instruction word; each slot corresponds to one functional unit (e.g. Memory, FP, Integer). Benefit: one fetch delivers k operations, decode is trivial (slot i goes to unit i, no arbitration), and scaling means adding slots.

3. When no independent operation is available for a slot, or a latency must elapse, the compiler fills the slot with a NOP. Benefit: the fixed format and the timing stay explicit, so no stall logic is needed. Cost: wasted slots and larger code; code efficiency = IC / (#cycles × #issues).

4. One PC fetches one bundle per cycle, and a bundle contains at most one branch. Benefit: a single next-PC decision per cycle keeps branch handling simple (in the exam's model the branch is solved in ID with one delay slot).

5. All the operations of a bundle read their operands in the same cycle, and every unit can write a result in every cycle: two read ports and one write port per operation, 8 + 4 for a 4-issue machine. Benefit: every unit gets its operands and writes its result without a bottleneck. Cost: area and power grow quickly with the number of ports, which leads to clustered VLIWs (several smaller register files, each serving a subset of the units).

6. Every unit accepts a new operation each cycle, and its result is available after a fixed latency (e.g. Memory 3, FP 3, Integer 1, 2 to a branch); the compiler places each consumer at least one latency after its producer and fills the gap with independent operations. Benefit: one operation per unit per cycle with no interlocks. Cost: the schedule, hence the binary, depends on the latencies of one implementation.

7. To remove WAR and WAW dependences the compiler writes results into different architectural registers. Benefit: more freedom to reorder and overlap operations, more ILP. Cost: register pressure — every result in flight needs an architectural register; when the register file saturates, values are spilled to memory.

8. The compiler cannot know whether a load will miss in the data cache or whether a static branch hint is wrong. On a miss the processor stalls; on a misprediction the hardware flushes the wrongly fetched bundles. Benefit: correct execution despite unpredictable events, while the regular flow stays free of checks. Cost: a stall freezes the whole schedule, which assumed the hit latency.

The June 2026 paper asks exactly this shape — eight techniques, five lines each, for the Tomasulo-style superscalar; this is its VLIW twin. Give each sub-point its concept in one sentence and its benefit in the next; for 3, 5, 6 and 7 add the cost too, since there the benefit only makes sense against it. Use the precise terms (bundle, slot, NOP, latency, WAR / WAW, renaming, spill), and never let the VLIW hardware "check" or "rename" anything.

Lesson 19 · The compiler takes the wheel: what a VLIW is · question 2 of 5 · open in the lesson

Let's consider the following LOOP1 code, where Ri are integer registers and Fi are floating-point registers:

LOOP1: LD    F2, 0(R1)
       FADD  F6, F2, F2
       SD    F6, 0(R1)
       ADDUI R1, R1, 4
       BNE   R1, R3, LOOP1

Given a 3-issue VLIW machine with fully pipelined functional units: 1 Memory Unit with 3 cycles latency; 1 FP ALU with 4 cycles latency; 1 Integer ALU with 1 cycle latency to next Int/FP/L/S & 2 cycle latency to next Branch. The branch is completed with 1 cycle delay slot (branch solved in ID stage). No branch prediction. In the Register File, it is possible to read and write at the same address at the same clock cycle. Considering one iteration of the loop, complete the following table (Memory Unit | Floating Point Unit | Integer Unit, rows C1 … C15) by using the list-based scheduling (do NOT introduce any software pipelining, loop unrolling and modifications to loop indexes) on the 3-issue VLIW machine including the BRANCH DELAY SLOT. Please do not write in NOPs. (C1 is given: LD F2, 0(R1) in the Memory Unit.)

How long is the critical path for a single iteration? What CPI did you achieve? What performance did you achieve in FP ops per cycle? How much is the code efficiency?

Extra question of this lesson, not of the papers: the same loop compiled for a 3-cycle FP ALU (SD in C7) runs unchanged on this machine. Which instruction reads a wrong value?

Show model answer
Memory UnitFloating Point UnitInteger Unit
C1LD F2, 0(R1)
C2
C3
C4FADD F6, F2, F2
C5
C6
C7
C8SD F6, 0(R1)ADDUI R1, R1, 4
C9
C10BNE R1, R3, LOOP1
C11(delay slot)

FADD at C1 + 3 = C4 (F2 from the memory unit); SD at C4 + 4 = C8 (F6 from the FP ALU); ADDUI in C8 with the SD, its last reader of R1 (read and write in the same cycle); BNE at C8 + 2 = C10; delay slot C11.

Critical path = 11 cycles. CPI = 11 / 5 = 2.2. FP ops per cycle = 1 / 11 = 0.09. Code efficiency = 5 / (11 × 3) = 0.15.

Old binary: SD F6, 0(R1) in C7 reads F6 one cycle before the 4-cycle FADD (issued in C4) writes it, so it stores the F6 of the previous iteration. A VLIW has no hardware that detects the RAW hazard.

The table is the June 2026 EX2 (LOOP1) with one number changed, FP latency 4 instead of 3. Four placements decide it: the RAW distances (3 after the load, 4 after the FADD), the ADDUI in the same cycle as the SD, the 2-cycle distance to the branch and the delay slot counted in the 11. The extra question is this lesson's point: on a VLIW a latency change does not slow the old binary down, it makes it wrong.

Lesson 19 · The compiler takes the wheel: what a VLIW is · question 3 of 5 · open in the lesson

True or False: "A 4-issue VLIW processor requires 4 Program Counters to load the necessary instructions in the 4 parallel lanes."

  • True The four operations travel together in one bundle, fetched with one address; four PCs would mean four instruction streams, as in multithreading.
  • False A VLIW has a single program counter: each fetch brings one bundle, and a bundle holds at most one branch, so there is one next-PC decision per cycle.
Show model answer

False. One PC fetches one bundle per cycle; the bundle carries up to 4 operations in its 4 slots, one per functional unit, and at most one of them is a branch.

A True/False quiz of the 11 February 2025 paper, as the notes transcribe it (p. 582). The statement mixes up the issue width (operations per bundle) with the number of instruction streams. If a motivation line is asked, name the single PC and the one-branch-per-bundle rule.

Lesson 19 · The compiler takes the wheel: what a VLIW is · question 4 of 5 · open in the lesson

True or False: "In VLIW architectures, the compiler can detect parallelism only in basic blocks of the code."

  • True Inside a basic block the dependences are easy to see, but a block holds only about 4 to 7 instructions; a compiler limited to it would leave most VLIW slots empty.
  • False Loop unrolling, software pipelining and trace scheduling find and schedule parallelism across basic blocks and across loop iterations.
Show model answer

False. A basic block (straight-line code with one entry and one exit) holds only about 4 to 7 instructions, and its RAW chains limit the parallelism further. VLIW compilers therefore schedule larger regions: loop unrolling and software pipelining overlap loop iterations, trace scheduling schedules the most likely path through several basic blocks.

A True/False quiz of the 11 February 2025 paper, as the notes transcribe it (p. 581). The notes answer it themselves on p. 273: substantial speedups need "techniques that go beyond individual basic blocks". The three techniques are lesson 21.

Lesson 19 · The compiler takes the wheel: what a VLIW is · question 5 of 5 · open in the lesson

In a VLIW processor, which of the following are handled by the compiler at compile time? (MULTIPLE ANSWERS)

  • RAW hazards between operations The compiler places each consumer at least one latency after its producer and fills the gap with independent operations or NOPs.
  • WAR and WAW hazards By the order of the operations (a WAR writer may share the cycle of its reader) or by renaming into other registers.
  • Structural hazards on the functional units One operation per slot, one slot per unit: the bundle format itself prevents two operations on one unit.
  • Data-cache misses Whether an access misses depends on the run; the hardware stalls the processor when it happens.
  • Branch mispredictions The compiler may give a static hint, but detecting a wrong guess and flushing the pipeline is the hardware's job.
Show model answer

Answers 1, 2 and 3. Data hazards (RAW, WAR, WAW) and structural hazards are solved statically with known latencies and resources; cache misses and branch mispredictions are dynamic events handled by the hardware (stall, flush).

Draw the line between compile time and run time exactly: everything known in advance (latencies, units, register names) belongs to the compiler; everything that depends on the data or on the path taken belongs to the hardware.

Lesson 20 · Graphs, critical paths and the exam table: list scheduling

Lesson 20 · Graphs, critical paths and the exam table: list scheduling · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by a compiler to schedule code statically for a VLIW processor:

  1. Basic block
  2. Dependence graph
  3. Critical path
  4. ASAP scheduling
  5. List-based scheduling
  6. Priority based on the longest path to the sink
  7. Resource reservation table
  8. Local versus global scheduling
Show model answer
  1. A straight-line sequence of instructions with one entry and one exit (only the last instruction may branch). All its instructions execute together, so the compiler can reorder them freely as long as the data dependences hold. It is the unit of local scheduling; its limit is its size — a few instructions between branches.
  2. A DAG with one node per instruction and one edge per dependence: RAW (true), WAR and WAW (name dependences). RAW edges carry the producer's latency. It shows what may run in parallel (unconnected nodes) and what must wait, and it is the input of every scheduler.
  3. The longest latency-weighted path from a source to a sink, LP(i) = max LP(p) + Lat(i). It is the minimum execution time of the block even with unlimited resources: no schedule can beat it. In the exam's VLIW exercise, "critical path for a single iteration" is answered with the length of the scheduled iteration, delay slot included.
  4. Each operation is scheduled in the first cycle in which its operands are available, ignoring resources. It gives the lower bound (= the critical path) and the earliest cycle of every operation; it is not a valid schedule on a real machine, because it can use more units than exist.
  5. ASAP plus resource constraints: in every cycle the ready instructions (operands available) are sorted by priority and the highest ones take the free units. It is greedy and fast, close to optimal on small graphs, and it is what a VLIW compiler — and the exam table — uses.
  6. The priority of an instruction is the longest path from it to the end of the block, computed backwards from the sinks. Instructions with a long chain still ahead go first; instructions with slack fill the holes; ties are broken in program order.
  7. A table of cycles × functional units recording which unit is busy in which cycle. The scheduler checks it before placing an instruction, so no unit is oversubscribed (with fully pipelined units: one new instruction per unit per cycle). Read row by row, it gives the bundles.
  8. Local scheduling works inside one basic block (ASAP, list scheduling; unrolling and software pipelining reshape a loop body); it is simple but limited by the block. Global scheduling moves instructions across branches (trace and superblock scheduling): more ILP, at the cost of compensation code and a more complex compiler.

The 2026 paper asks eight sub-points of this kind with five lines each, on superscalar techniques; this one transposes the form to the static side. The question asks for "main concepts and benefits": give each item a definition plus one benefit or limit. Sub-point 3 is the delicate one: say that the critical path is a resource-independent lower bound, and if you mention the exam table, say that there the iteration length is meant.

Lesson 20 · Graphs, critical paths and the exam table: list scheduling · question 2 of 7 · open in the lesson

Let's consider the following LOOP code, where Ri are integer registers and Fi are floating-point registers.

LOOP: LD    F2, 0(R1)
      LD    F4, 0(R2)
      FADD  F4, F4, F4
      FADD  F6, F2, F2
      FADD  F8, F0, F0
      SD    F6, 0(R1)
      SD    F8, 0(R2)
      ADDUI R1, R1, 4
      ADDUI R2, R2, 4
      BNE   R1, R3, LOOP

Given a 3-issue VLIW machine with fully pipelined functional units: 1 Memory Unit with 3 cycles latency; 1 FP ALU with 3 cycles latency; 1 Integer ALU with 1 cycle latency to next Int/FP/L/S & 2 cycle latency to next Branch. The branch is completed with 1 cycle delay slot (branch solved in ID stage). No branch prediction. In the Register File, it is possible to read and write at the same address at the same clock cycle. Considering one iteration of the loop, complete the table (columns Memory Unit, Floating Point Unit, Integer Unit; rows C1 to C15; C1 is given: LD F2, 0(R1)) by using the list-based scheduling (do NOT introduce any software pipelining, loop unrolling and modifications to loop indexes) including the BRANCH DELAY SLOT. Please do not write in NOPs. How long is the critical path for a single iteration? How much is the code efficiency for a single iteration?

Show model answer

Dependences: LD F2 → FADD F6 (RAW F2, 3) → SD F6 (RAW F6, 3); LD F4 → FADD F4 (RAW F4, 3); FADD F8 → SD F8 (RAW F8, 3); ADDUI R1 after LD F2 and SD F6 (WAR R1, same cycle allowed); ADDUI R2 after LD F4 and SD F8 (WAR R2); BNE at least 2 cycles after ADDUI R1.

Memory UnitFloating Point UnitInteger Unit
C1LD F2, 0(R1)FADD F8, F0, F0
C2LD F4, 0(R2)
C3
C4SD F8, 0(R2)FADD F6, F2, F2ADDUI R2, R2, 4
C5FADD F4, F4, F4
C6
C7SD F6, 0(R1)ADDUI R1, R1, 4
C8
C9BNE R1, R3, LOOP
C10(delay slot)

Critical path for a single iteration: 10 cycles (LD F2 → FADD F6 → SD F6 / ADDUI R1 → BNE → delay slot). Code efficiency = 10 / (10 × 3) = 0.33. (CPI = 10/10 = 1; FP ops per cycle = 3/10 = 0.3.)

This schedule reaches the floor: with unlimited units the chain is also 10 cycles, so the single units cost nothing. Three traps. FADD F4, F4, F4 produces a value nobody uses in the iteration — schedule it anyway. ADDUI R2 cannot go before SD F8, which still reads R2. The printed text says "ADDDUI" and, in one sentence, "4-issue": the machine and the table are 3-issue, so divide by 3. Try it first in the trainer (preset July 2024).

Lesson 20 · Graphs, critical paths and the exam table: list scheduling · question 3 of 7 · open in the lesson

Given the following software pipelined loop:

SP_LOOP: SD    F6, 0(R1)
         SD    F8, 0(R2)
         SD    F10, 0(R3)
         FADD  F6, F0, F0
         FADD  F8, F2, F2
         FADD  F10, F4, F4
         LD    F0, 16(R1)
         LD    F2, 16(R2)
         LD    F4, 16(R3)
         ADDUI R1, R1, 8
         ADDUI R2, R2, 8
         ADDUI R3, R3, 8
         BNE   R1, R4, SP_LOOP

Consider a 4-issue VLIW machine with fully pipelined functional units: 2 Memory Units with 3 cycles latency; 1 FP ALU with 3 cycles latency; 1 Integer ALU with 1 cycle latency to next Int/FP & 2 cycle latency to next Branch. The branch is completed with 1 cycle delay slot (branch solved in ID stage). No branch prediction. In the Register File, it is possible to read and write at the same address at the same clock cycle. Considering one iteration of the SP_LOOP, complete the table (columns Memory Unit 1, Memory Unit 2, Floating Point Unit, Integer Unit; C1 is given: SD F6, 0(R1)) by using the list-based scheduling (do NOT introduce any loop transformation) including the BRANCH DELAY SLOT. Please do not write in NOPs. How long is the critical path for a single iteration? What performance did you achieve in CPI? What performance did you achieve in FP ops per cycles? How much is the code efficiency?

Show model answer

Inside the body there is no RAW chain except ADDUI R1 → BNE: each SD stores a value computed in the previous iteration, each FADD reads a value loaded in the previous iteration. Only WAR edges remain (SD F6 before FADD F6, FADD F6 before LD F0, the SD and LD of each pointer before its ADDUI), and the same cycle is allowed for all of them.

Memory Unit 1Memory Unit 2Floating Point UnitInteger Unit
C1SD F6, 0(R1)LD F0, 16(R1)FADD F6, F0, F0ADDUI R1, R1, 8
C2SD F8, 0(R2)LD F2, 16(R2)FADD F8, F2, F2ADDUI R2, R2, 8
C3SD F10, 0(R3)LD F4, 16(R3)FADD F10, F4, F4ADDUI R3, R3, 8
C4BNE R1, R4, SP_LOOP
C5(delay slot)

Critical path for a single iteration: 5 cycles. CPI = 5/13 ≈ 0.38. FP ops per cycle = 3/5 = 0.6. Code efficiency = 13 / (5 × 4) = 0.65.

The bottleneck is the single Integer ALU: three ADDUIs and the BNE, the BNE last, so the BNE cannot be before C4 — and it reaches C4 only if each ADDUI goes as early as possible, which means pairing each SD and LD with its own pointer, cycle by cycle. The longest-path priority of section 3 does not see this. After C1 every remaining instruction has priority 2, program order sends SD F8 and SD F10 together to the two Memory Units in C2, and LD F2 with ADDUI R2 slips to C3, ADDUI R3 to C4, the BNE to C5: 6 cycles (CPI 6/13 ≈ 0.46, efficiency 13/24 ≈ 0.54), a legal list schedule — and so is plain program order, which also ends at 6. Hand in the 5, with one line on the tie-break. Why the loop looks like this (iteration i is stored, i + 1 computed, i + 2 loaded, hence the offset 16) is lesson 21; here you only schedule it.

Lesson 20 · Graphs, critical paths and the exam table: list scheduling · question 4 of 7 · open in the lesson

Let's consider the two following loops LOOP1 and LOOP2, where Ri are integer registers and Fi are floating-point registers:

LOOP1: LD    F2, 0(R1)
       FADD  F6, F2, F2
       SD    F6, 0(R1)
       ADDUI R1, R1, 4
       BNE   R1, R3, LOOP1
LOOP2: SD    F6, 0(R2)
       FADD  F6, F2, F2
       LD    F2, 0(R2)
       ADDUI R2, R2, 4
       BNE   R2, R3, LOOP2

Given a 3-issue VLIW machine with fully pipelined functional units: 1 Memory Unit with 3 cycles latency; 1 FP ALU with 3 cycles latency; 1 Integer ALU with 1 cycle latency to next Int/FP/L/S & 2 cycle latency to next Branch. The branch is completed with 1 cycle delay slot (branch solved in ID stage). No branch prediction. In the Register File, it is possible to read and write at the same address at the same clock cycle. Considering one iteration of each loop, complete the following tables (rows C1 to C10; C1 is given: LD F2, 0(R1) for LOOP1 and SD F6, 0(R2) for LOOP2) by using the list-based scheduling (do NOT introduce any software pipelining, loop unrolling and modifications to loop indexes) on the 3-issue VLIW machine including the BRANCH DELAY SLOT. Please do not write in NOPs. For LOOP1 and LOOP2: How long is the critical path for a single iteration? What performance did you achieve in CPI? What performance did you achieve in FP ops per cycles? How much is the code efficiency? How much is the speed up in terms of CPI?

Show model answer
LOOP1Memory UnitFloating Point UnitInteger Unit
C1LD F2, 0(R1)
C2
C3
C4FADD F6, F2, F2
C5
C6
C7SD F6, 0(R1)ADDUI R1, R1, 4
C8
C9BNE R1, R3, LOOP1
C10(delay slot)
LOOP2Memory UnitFloating Point UnitInteger Unit
C1SD F6, 0(R2)FADD F6, F2, F2
C2LD F2, 0(R2)ADDUI R2, R2, 4
C3
C4BNE R2, R3, LOOP2
C5(delay slot)
LOOP1LOOP2
Critical path10 cycles5 cycles
CPI10/5 = 25/5 = 1
FP ops per cycle1/10 = 0.11/5 = 0.2
Code efficiency5/(10 × 3) ≈ 0.175/(5 × 3) ≈ 0.33
Speed-up in CPI2 / 1 = 2

LOOP1 is one RAW chain, LD → FADD → SD, plus the branch: 10 cycles, all forced. In LOOP2 the same three operations have only WAR edges between them: SD reads the old F6 before FADD overwrites it, FADD reads the old F2 before LD overwrites it. SD and FADD share C1; the LD waits for the single Memory Unit (C2), the ADDUI follows its last reader (C2), the BNE is two cycles later. The same five instructions, half the cycles — the before and after of software pipelining that lesson 21 builds. The paper prints "ADDDUI" for ADDUI.

Lesson 20 · Graphs, critical paths and the exam table: list scheduling · question 5 of 7 · open in the lesson

The dependence graph of a basic block has a critical path of 7 cycles. Which statement is true for any list-based schedule of the block on a machine with one functional unit of each type? (SINGLE ANSWER)

  • Answer 1: it is always exactly 7 cycles long Only when the units never delay an instruction of the critical path; with the MUL latency at 1, the graph a–g of the notes needs 6 cycles on one ALU against a critical path of 5.
  • Answer 2: it is never shorter than 7 cycles The critical path is the length with unlimited resources: fewer resources can only add waiting.
  • Answer 3: it is never longer than 7 cycles Busy units can delay instructions of the critical path: the January 2026 loop has a floor of 13 and needs 14 on one Memory Unit.
  • Answer 4: its length does not depend on the priority function List scheduling is greedy: the order in which it serves the ready set can change the length. Two loads are ready in C1, one at the head of the critical chain, one whose value nobody waits for: serve the second first and the whole chain slips by a cycle.
Show model answer

Answer 2. The critical path is a resource-independent lower bound; resources and priorities can only make the schedule equal to it or longer.

A single-answer quiz in the style of the paper's block. The trap is Answer 1, which is what students conclude after seeing a few schedules that reach the floor.

Lesson 20 · Graphs, critical paths and the exam table: list scheduling · question 6 of 7 · open in the lesson

The January 2026 loop needs 14 cycles per iteration on the 3-issue VLIW of the paper (1 Memory Unit, 1 FP ALU, 1 Integer ALU; latencies 3, 3, 1 and 2 to the branch). Which of the following single changes of the machine would shorten the schedule? (MULTIPLE ANSWERS)

  • Answer 1: a second Memory Unit LD F4, VC(R6) can then share C7 with SD F4, VA(R7): 13 cycles, the floor.
  • Answer 2: a second FP ALU The FP unit is never the bottleneck: FADD F8 already sits in C1 and FADD F4 waits for its operand, not for the unit. Still 14.
  • Answer 3: a second Integer ALU The two ADDUIs never wait for the unit, and the BNE waits for R7. Still 14.
  • Answer 4: a Memory Unit with 2 cycles latency Two load latencies lie on the critical chain (LD F2 → FADD, LD F4 → SD): 12 cycles.
  • Answer 5: an FP ALU with 2 cycles latency FADD F4 → SD F4 is on the chain: 13 cycles.
Show model answer

Answers 1, 4 and 5: they give 13, 12 and 13 cycles. Answers 2 and 3 leave 14: the units they add are never waited for.

The question tests whether you know where the critical path runs and which constraints are latencies (they move the floor) and which are resources (they can only close the gap to the floor). The trainer above lets you verify each case.

Lesson 20 · Graphs, critical paths and the exam table: list scheduling · question 7 of 7 · open in the lesson

True or False: the longest path of the dependence graph of a basic block, computed with the latencies of the machine, becomes shorter when a second memory unit is added to the machine.

  • True The longest path is computed with unlimited resources: the number of units does not appear in it. A second unit can shorten the schedule, never the critical path.
  • False Correct: only latencies and dependences enter the longest path. Units change how close a real schedule gets to it.
Show model answer

False. LP(i) = max LP(p) + Lat(i) contains latencies and edges only; the number of functional units changes the list schedule, not the critical path.

A true/false quiz, one point. Keep apart the two meanings of "critical path": the graph's longest path (machine-independent) and, in the exam's VLIW exercise, the length of your scheduled iteration.

Lesson 21 · Same loop, three shapes: unrolling, software pipelining and betting on the hot path

Lesson 21 · Same loop, three shapes: unrolling, software pipelining and betting on the hot path · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following static scheduling techniques used by compilers for VLIW processors, and state the main drawback of each: (1) Loop unrolling; (2) Software pipelining; (3) Trace scheduling; (4) Superblock scheduling; (5) Predication (if-conversion).

Show model answer

(1) Loop unrolling replicates the loop body u times in one block, adjusts the displacements of the copies (0, 8, 16, …) and keeps a single index update and a single branch. The compiler renames the registers of each copy, removing the WAR and WAW dependences between copies, so the scheduler can interleave u independent chains and hide latencies. Benefits: fewer branches and index updates per element, fewer stalls, more operations per bundle (x[i] = x[i] + s: 10 cycles per element → 3.5 on a single-issue pipeline with a delay slot). Costs: code size, (u − 1) times the registers a copy writes, a remainder loop when the trip count is not a multiple of u.

(2) Software pipelining reorganises the loop so that each execution of the body contains stages of different iterations — store of i, compute of i + 1, load of i + 2 — in reverse order. The true dependences of an iteration no longer lie inside one body; only anti-dependences and the loop control do. A prologue fills and an epilogue drains the pipeline. Benefits: one iteration completes per execution of the body, with the body's original size and the same registers (June 2026: LOOP1 10 cycles, LOOP2 5 cycles, CPI speed-up 2). Costs: prologue and epilogue code, extra registers when a value must live longer than one pass, at least as many iterations as stages, compiler complexity.

(3) Trace scheduling is global scheduling across basic blocks: profiling selects the most likely path (the trace, acyclic), which is list-scheduled as one block; instructions move across branches (above them speculatively) and across joins. Compensation code — copies of moved instructions on the off-trace exit and entry paths — keeps the other paths correct. Benefits: fills wide instructions beyond the 4 to 7 instructions of a basic block and starts long-latency loads early. Costs: code growth from compensation code, slower off-trace paths, dependence on predictable branches, a complex compiler; stores and instructions that may raise exceptions cannot be speculated freely.

(4) Superblock scheduling restricts the region to a single entry and multiple exits, obtained by tail duplication: the part of the trace below a side entrance is copied for the entering path. Moves then need compensation only at the exits, outside the superblock, so speculation is simpler and safer. Cost: the duplicated code.

(5) Predication removes a branch instead of scheduling around it: a compare sets a predicate register and its complement, and the instructions of each arm are guarded by one of them — always issued, but writing their result only when their predicate is true. The control dependence becomes a data dependence on the predicate, so both arms form one larger basic block that the scheduler can fill, with nothing to mispredict and no compensation code. Cost: both arms take issue slots on every pass, so it pays only for short, balanced, hard-to-predict branches; it needs predicate registers in the ISA (IA-64).

The June 2026 paper asked eight such sub-points for 8 points, about five lines each. A complete sub-point has three things: the mechanism in one or two sentences, the benefit with a number from an exercise, the cost. The contrasts make the answer crisp — unrolling replicates while software pipelining interleaves; trace scheduling repairs at entries and exits, a superblock only at exits, predication nowhere — and so does one sentence saying that the compiler applies all five, the VLIW doing no dependence checking at run time.

Lesson 21 · Same loop, three shapes: unrolling, software pipelining and betting on the hot path · question 2 of 7 · open in the lesson

Given the following software pipelined loop:

SP_LOOP: SD    F6, 0(R1)
         SD    F8, 0(R2)
         SD    F10, 0(R3)
         FADD  F6, F0, F0
         FADD  F8, F2, F2
         FADD  F10, F4, F4
         LD    F0, 16(R1)
         LD    F2, 16(R2)
         LD    F4, 16(R3)
         ADDUI R1, R1, 8
         ADDUI R2, R2, 8
         ADDUI R3, R3, 8
         BNE   R1, R4, SP_LOOP

Consider a 4-issue VLIW machine with fully pipelined functional units: 2 Memory Units with 3 cycles latency; 1 FP ALU with 3 cycles latency; 1 Integer ALU with 1 cycle latency to next Int/FP and 2 cycle latency to next Branch. The branch is completed with 1 cycle delay slot (branch solved in ID stage). No branch prediction. In the Register File, it is possible to read and write at the same address at the same clock cycle. Considering one iteration of the SP_LOOP, complete the table (Memory Unit 1, Memory Unit 2, Floating Point Unit, Integer Unit; C1 given: SD F6, 0(R1)) by using the list-based scheduling (do NOT introduce any loop transformation), including the branch delay slot. Then: how long is the critical path for a single iteration? What performance did you achieve in CPI and in FP ops per cycle? How much is the code efficiency?

Show model answer

There is no true dependence among the SDs, FADDs and LDs: each SD reads the value its FADD rewrites (WAR), each FADD reads the value its LD rewrites (WAR), and every ADDUI may share the cycle of the last instruction that reads its register. The integer unit has four instructions to issue (three ADDUI and BNE), so each stream's SD and LD are placed together to free its ADDUI as early as possible.

Memory Unit 1Memory Unit 2Floating Point UnitInteger Unit
C1SD F6, 0(R1)LD F0, 16(R1)FADD F6, F0, F0ADDUI R1, R1, 8
C2SD F8, 0(R2)LD F2, 16(R2)FADD F8, F2, F2ADDUI R2, R2, 8
C3SD F10, 0(R3)LD F4, 16(R3)FADD F10, F4, F4ADDUI R3, R3, 8
C4BNE R1, R4, SP_LOOP
C5(delay slot)

Critical path = 5 cycles. CPI = 5/13 ≈ 0.38. FP ops per cycle = 3/5 = 0.6. Code efficiency = 13/(5 × 4) = 0.65.

Five cycles is optimal: six memory operations need three cycles on two units, the ADDUI of the stream loaded last cannot precede C3, and the single integer unit needs a fourth cycle for BNE. A pure program-order tie-break (SD F6 and SD F8 together in C1) is also a list schedule, but it delays LD F2 and LD F4, pushes ADDUI R3 to C4 and BNE to C5: 6 cycles, CPI 0.46, 0.5 FP ops per cycle, efficiency 0.54. Write the reasoning about the integer unit next to the table: it is what justifies pairing each SD and LD in one cycle. Lesson 20 drills the same table as a list-scheduling exercise.

Lesson 21 · Same loop, three shapes: unrolling, software pipelining and betting on the hot path · question 3 of 7 · open in the lesson

Consider the following software pipelined loop SP_LOOP and its start-up code; R1 points to the first element of an array of n doubles.

START_UP: LD    F0, 0(R1)
          FADD  F4, F0, F2
          LD    F0, 8(R1)
SP_LOOP:  SD    F4, 0(R1)
          FADD  F4, F0, F2
          LD    F0, 16(R1)
          ADDUI R1, R1, 8
          BNE   R1, R5, SP_LOOP

(a) Reconstruct the original (non-pipelined) loop. (b) For each of the first three instructions of SP_LOOP, state which iteration of the original loop it belongs to. (c) Write the finish-up code. (d) For n = 100, how many times is the body of SP_LOOP executed, and which value must R5 hold?

Show model answer

(a) With R3 = initial R1 + 8n:

LOOP: LD    F0, 0(R1)
      FADD  F4, F0, F2
      SD    F4, 0(R1)
      ADDUI R1, R1, 8
      BNE   R1, R3, LOOP

(b) SD F4, 0(R1): iteration i, whose sum was computed in the previous pass. FADD F4, F0, F2: iteration i + 1, whose operand was loaded in the previous pass. LD F0, 16(R1): iteration i + 2 — two strides ahead, 16 = 2 × 8.

(c) FINISH_UP: SD F4, 0(R1) (element n − 2); FADD F4, F0, F2 (element n − 1); SD F4, 8(R1) (element n − 1).

(d) The body handles i = 0 … n − 3: it runs n − 2 = 98 times. R5 = initial R1 + 8 × 98 = R1 + 784, the address of element 98.

The classic mistake is to read SD as "store the result of this pass" and put it first in the reconstructed loop. Follow one value through the passes instead. In (c), remember that the last ADDUI of the body has already moved R1.

Lesson 21 · Same loop, three shapes: unrolling, software pipelining and betting on the hot path · question 4 of 7 · open in the lesson

Let's consider the two following loops, where LOOP2 is the software-pipelined form of LOOP1 (its load fetches the element two iterations ahead):

LOOP1: LD    F2, 0(R1)
       FADD  F6, F2, F2
       SD    F6, 0(R1)
       ADDUI R1, R1, 4
       BNE   R1, R3, LOOP1
LOOP2: SD    F6, 0(R2)
       FADD  F6, F2, F2
       LD    F2, 8(R2)
       ADDUI R2, R2, 4
       BNE   R2, R3, LOOP2

Both are scheduled by list-based scheduling, including the branch delay slot, on a 4-issue VLIW machine with fully pipelined units: 2 Memory Units with 3 cycles latency, 1 FP ALU with 3 cycles latency, 1 Integer ALU with 1 cycle latency to next Int/FP and 2 cycle latency to next Branch; branch solved in ID with 1 delay slot; read and write at the same register-file address in the same clock cycle. How much is the speed up of LOOP2 over LOOP1 in terms of CPI?

Show model answer

LOOP1 does not change: its chain LD (C1) → FADD (C4) → SD with ADDUI (C7) → BNE (C9) → delay slot (C10) uses one memory unit at a time. 10 cycles, CPI = 10/5 = 2.

LOOP2: SD F6, 0(R2) and LD F2, 8(R2) both fit in C1 (two memory units, two different addresses), with FADD F6 (WAR on F6 and F2) and ADDUI R2 (WAR on R2) in the same cycle; BNE in C3, delay slot in C4. 4 cycles, CPI = 4/5 = 0.8.

\[ \text{speed-up} = \frac{2}{0.8} = 2.5 \]

The second memory unit helps only the software-pipelined loop: LOOP1 is bound by its true-dependence chain, LOOP2 by resources and the branch. The paper itself prints LOOP2's load as LD F2, 0(R2): then the store and the load of one pass touch the same address, the load must not move up beside the store that precedes it, it stays in C2, and LOOP2 takes 5 cycles — a speed-up of 2. With one memory unit, as in the paper, the question never arises.

Lesson 21 · Same loop, three shapes: unrolling, software pipelining and betting on the hot path · question 5 of 7 · open in the lesson

Let's consider the following code: for (i=0; i<260; i++) Y[i] = X[i] + Y[i]; Which code transformation can be applied to be executed by the VMIPS processor with a Vector Register File composed of 16 Vector registers of 32 elements and 64 bits/element? Motivate your answer.

  • Trace scheduling A VLIW compiler technique for scheduling across branches; this loop has no branch inside and the problem is the vector length.
  • Software pipelining It overlaps iterations of a scalar loop on a statically scheduled machine; it does not make 260 elements fit 32-element registers.
  • Strip mining 260 > 32, so the loop is cut into strips of at most 32 elements, with the vector length register set for each strip.
  • Apply a mask register A mask handles conditional statements inside a vector loop; there is no condition here.
Show model answer

Strip mining. The loop has 260 elements and a vector register holds 32: 260 = 8 × 32 + 4, so a first strip of 4 elements and then eight strips of 32, setting VLR for each strip.

The distractors are the techniques of this lesson; strip mining itself is lesson 31. The motivation point is the arithmetic 260 = 8 × 32 + 4.

Lesson 21 · Same loop, three shapes: unrolling, software pipelining and betting on the hot path · question 6 of 7 · open in the lesson

True or false: in the steady state, a software-pipelined loop completes one iteration every clock cycle.

  • True That holds only if the whole body, branch included, fits one bundle; LOOP2 of June 2026 completes one iteration every 5 cycles.
  • False One iteration completes per execution of the body, every II cycles, where II is the length of the body's schedule.
Show model answer

False. Each execution of the body finishes one iteration, so the throughput is one iteration per initiation interval — 5 cycles for LOOP2 on the 3-issue VLIW of June 2026, 8 cycles for the midterm's SP_LOOP.

The notes repeat the wrong version five times (pp. 289–291); the CPI you compute in the VLIW exercise contradicts it.

Lesson 21 · Same loop, three shapes: unrolling, software pipelining and betting on the hot path · question 7 of 7 · open in the lesson

Which of the following statements about trace and superblock scheduling are true? (MULTIPLE ANSWERS)

  • An instruction moved from below a branch to above it needs no compensation code if its result is dead on the other path and it cannot store or raise an exception. Speculation is free exactly in this case: the off-trace path simply never uses the value.
  • An instruction moved above a side entrance into the trace needs a copy on the entering path. Otherwise the path that enters from the side would skip it.
  • A superblock may have several entries but only one exit. The other way round: one entry, any number of exits.
  • Tail duplication removes side entrances at the price of code size. The tail below the entrance is copied for the entering path.
  • A trace may contain a loop's back edge. Traces are acyclic; a back edge ends a trace, which is why loops are unrolled first.
Show model answer

Answers 1, 2 and 4.

The two directions of compensation are what the question checks: copies go on the exit path for moves below a branch and on the entering path for moves above a join.

To the filters ↑

Module 6 · Memory hierarchy

47 questions · Notes, chapter 6 and 4.4 · caches, the AMAT formulas of the formula sheet, nineteen optimisations, virtual memory

Lesson 22 · The memory wall and the illusion of a fast, big memory

Lesson 22 · The memory wall and the illusion of a fast, big memory · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following concepts of the memory hierarchy: 1. Memory hierarchy; 2. Temporal locality; 3. Spatial locality; 4. Cache block (cache line); 5. Hit time and miss penalty; 6. Average Memory Access Time (AMAT); 7. Separate instruction and data caches (Harvard architecture) versus a unified cache; 8. SRAM and DRAM technologies.

Show model answer

1. A layered memory system: small, fast, expensive levels close to the processor (registers; L1, L2, L3 caches in SRAM) and large, slow, cheap levels further away (main memory in DRAM, disk). Each upper level holds a subset of the level below. Benefit: the processor sees one large memory with an average access time close to that of the fastest level, at a cost per bit close to that of the cheapest (the illusion of a large, fast memory). It works only because programs have locality. Registers are managed by the compiler, caches by hardware, main memory and disk by the operating system.

2. A location accessed now is likely to be accessed again soon (an accumulator in a loop, the instructions of a loop body). Exploited by keeping recently used blocks in the cache and, when space is needed, replacing the least recently used one (LRU), so that the repeated accesses hit. Benefit: after the first access the reused word costs only the hit time; the cache needs enough capacity to keep the block until the reuse comes.

3. After a location, nearby locations are likely to be accessed soon (array elements a[i], a[i+1]; sequential instructions). Exploited by transferring whole multi-word blocks: one miss brings the neighbours, whose accesses then hit (8 doubles in a 64-byte block: 1 miss, 7 hits). Benefit: one miss penalty is shared by several accesses; if the neighbours are never used, a larger block only makes each miss longer.

4. The smallest unit transferred between memory and cache, typically 32 to 128 bytes; number of blocks = cache size / block size (64 KB / 16 B = 4096). Benefit: one transfer serves several accesses (spatial locality). Cost: a larger block makes each miss longer.

5. Hit time: time to access the cache, determine whether it is a hit and return the data (1 to 3 cycles for L1). Miss penalty: extra time to fetch the block from the lower level, write it into the cache and resume the CPU (tens to hundreds of cycles). On a miss the CPU stalls, the block is fetched and written, and the access is retried; miss time = hit time + miss penalty.

6. AMAT = Hit Rate × Hit Time + Miss Rate × (Hit Time + Miss Penalty) = Hit Time + Miss Rate × Miss Penalty, because Hit Rate + Miss Rate = 1: every access pays the hit time, the misses add the penalty. The miss rate is a fraction (5% = 0.05): 1 + 0.05 × 100 = 6 cycles. Benefit: one number that combines the three parameters and shows the three ways to improve a cache: reduce the hit time, the miss rate or the miss penalty.

7. Split L1: separate I-cache and D-cache, so the pipeline can fetch an instruction and access data in the same cycle (no structural hazard). AMAT = %Instr × (HT + MRI × MP) + %Data × (HT + MRD × MP), with %Instr = 1/(1 + d) and %Data = d/(1 + d), d = loads/stores per instruction. Unified: one cache shared flexibly between code and data, usually a lower miss rate for the same total size, but with one port every data access stalls one cycle. Example: unified 1.99% against split 2.10% miss rate, yet AMAT 2.245 against 2.05 cycles: the split cache is better there because of the port, and the comparison must be made on AMAT.

8. SRAM: six transistors per bit, fast but large and expensive per bit, used for the caches. DRAM: one transistor and a capacitor per bit, dense and cheap but slower, and it must be refreshed; used for main memory (SDRAM and DDR are DRAM). No single technology is both fast and big, which is why the hierarchy combines them.

The 2026 paper leaves five lines per sub-point: room for a definition, the mechanism, the benefit, the cost and a number. In sub-point 6 write the derivation, not only the final formula; in sub-point 7 give the reason the unified cache loses, the structural hazard on its single port. Writing SDRAM for the caches in sub-point 8 repeats the notes' slip of p. 297.

Lesson 22 · The memory wall and the illusion of a fast, big memory · question 2 of 6 · open in the lesson

MEMORY HIERARCHY. Let's consider a processor where 25% of the instructions are loads/stores, with two alternative L1 organisations of the same total size: (a) separate instruction and data caches (Harvard architecture) with Miss RateI$ = 1% and Miss RateD$ = 6%; (b) a unified cache with Aggregate Miss Rate = 1.8% and only one port, so a data access has 1 more stall cycle. Hit Time = 1 clock cycle and Miss Penalty = 50 clock cycles in both cases.

1. How much are the percentages of instruction accesses and of data accesses? 2. How much is the miss rate of the Harvard organisation over all accesses? 3. How much is the AMAT of each organisation? 4. Which organisation is better, and why?

Show model answer

1. Per instruction: 1 fetch + 0.25 data accesses = 1.25 accesses. %Instr = 1 / 1.25 = 0.80 (80%); %Data = 0.25 / 1.25 = 0.20 (20%).

2. MRHarvard = 0.8 × 0.01 + 0.2 × 0.06 = 0.008 + 0.012 = 0.020 (2.0%), higher than the unified 1.8%.

3. AMATHarvard = 0.8 × (1 + 0.01 × 50) + 0.2 × (1 + 0.06 × 50) = 0.8 × 1.5 + 0.2 × 4 = 1.2 + 0.8 = 2.0 cycles. AMATunified = 0.8 × (1 + 0.018 × 50) + 0.2 × (1 + 1 + 0.018 × 50) = 0.8 × 1.9 + 0.2 × 2.9 = 1.52 + 0.58 = 2.1 cycles.

4. The Harvard organisation is better, 2.0 against 2.1 cycles, although its miss rate is higher (2.0% against 1.8%). The unified cache saves (0.020 − 0.018) × 50 = 0.1 cycles per access on misses but loses 0.2 × 1 = 0.2 cycles per access in structural-hazard stalls on its single port. The comparison is decided by AMAT, not by the miss rate.

The same structure as the notes' Example 6 with rounder numbers. The steps to get right: the shares derived per instruction (80% and 20%, not 75% and 25%), every percentage converted to a fraction, and the "why" of point 4: the structural hazard and its cost per access.

Lesson 22 · The memory wall and the illusion of a fast, big memory · question 3 of 6 · open in the lesson

A cache has a Hit Time of 1 clock cycle and a Miss Penalty of 100 clock cycles. Which Miss Rate gives an AMAT of 3 clock cycles? Write it as a decimal fraction, not as a percentage.

Show model answer

AMAT = Hit Time + Miss Rate × Miss Penalty ⇒ 3 = 1 + Miss Rate × 100 ⇒ Miss Rate = 2 / 100 = 0.02 (2%).

The answer "2" is the percentage written as a bare number: the "unit is %" trap of p. 321 in reverse. Check it: 1 + 0.02 × 100 = 3.

Lesson 22 · The memory wall and the illusion of a fast, big memory · question 4 of 6 · open in the lesson

(Single answer.) Let's consider a cache with Hit Time = 1 clock cycle, Miss Rate = 5% and Miss Penalty = 100 clock cycles. How much is the AMAT?

  • Answer 1: 5.95 clock cycles 0.95 × 1 + 0.05 × 100 forgets the hit time that the misses pay too.
  • Answer 2: 6 clock cycles 1 + 0.05 × 100: every access pays the hit time, the misses add the penalty on average.
  • Answer 3: 101 clock cycles That is the cost of one miss, hit time plus miss penalty, not the average.
  • Answer 4: 501 clock cycles The miss rate was entered as 5 instead of 0.05.
Show model answer

Answer 2: AMAT = 1 + 0.05 × 100 = 6 clock cycles.

The notes' Example 3. Each distractor is one classic slip: the dropped hit time, the cost of one miss, the percentage used as a number.

Lesson 22 · The memory wall and the illusion of a fast, big memory · question 5 of 6 · open in the lesson

(Multiple answers.) Which of the following statements about locality and caches are correct?

  • Answer 1: Temporal locality is exploited by keeping recently accessed blocks in the cache and replacing the least recently used one The reused word is still there when it is needed again; LRU protects the blocks in use.
  • Answer 2: Spatial locality is exploited by transferring multi-word blocks between memory and cache One miss brings the neighbours, whose accesses then hit.
  • Answer 3: A larger block size helps a program that reads each element of a large array once, in random order The neighbours are read only much later, long after their block has been evicted: each block serves one useful word, and a larger block only makes each miss longer.
  • Answer 4: The instructions of a loop body show both temporal and spatial locality They are fetched again in every iteration (temporal) and lie at consecutive addresses (spatial).
  • Answer 5: Without any locality, a cache still reduces the average memory access time Every access misses: AMAT = hit time + miss penalty, more than accessing memory directly.
Show model answer

Answers 1, 2 and 4.

The locality probe shows four of the five: answers 1 and 2 are its first program (capacity, then block size), answers 3 and 5 its third. Answer 4 is the instruction stream of the six-instruction loop in section 2: fetched again in every iteration, from consecutive addresses.

Lesson 22 · The memory wall and the illusion of a fast, big memory · question 6 of 6 · open in the lesson

(True/False.) For the same total size, a unified L1 cache always has a higher AMAT than separate instruction and data caches.

  • True In the notes' Example 6 the split cache wins only because the unified one has a single port; without that stall the unified cache, with its lower miss rate, has AMAT 1.995 against 2.049.
  • False The result depends on the miss rates, the share of data accesses, the miss penalty and the number of ports: compute both AMATs.
Show model answer

False. A unified cache usually has the lower miss rate for the same size; it loses only when the structural-hazard stalls on its single port cost more than its miss-rate advantage saves (Example 6: 0.25 cycles against about 0.05 per access). With two ports, or a large enough miss penalty (above about 233 cycles with the numbers of Example 6), it wins.

An "always" in a true/false question is a hint to look for the counterexample. Here it is one line of arithmetic.

Lesson 23 · Anatomy of a cache: the four questions and the exam cache table

Lesson 23 · Anatomy of a cache: the four questions and the exam cache table · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used in cache memories: (a) direct-mapped block placement; (b) fully associative block placement; (c) set-associative block placement; (d) block identification by tag comparison; (e) LRU replacement; (f) write-back with dirty bit; (g) write-through with write buffer; (h) write allocate and no write allocate. (Five lines each.)

Show model answer

(a) Each memory block can be placed in exactly one cache line, line = block address mod #blocks: the index bits select the line and a single tag comparison decides hit or miss. Benefit: the simplest and fastest organisation — one comparator, no replacement decision, and the data can be read while the tag is being checked. Cost: conflict misses — two blocks with the same index evict each other at every access (blocks 12 and 20 in an 8-line cache), even while other lines are empty.

(b) A block may be placed in any line: there is no index, the whole block address is the tag, and the address tag is compared with the tags of all lines in parallel. Benefit: no conflict misses, and full freedom for the replacement policy. Cost: one comparator per line plus the logic that selects the matching line — expensive in area and energy, and slower, so it is used only for small caches and buffers.

(c) The cache is divided into sets of n lines (ways); a memory block maps to exactly one set, set = block address mod #sets, and may occupy any of its n ways. Benefit: far fewer conflict misses than direct-mapped (two blocks with the same index can coexist) at a much lower cost than fully associative, since only the n tags of one set are compared. Cost: n comparators and an n-way multiplexer, so a slightly longer hit time and more energy.

(d) The address is split into tag | index | offset: offset = log2(block size), index = log2(#sets), tag = the remaining high-order bits. The index selects the set, the n stored tags of that set are compared with the address tag in parallel, and a way hits if its tag is equal and its valid bit is 1; the offset then selects the word. Benefit: one parallel lookup; only the tag is stored, since index and offset are implied by the position; the valid bit prevents false hits at cold start.

(e) On a miss into a full set, the block whose last use (read or write, hit or fill) is oldest is evicted; the order of use is updated on every access. Benefit: it exploits temporal locality — recently used blocks are likely to be used again — so it usually misses less than FIFO or random. Cost: state per set grows as log2(n!) bits and must be updated on every hit, so highly associative caches use pseudo-LRU or random.

(f) A write updates only the cache line and sets its dirty bit; main memory is updated with the whole block only when a dirty block is evicted. Benefit: many writes to the same block cost one memory write, less memory traffic and writes at cache speed. Cost: a dirty bit per line, memory stale until eviction, and a miss that evicts a dirty block must write it back as well.

(g) Every write updates the cache (on a hit) and main memory; a small FIFO write buffer holds the pending writes so the processor continues while they drain to memory, stalling only if the buffer is full. Benefit: memory is always up to date, simple control, no write-back on eviction. Cost: one memory transaction per store, so high traffic; without the buffer every store would stall for a memory write.

(h) On a write miss, write allocate fetches the block into the cache and then writes it (as a read miss would); no write allocate writes the word directly to memory and leaves the cache unchanged. Write allocate is paired with write-back: once allocated, further writes to the block hit and generate no traffic. No write allocate is paired with write-through: every write goes to memory anyway, so fetching the block would only add traffic; it also keeps data that is written once and not read soon from evicting useful blocks.

Eight sub-points for 8 points, five lines each: the form of the June 2026 open question. Every answer needs three things: the mechanism in one sentence (with the formula where there is one: mod #blocks, mod #sets, log2), what it buys, what it costs. Do not write "LRU evicts the oldest block" in (e): that describes FIFO. In (h) give the pairing and its reason, not the pairing alone.

Lesson 23 · Anatomy of a cache: the four questions and the exam cache table · question 2 of 7 · open in the lesson

Let's consider the following memory hierarchy addressed at word-level (32-bit): main memory size = 4 Giga word; 4-way set-associative cache with cache size = 1 Mega word and block size = 256 word. Please indicate the structure of the 32-bit memory address: (SINGLE ANSWER)

  • Answer 1: |12-bit tag | 12-bit index | 8-bit offset| 12 index bits would mean 4096 sets: that is the same cache direct-mapped, one line per set.
  • Answer 2: |24-bit tag | 8-bit offset| No index at all means a single set: fully associative, not 4-way.
  • Answer 3: |14-bit tag | 10-bit index | 8-bit offset| Offset log2 256 = 8; 2^20 / 2^8 = 4096 lines; 4096 / 4 = 1024 sets → 10 index bits; 32 − 10 − 8 = 14.
  • Answer 4: |13-bit tag | 11-bit index | 8-bit offset| 11 index bits = 2048 sets of 2 ways: the 2-way version of the cache.
Show model answer

Answer 3. Offset = log2(256) = 8 bits; number of blocks = 2^20 / 2^8 = 2^12; number of sets = 2^12 / 4 = 2^10, so index = 10 bits; tag = 32 − 10 − 8 = 14 bits.

Quiz 2 of the 15 July 2024 paper, in its own words. The three distractors are the same cache at 1, 2 and 4096 ways — so if you only remember that "more ways move bits from the index to the tag", you can still pick the right one.

Lesson 23 · Anatomy of a cache: the four questions and the exam cache table · question 3 of 7 · open in the lesson

Let's consider a 32-block main memory with a 4-way set associative 8-block cache based on a write allocate with write-back protocol with LRU. The addresses are expressed as: Memory Addresses [0, 1, 2, … 31]10; Cache Addresses [a, b, c, d, e, f, g, h], and Cache Tags are expressed as binary numbers. How many sets? (Answer 1: 2; Answer 2: 4; Answer 3: 8; Answer 4: 16.) At cold start the cache is empty, then there is the following sequence of memory accesses: Write 16, Write 14, Write 07, Read 14, Write 16, Read 12, Write 18, Read 06, Write 04, Write 30. Please complete the table (Hit/Miss Type, Cache Tag, Set, Cache Address, Dirty bit, Write in memory). How much is the miss rate?

Show model answer

Sets = 8 / 4 = 2 (Answer 1). The 5-bit block address = 4-bit tag | 1-bit set: set = address mod 2, tag = address div 2. Set 0 = lines a–d, set 1 = lines e–h; a free line is taken in alphabetical order, otherwise the LRU line of the set. "Yes (14)" means: the evicted block 14 is dirty and is written back to memory. The last column is scratch work, not a column of the paper.

Type of memory accessMemory AddressHit/ Miss TypeCache TagSetCache AddressDirty bitWrite in memoryscratch: the set after it, LRU first
1Write[16]10Cold-start Miss[1000]2[0]10a1No16
2Write[14]10Cold-start Miss[0111]2[0]10b1No16 14
3Write[07]10Cold-start Miss[0011]2[1]10e1No7
4Read[14]10Hit[0111]2[0]10b1No16 14
5Write[16]10Hit[1000]2[0]10a1No14 16
6Read[12]10Cold-start Miss[0110]2[0]10c0No14 16 12
7Write[18]10Cold-start Miss[1001]2[0]10d1No14 16 12 18
8Read[06]10Cold-start Miss (replaces LRU 14)[0011]2[0]10b0Yes (14)16 12 18 6
9Write[04]10Cold-start Miss (replaces LRU 16)[0010]2[0]10a1Yes (16)12 18 6 4
10Write[30]10Cold-start Miss (replaces LRU 12, clean)[1111]2[0]10c1No18 6 4 30

Miss rate = 8 / 10 = 80 % (two hits: accesses 4 and 5). Final cache: a = 4 (dirty), b = 6, c = 30 (dirty), d = 18 (dirty), e = 7 (dirty), f–h empty.

The paper's own exercise (15 July 2024, Exercise 3); this table is a computed model answer, as the official solution is not in the course material. Rows 8–10 are where it is decided: the LRU victim (14, not 16 — FIFO would pick 16), the dirty bit 0 after the read fill of row 8, and "Write in memory" Yes only for the dirty victims. Every miss here is a first reference to its block, hence Cold-start by the 3C definition of the notes (p. 319). Rows 8–10 also evict from a full set while set 1 still has free lines, which the notes' wording for a conflict miss ("even if the cache is not full") could seem to fit; no official solution settles the label, so write the reason next to the type ("replaces LRU block 14, dirty") and either reading is covered.

Lesson 23 · Anatomy of a cache: the four questions and the exam cache table · question 4 of 7 · open in the lesson

Same 32-block main memory and the same sequence of memory accesses (Write 16, Write 14, Write 07, Read 14, Write 16, Read 12, Write 18, Read 06, Write 04, Write 30), but now a 2-way set associative 8-block cache, again write allocate with write-back and LRU; Cache Addresses [a … h], tags in binary. How many sets? Complete the table and compute the miss rate. Which blocks are written back to memory?

Show model answer

Sets = 8 / 2 = 4: set = address mod 4 (the two last bits), tag = address div 4 (3 bits). Set 0 = a, b; set 1 = c, d; set 2 = e, f; set 3 = g, h.

Type of memory accessMemory AddressHit/ Miss TypeCache TagSetCache AddressDirty bitWrite in memoryscratch: the set after it, LRU first
1Write[16]10Cold-start Miss[100]2[0]10a1No16
2Write[14]10Cold-start Miss[011]2[2]10e1No14
3Write[07]10Cold-start Miss[001]2[3]10g1No7
4Read[14]10Hit[011]2[2]10e1No14
5Write[16]10Hit[100]2[0]10a1No16
6Read[12]10Cold-start Miss[011]2[0]10b0No16 12
7Write[18]10Cold-start Miss[100]2[2]10f1No14 18
8Read[06]10Cold-start Miss (replaces LRU 14)[001]2[2]10e0Yes (14)18 6
9Write[04]10Cold-start Miss (replaces LRU 16)[001]2[0]10a1Yes (16)12 4
10Write[30]10Cold-start Miss (replaces LRU 18)[111]2[2]10f1Yes (18)6 30

Miss rate = 8 / 10 = 80 %. Written back: blocks 14, 16 and 18.

A variant built on the paper's numbers to check that you do not copy the 4-way table: with four sets of two ways, sets 0 and 2 fill up sooner, and one more dirty block (18) is written back. Set 1 is never used, because no address of the sequence is 1 mod 4 — which is legal; do not "move" a block into a free line of another set. Recompute both columns from the address every time: the tag now has 3 digits.

Lesson 23 · Anatomy of a cache: the four questions and the exam cache table · question 5 of 7 · open in the lesson

A byte-addressed processor with 32-bit addresses has a 64 KB 4-way set-associative data cache with 64-byte blocks. How many bits does the tag have?

Show model answer

Offset = log2(64) = 6 bits; blocks = 65 536 / 64 = 1024; sets = 1024 / 4 = 256, so index = 8 bits; tag = 32 − 8 − 6 = 18 bits. Check: 32 − log2(64 KB / 4) = 32 − 14 = 18.

The two usual slips: forgetting to divide the lines by the ways (index 10, tag 16) and taking the block size in words when the machine is byte-addressed. A common follow-up asks for the storage the cache really needs: every line keeps V, D and its tag besides the data, 1024 × (1 + 1 + 18 + 512) = 544 768 bits; the 20 480 bits of V, D and tags add about 4 % to the 64 KB of data (the LRU state of the sets comes on top).

Lesson 23 · Anatomy of a cache: the four questions and the exam cache table · question 6 of 7 · open in the lesson

Which statements about a write-back cache are correct? (MULTIPLE ANSWERS)

  • Answer 1: Every store updates main memory immediately. That is write-through; write-back updates only the cache line.
  • Answer 2: A block is written to main memory only when it is evicted while dirty. The dirty bit records that the cached copy is newer; the eviction writes it back.
  • Answer 3: It generates less memory traffic than write-through when the same block is written many times. Many stores to one block become a single block write at eviction.
  • Answer 4: Main memory always holds the most recent value. Memory is stale while a dirty copy sits in the cache.
  • Answer 5: It is usually combined with write allocate. Allocation brings the block in, so later writes to it hit in the cache.
Show model answer

Answers 2, 3 and 5. Answers 1 and 4 describe write-through.

A multiple-answer quiz in the June 2026 format. Answer 4 is the common trap: in a write-back cache it is the cache, not memory, that holds the newest copy of a dirty block.

Lesson 23 · Anatomy of a cache: the four questions and the exam cache table · question 7 of 7 · open in the lesson

True or false: with LRU replacement, the block evicted from a full set is the one that was brought into the set first. (True/False)

  • True "Brought in first" is FIFO. LRU looks at the last use, which a later hit can renew.
  • False LRU evicts the block whose most recent access is the oldest; in July 2024, access 8, that is block 14, while block 16 arrived first.
Show model answer

False. LRU evicts the least recently used block; the block that arrived first is the FIFO victim. Before access 8 of the July 2024 sequence, set 0 holds 16 (in at 1, last used 5) and 14 (in at 2, last used 4): FIFO evicts 16, LRU evicts 14.

True/False is one of the quiz forms of the papers (June 2025, Quiz 3), and a near-definition like this one is its natural target. Back the answer with a two-block counter-example; it takes one line.

Lesson 24 · Misses, penalties and the design space: the second level, the 3 C’s, from misses to seconds

Lesson 24 · Misses, penalties and the design space: the second level, the 3 C’s, from misses to seconds · question 1 of 7 · open in the lesson

PERFORMANCE EVALUATION (part 2). Evaluate the impact of the memory hierarchy on another CPU3 for which all instructions require 8 clock cycles in the following cases:

1. How much is the CPI3 when considering an ideal cache (100% hit)? CPI3_ideal_cache = …

2. How much is the CPI3 when considering a real cache with a miss rate of 50% and assuming 3 memory accesses on average for each instruction and miss penalty of 3 clock cycles? CPI3_real_cache = … How much is the impact on performance of the real cache with respect to the ideal cache (100% hit)?

3. How much is the CPI3 in the case of no cache (100% miss)? CPI3_no_cache = … How much is the impact on performance with respect to the real cache (50% hit)?

Show model answer

CPI = CPI_exec + memory accesses per instruction × miss rate × miss penalty, with CPI_exec = 8 clock cycles.

1. CPI3_ideal_cache = 8 + 3 × 0 × 3 = 8.

2. Stall cycles per instruction = 3 × 0.5 × 3 = 4.5; CPI3_real_cache = 8 + 4.5 = 12.5. Same IC and same clock, so the ratio of the CPU times is the ratio of the CPIs: 12.5 / 8 = 1.5625. With the real cache CPU3 takes 56.25% more time; the ideal cache would be 1.56 times (56.25%) faster.

3. Stall cycles per instruction = 3 × 1 × 3 = 9; CPI3_no_cache = 8 + 9 = 17. 17 / 12.5 = 1.36: without a cache CPU3 takes 36% more time than with the real cache (the real cache is 1.36 times faster); against the ideal cache, 17 / 8 = 2.125.

Exercise 3 of the 10 June 2025 paper, part 2, in its own words; part 1 is in lesson 3. Write the formula once, compute the stall term on its own line (3 × 0.5 × 3 = 4.5) and give the impact as a ratio of times, which here is the CPI ratio because IC and the clock do not change.

Lesson 24 · Misses, penalties and the design space: the second level, the 3 C’s, from misses to seconds · question 2 of 7 · open in the lesson

MEMORY HIERARCHY. Let's consider a computer with an L1 and L2 cache memory hierarchy. In 1000 memory references there are 40 misses in L1 and 20 misses in L2. Hit Time L1 = 1 clock cycle; Hit Time L2 = 10 clock cycles; Miss Penalty L2 = 200 clock cycles; 1.5 memory accesses on average for each instruction; CPI = 1.0 with an ideal cache.

1. How much are the L1 miss rate, the L2 local miss rate and the L2 global miss rate? 2. How much is the AMAT? 3. How much are the memory stall cycles per instruction and the CPI? 4. How much is the CPI without the L2 cache (L1 misses served by main memory in 200 clock cycles), and how much is the speed-up due to the L2 cache?

Show model answer

1. Miss Rate L1 = 40 / 1000 = 0.04 (4%); local Miss Rate L2 = 20 / 40 = 0.5 (50%); global Miss Rate L2 = 0.04 × 0.5 = 20 / 1000 = 0.02 (2%).

2. AMAT = 1 + 0.04 × (10 + 0.5 × 200) = 1 + 0.04 × 110 = 5.4 clock cycles.

3. Stall cycles per instruction = 1.5 × (0.04 × 10 + 0.02 × 200) = 1.5 × (0.4 + 4) = 6.6 (check: 1.5 × (5.4 − 1) = 6.6). CPI = 1.0 + 6.6 = 7.6.

4. Without L2: stall cycles per instruction = 1.5 × 0.04 × 200 = 12; CPI = 13 (AMAT = 1 + 0.04 × 200 = 9). Speed-up due to L2 = 13 / 7.6 = 1.71.

The notes' Example 7 (p. 261) with the latencies of Hennessy & Patterson's version of the same example; the no-L2 part is added here. The whole exercise is about which rate goes where: the local 50% inside the bracket of the AMAT, the global 2% in the misses per instruction that reach memory, and no L1 hit time among the stall cycles.

Lesson 24 · Misses, penalties and the design space: the second level, the 3 C’s, from misses to seconds · question 3 of 7 · open in the lesson

(Single answer.) Let us consider a computer with L1 and L2 caches with the following parameters: Processor Clock Frequency = 1 GHz; Hit Time L1 = 1 clock cycle; Hit Rate L1 = 95%; Hit Time L2 = 5 clock cycles; Hit Rate L2 = 90%; Miss Penalty L2 = 15 clock cycles. How much is the Global Miss Rate for Last Level Cache? Motivate your answer.

  • Answer 1: 5% That is the L1 miss rate, 1 − 0.95: the share that reaches L2, not the share that reaches memory.
  • Answer 2: 0.5% L2 is the last level: 0.05 × 0.10 = 0.005. Global rate = L1 miss rate × local L2 miss rate.
  • Answer 3: 10% That is the local miss rate of L2, measured against the 5% of accesses that reach it.
  • Answer 4: 7.5% The average of 5% and 10%: miss rates along a path multiply, they are not averaged.
Show model answer

Answer 2. Miss Rate L1 = 1 − 0.95 = 0.05. The L2 hit rate of 90% is local, so the L2 misses 0.10 of the accesses that reach it. Global miss rate of the last-level cache (L2) = 0.05 × 0.10 = 0.005 = 0.5%: one access in 200 goes to main memory. The clock and the hit times are not needed.

Question 3 of the 8 January 2026 paper as the notes reproduce it (p. 503); the notes' answer is right. The motivation needs one fact: the 90% is a local hit rate, so the L2 misses 10% of the 5% that reach it.

Lesson 24 · Misses, penalties and the design space: the second level, the 3 C’s, from misses to seconds · question 4 of 7 · open in the lesson

With the parameters of the previous question, how much is the AMAT, in clock cycles?

Show model answer

AMAT = Hit Time L1 + Miss Rate L1 × (Hit Time L2 + Miss Rate L2 × Miss Penalty L2) = 1 + 0.05 × (5 + 0.10 × 15) = 1 + 0.05 × 6.5 = 1.325 clock cycles (1.325 ns at 1 GHz).

Not asked in the paper, but the same numbers make it the natural next question. The expanded form gives the same: 1 + 0.25 + 0.075. The slip to avoid is the global rate inside the bracket, 1 + 0.05 × (5 + 0.005 × 15) = 1.254.

Lesson 24 · Misses, penalties and the design space: the second level, the 3 C’s, from misses to seconds · question 5 of 7 · open in the lesson

(Multiple answers.) Which of the following cache improvements are effective in reducing the miss penalty?

  • Answer 1: Adopting higher associativity in designing the cache to reducing the impact of collisions when the correct block must be loaded in the cache. It removes conflict misses: it lowers the miss rate, while each miss still costs the same.
  • Answer 2: Avoiding address translation during indexing of the cache to minimize the management time of miss penalties. Indexing with untranslated bits lets the TLB and the cache work in parallel on every access: a hit-time technique, whatever the wording of the option says.
  • Answer 3: Combining a small and fast level-1 cache with a slower but larger level-2 cache to capture many accesses that would go to the main memory. An L1 miss now costs Hit Time L2 + Miss Rate L2 × Miss Penalty L2 instead of a trip to memory.
  • Answer 4: Giving priority to read misses over writes, exploiting techniques to serve the reads before the writes have been completed. A read miss no longer waits for buffered writes, or a dirty victim's write-back, to reach memory first: the processor waits less on that miss.
Show model answer

Answers 3 and 4. Answer 1 reduces the miss rate (fewer conflict misses). Answer 2 reduces the hit time: the cache is indexed while the TLB translates. Answer 3 makes an L1 miss cost an L2 access instead of a memory access. Answer 4 serves a read miss before the pending writes complete (after checking the write buffer for the same address), so the read waits less.

Question 4 of the 8 January 2026 paper as the notes reproduce it (pp. 503–504). The notes' solution marks 2 and 3: see the red pen in the last section. The options copy, almost word for word, the titles of Hennessy & Patterson's basic cache optimizations, where each title also names the term it reduces.

Lesson 24 · Misses, penalties and the design space: the second level, the 3 C’s, from misses to seconds · question 6 of 7 · open in the lesson

(Multiple answers.) Which of the following statements about the classification of cache misses (the 3 C's model) are correct?

  • Answer 1: Compulsory misses occur even in a cache of infinite size. They are the first references to each block: no cache holds a block it has never fetched.
  • Answer 2: A fully associative cache has no conflict misses. Conflict misses are defined against a fully associative cache of the same size: its own count is zero.
  • Answer 3: Increasing the associativity at the same cache size reduces the capacity misses. Capacity misses are those of a fully associative cache of that size: more ways cannot remove them, only a bigger cache can.
  • Answer 4: A miss that replaces a valid block in a full set is a conflict miss. The first reference to a block is a cold-start miss whatever it evicts; a conflict miss is a re-reference that a fully associative cache would have hit.
  • Answer 5: Larger blocks can reduce the compulsory misses. One fetch brings the neighbours, so fewer first touches miss (p. 319), at the price of a larger miss penalty.
Show model answer

Answers 1, 2 and 5.

Built in the paper's multiple-answer form. The definitions are Hennessy & Patterson's; the remedies are the notes' Table 28 (p. 320). Answer 4 is the trap of the exam's cache table, where every first touch is a Cold-start Miss.

Lesson 24 · Misses, penalties and the design space: the second level, the 3 C’s, from misses to seconds · question 7 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following concepts and techniques of the memory hierarchy: 1. Second-level cache (L2); 2. Local and global miss rate; 3. AMAT of a two-level cache hierarchy; 4. Memory stall cycles and CPU time; 5. Compulsory misses; 6. Capacity misses; 7. Conflict misses; 8. The three strategies to improve cache performance.

Show model answer

1. A larger, slower cache between L1 and main memory (hundreds of KB to MBs, SRAM, usually unified, on chip). It catches L1 misses before they reach DRAM, so the L1 miss penalty becomes Hit Time L2 + Miss Rate L2 × Miss Penalty L2 instead of the memory latency. Benefit: L1 stays small and fast while its misses become cheap (Example 8: AMAT 6 → 2.5 cycles). It does not change the L1 miss rate; it pays off only if its hit time plus its own misses cost less than the trip to memory.

2. Local miss rate = misses of a level / accesses to that level; global miss rate = misses of a level / all CPU accesses; for L2, local = L2 misses / L1 misses and global = Miss Rate L1 × local Miss Rate L2. Example: 1000 accesses, 40 L1 misses, 20 L2 misses → 4%, 50% local, 2% global. The global rate measures the accesses that reach memory and is comparable across hierarchies; the local L2 rate is high because L1 has already served the easy accesses.

3. Nest the one-level formula: AMAT = Hit Time L1 + Miss Rate L1 × Miss Penalty L1, with Miss Penalty L1 = Hit Time L2 + Miss Rate L2 × Miss Penalty L2 (local rate). Expanded: every access pays Hit Time L1, the L1 misses pay Hit Time L2, the misses in both pay Miss Penalty L2. Example: 1 + 0.04 × (10 + 0.5 × 200) = 5.4 cycles, against 9 without L2.

4. CPU time = IC × (CPI_exec + memory stall cycles per instruction) × T_CLK; stall cycles per instruction = memory accesses per instruction × miss rate × miss penalty (misses per instruction × penalty). With L1 and L2: MAPI × (Miss Rate L1 × Hit Time L2 + Miss Rate L1 × Miss Rate L2 × Miss Penalty L2) = MAPI × (AMAT − Hit Time L1). Example: CPU3, 8 + 3 × 0.5 × 3 = 12.5. Benefit: it predicts the effect of the memory system on execution time, and shows that a faster core loses a larger share of its time to the same misses.

5. The first access to a block (cold start); they occur even in an infinite cache. Reduced by larger blocks (one miss brings the neighbours) and by prefetching; larger blocks raise the miss penalty.

6. The working set does not fit, so blocks are evicted and needed again: the misses of a fully associative cache of the same size, minus the compulsory ones. Reduced by a larger cache, at the cost of hit time, area and power.

7. Blocks that map to the same set evict each other although other lines are free: the misses of the real cache minus those of a fully associative cache of the same size. Reduced by higher associativity (more comparators, longer hit time) or a victim cache. Example: blocks 12 and 20 in a direct-mapped cache of 8 blocks, 100% miss rate, against 33% fully associative.

8. From AMAT = Hit Time + Miss Rate × Miss Penalty: reduce the miss rate (larger caches and blocks, higher associativity, prefetching, compiler optimizations), reduce the miss penalty (multilevel caches, priority to read misses over writes, early restart and critical word first, non-blocking caches), reduce the hit time (small and simple L1, avoiding address translation with virtually indexed, physically tagged caches, pipelined writes). Most techniques move two terms (bigger cache: miss rate down, hit time up; bigger block: miss rate down, miss penalty up), so each choice is a trade-off judged on AMAT.

The 2026 paper's form: eight sub-points, about five lines each. A strong sub-point has a definition, the mechanism or formula, a number and the benefit with its cost. Sub-point 2 needs both denominators named; sub-point 4 needs the multiplication by the memory accesses per instruction; sub-points 5–7 are strongest with the comparison caches of the definitions.

Lesson 25 · Fewer misses: size, blocks, ways, victims, prediction, prefetching and the compiler

Lesson 25 · Fewer misses: size, blocks, ways, victims, prediction, prefetching and the compiler · question 1 of 7 · open in the lesson

(In the form of the June 2026 Question 1.) Explain the main concepts and benefits of each one of the following cache optimization techniques: 1. Larger block size; 2. Higher associativity; 3. Victim cache; 4. Way prediction; 5. Pseudo-associativity; 6. Hardware prefetching with stream buffers; 7. Software (compiler-controlled) prefetching; 8. Loop interchange and loop blocking.

Show model answer

1. Larger block size: a miss brings in the neighbouring words too, exploiting spatial locality, so compulsory misses decrease. For a fixed cache size there are fewer blocks, so beyond an optimum conflict and capacity misses grow (U-shaped miss rate), and the miss penalty grows with the block (latency + transfer). The AMAT-optimal block is at or below the miss-rate-optimal one; common sizes are 16–64 bytes.

2. Higher associativity: a block can be placed in any of the n ways of its set, so blocks with the same index can coexist: conflict misses decrease, compulsory and capacity misses do not change. Rules of thumb: a direct-mapped cache of size N misses about as often as a 2-way cache of size N/2; 8-way is practically fully associative. Cost: the way-select multiplexer must wait for the n tag comparisons, so the hit time (clock cycle) and the power grow; for large caches AMAT can increase.

3. Victim cache: a small (4–16 entries) fully associative buffer between the cache and the next level, holding the blocks recently evicted. On a miss it is checked; on a hit there the block is swapped back into the cache. It removes many conflict misses of a direct-mapped cache (a few blocks that keep evicting each other) without changing the hit time of the main cache; low cost. Seen from the main cache, it makes those misses cheap (miss-penalty view).

4. Way prediction: a small table indexed by the set index stores, for each set, the way that hit last (log2 n bits). Only the predicted way is read and its data is sent out at once, as in a direct-mapped cache; one tag comparison confirms it. On a mismatch the other ways are checked (+1–2 cycles); the table is updated on every wrong prediction, misses included. Benefit: hit time and energy close to direct-mapped with the miss rate of a set-associative cache (accuracy 80–95 %). It does not reduce the miss rate.

5. Pseudo-associativity: a direct-mapped cache where each block has a second possible line (e.g. the index with its MSB flipped). Check the primary line (1-cycle hit), then the secondary (slow hit, +1 cycle), then miss. Two blocks with the same index can now both stay, one in each line (the pair of lines acts as one 2-way set), so it removes many conflict misses with little hardware; cost: two different hit times, harder to pipeline; blocks are swapped so that the most recently used one is in the primary line.

6. Hardware prefetching: on a miss on block X the hardware fetches X into the cache and X+1, X+2, … into a stream buffer next to it (instruction stream buffer for sequential code, data stream buffers for sequential or strided accesses). If the next access finds the block in the buffer, it is moved into the cache and the following one is prefetched. It removes compulsory (and some capacity) misses by overlapping memory accesses with execution; the separate buffer avoids polluting the cache with wrong guesses. Cost: memory bandwidth, useless prefetches.

7. Software prefetching: the compiler inserts prefetch instructions ahead of the use (e.g. prefetch A[i+8] while using A[i]), at a distance of about miss latency / cycles per iteration. Cache prefetch (into the cache, not a register) is the common form; the prefetch must be non-faulting and the cache non-blocking, so that execution continues while the block arrives. Benefits: removes compulsory/capacity misses of predictable patterns the hardware may not detect, tunable by profiling. Costs: extra instructions (issue slots), bandwidth; too close is useless, too far may be evicted.

8. Loop interchange swaps nested loops so that the inner loop walks memory sequentially (row-major C arrays: inner loop on the last index), so each block fetched serves all its words before eviction (e.g. 16 times fewer misses with 4-byte words and 64-byte blocks). Loop blocking (tiling) splits a computation that reuses data, such as matrix multiplication, into B × B tiles that fit in the cache, so that each tile is reused before eviction: words moved go from 2N³ + N² to 2N³/B + N². Both reduce capacity (and conflict) misses at no hardware cost; they must respect the data dependences.

A complete sub-point has three parts: the mechanism in one or two sentences, the kind of miss (or the term of AMAT) it attacks, and its cost. Two classic traps: crediting way prediction with fewer misses, and saying that larger blocks reduce capacity misses. Short of time, write the AMAT term and the miss category first — they carry the answer.

Lesson 25 · Fewer misses: size, blocks, ways, victims, prediction, prefetching and the compiler · question 2 of 7 · open in the lesson

A 64 KB cache has a hit time of 1 clock cycle. Its measured miss rate is 2.04 % with 16-byte blocks, 1.35 % with 32-byte blocks, 1.06 % with 64-byte blocks, 1.02 % with 128-byte blocks and 1.15 % with 256-byte blocks. On a miss, main memory delivers the first 16 bytes after 80 clock cycles and 16 more bytes every 2 clock cycles. Which block size (in bytes) minimizes the average memory access time?

Show model answer

Miss penalty = 80 + 2 × (B/16) clock cycles; AMAT = 1 + Miss rate × Miss penalty.

Block sizeMiss rateMiss penaltyAMAT
16 B2.04 %821 + 0.0204 × 82 = 2.67
32 B1.35 %841 + 0.0135 × 84 = 2.13
64 B1.06 %881 + 0.0106 × 88 = 1.93
128 B1.02 %961 + 0.0102 × 96 = 1.98
256 B1.15 %1121 + 0.0115 × 112 = 2.29

The minimum AMAT is 1.93 clock cycles with 64-byte blocks, although the lowest miss rate is at 128 bytes: from 64 to 128 bytes the miss rate drops only from 1.06 % to 1.02 % while the miss penalty grows from 88 to 96 cycles.

The tempting wrong answer is 128, the miss-rate optimum. Write the penalty formula first and the table second: a slip then stays in one row, where it is easy to spot.

Lesson 25 · Fewer misses: size, blocks, ways, victims, prediction, prefetching and the compiler · question 3 of 7 · open in the lesson

Let's consider a 32-block main memory with a direct-mapped 8-block cache based on a write allocate with write-back protocol. The addresses are expressed as: Memory Addresses: [0, 1, 2, … 31]10; Cache Addresses: [a, b, c, d, e, f, g, h] and Cache Tags are expressed as binary numbers. At cold start the cache is empty, then there is the following sequence of memory accesses: Read [03]10, Read [11]10, Write [03]10, Read [11]10, Write [05]10, Read [03]10, Read [13]10, Read [05]10.

(a) Please complete the table (Type of memory access, Memory Address, Hit/Miss Type, Cache Tag, Set, Cache Address, Dirty bit, Write in memory). How much is the miss rate? (b) Repeat with a 2-way set associative 8-block cache with LRU. (c) Which misses of (a) disappear in (b), and why? (d) How many accesses of (a) must still fetch the block from main memory if a 2-entry fully associative victim cache is added to the direct-mapped cache?

Show model answer

(a) Direct-mapped: 8 sets, Set = address mod 8, Tag = address div 8 (2 bits); set k is cache address a + k (set 3 = d, set 5 = f).

#Type of memory accessMemory AddressHit/Miss TypeCache TagSetCache AddressDirty bitWrite in memory
1Read[03]10Cold-start Miss[00]2[3]10d0No
2Read[11]10Cold-start Miss[01]2[3]10d0No
3Write[03]10Conflict Miss[00]2[3]10d1No
4Read[11]10Conflict Miss[01]2[3]10d0Yes (write-back of block 3)
5Write[05]10Cold-start Miss[00]2[5]10f1No
6Read[03]10Conflict Miss[00]2[3]10d0No
7Read[13]10Cold-start Miss[01]2[5]10f0Yes (write-back of block 5)
8Read[05]10Conflict Miss[00]2[5]10f0No

Miss rate = 8/8 = 100 %.

(b) 2-way: 4 sets, Set = address mod 4, Tag = address div 4 (3 bits); set 0 = a, b; set 1 = c, d; set 2 = e, f; set 3 = g, h.

#Type of memory accessMemory AddressHit/Miss TypeCache TagSetCache AddressDirty bitWrite in memory
1Read[03]10Cold-start Miss[000]2[3]10g0No
2Read[11]10Cold-start Miss[010]2[3]10h0No
3Write[03]10Hit[000]2[3]10g1No
4Read[11]10Hit[010]2[3]10h0No
5Write[05]10Cold-start Miss[001]2[1]10c1No
6Read[03]10Hit[000]2[3]10g1No
7Read[13]10Cold-start Miss[011]2[1]10d0No
8Read[05]10Hit[001]2[1]10c1No

Miss rate = 4/8 = 50 %.

(c) The four conflict misses of (a), rows 3, 4, 6 and 8, become hits. Blocks 3 and 11 share a set in both caches (and so do 5 and 13), but the 2-way set holds both, while the direct-mapped line holds one at a time. The four cold-start misses remain: associativity does not remove compulsory misses. The two write-backs of (a) disappear too, because no dirty block is evicted.

(d) 4: only the cold-start misses (accesses 1, 2, 5, 7). Each conflict miss of (a) finds its block in the victim cache, where the previous access to the same line put it (access 6 finds block 3, evicted by access 4), and swaps it back into the line.

Label the misses as the July 2024 paper does ("Cold-start Miss" for a first reference) and say "Conflict Miss" when a block comes back after being evicted although the cache had free room: in a fully associative cache of 8 blocks these four accesses would hit. Dirty bits and write-backs are where most slips happen: memory is written only when a dirty block is evicted, never on the write itself.

Lesson 25 · Fewer misses: size, blocks, ways, victims, prediction, prefetching and the compiler · question 4 of 7 · open in the lesson

A 32 KB 8-way set associative cache with 64-byte blocks uses way prediction. How many bits does the way predictor table need?

Show model answer

Number of sets = 32 768 / (64 × 8) = 64. Each entry names one of 8 ways: log2 8 = 3 bits. Table size = 64 × 3 = 192 bits (24 bytes).

The table has one entry per set, not per block: the tempting wrong answers are 512 × 3 = 1536 (one entry per block) and 64 × 8 = 512 (one bit per way).

Lesson 25 · Fewer misses: size, blocks, ways, victims, prediction, prefetching and the compiler · question 5 of 7 · open in the lesson

(MULTIPLE ANSWERS) Which of the following techniques reduce conflict misses?

  • Answer 1: Increasing the associativity of the cache Blocks with the same index get several places in the set.
  • Answer 2: Adding a small fully associative victim cache The block evicted by a collision waits in the victim cache and is swapped back.
  • Answer 3: Pseudo-associativity A direct-mapped cache gets a second line for each index, so two colliding blocks can both stay.
  • Answer 4: Increasing the block size for the same cache size It reduces compulsory misses, and with fewer blocks in the cache it increases conflict misses.
  • Answer 5: Way prediction It never changes what the cache holds; it reduces the hit time and the power of hits.
Show model answer

Answers 1, 2 and 3.

The quizzes of the papers build their wrong options from neighbouring techniques; the January 2026 paper, solved in the notes' Exams chapter, asked the same question about the miss penalty (lesson 24). Sort each technique by the term of AMAT and the C it attacks — the table at the end of section 6.

Lesson 25 · Fewer misses: size, blocks, ways, victims, prediction, prefetching and the compiler · question 6 of 7 · open in the lesson

(SINGLE ANSWER) A 4-way set associative L1 cache adds a way predictor. Which statement is correct?

  • Answer 1: It reduces the miss rate, because the most likely way is checked first The order of the checks does not change what is in the cache: the same accesses miss.
  • Answer 2: It reduces the hit time and the energy of most hits, while the miss rate is unchanged Right: a correctly predicted hit reads one way and does not wait for the tag comparison; a wrong guess costs an extra cycle.
  • Answer 3: It removes the tag comparison from the access The predicted way's tag is still compared — to confirm the hit, in parallel with sending the data.
  • Answer 4: The predictor is updated only on hits After a miss the entry points to the way that received the new block (Example 11, access 3).
Show model answer

Answer 2.

Answer 4 is the sentence printed on p. 331 of the notes, which their own Example 11 contradicts one page later: after a miss the entry is rewritten too.

Lesson 25 · Fewer misses: size, blocks, ways, victims, prediction, prefetching and the compiler · question 7 of 7 · open in the lesson

(True/False, motivate your answer.) "Loop interchange, loop fusion and loop blocking reduce the compulsory misses of a program."

  • True They reorder the accesses but touch the same blocks, so every block still has its first, compulsory miss.
  • False Right: they remove repeat misses to blocks evicted and fetched again — capacity and conflict misses.
Show model answer

False. A compulsory miss is the first access to a block. These transformations change only the order of the accesses (and the loop structure), not the set of blocks the program touches, so the number of first accesses is unchanged. They reduce capacity (and conflict) misses: a block is used completely (interchange) or reused (fusion, blocking) before it is evicted.

The notes' table on p. 341 says the opposite. In the papers a motivation earns its own extra point: it must say what a compulsory miss is and why reordering the accesses cannot change their number.

Lesson 26 · Cheaper misses: reads first, the critical word, caches that do not block, the second level

Lesson 26 · Cheaper misses: reads first, the critical word, caches that do not block, the second level · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used to reduce the cache miss penalty: 1. Giving priority to read misses over writes; 2. Sub-block placement; 3. Early restart; 4. Critical word first; 5. Non-blocking caches (hit under miss, miss under miss); 6. Second-level caches; 7. Inclusive and exclusive multilevel caches; 8. Merging write buffer. (Five lines each.)

Show model answer

1. A read miss soon stalls the processor, because the following instructions need the data; a write can wait in the write buffer. So when a read miss competes with pending writes, the read is served first. In a write-through cache the read miss first compares its address with those in the write buffer: on a match it takes the data from the buffer, because memory still holds the old value (a RAW hazard through memory); with no match it goes to memory ahead of the buffered writes. In a write-back cache a dirty victim is copied into the write buffer, the new block is fetched at once and the victim is written back afterwards. Benefit: the read-miss penalty no longer includes writes nobody waits for. Cost: comparators on the buffer; a full buffer still stalls.

2. Each block is divided into sub-blocks, each with its own valid bit, under a single tag. On a miss only the requested sub-block is fetched; the others stay invalid until needed, and a hit requires both the tag match and the sub-block's valid bit. Benefit: the tag storage of a large block with the transfer time of a small one, so a lower miss penalty and less bandwidth, useful with large blocks or weak spatial locality. Cost: extra valid bits and control; less spatial locality exploited, so neighbouring words may miss later.

3. The block is fetched in normal order, but the requested word is sent to the processor as soon as it arrives and the processor resumes while the rest of the block is filled in the background. With a latency L before the first word, one word per cycle, n words per block and the requested word at position k (from 0), the stall falls from L + n to L + k + 1 cycles. Benefit: no change to the memory; the gain is larger when the word is early in the block.

4. Critical word first (wrapped fetch) asks the memory for the requested word first and then for the rest of the block, wrapping around (W2, W3, W0, W1). The stall is L + 1 cycles whatever the position of the word. Benefit: the largest gain when the word is late in the block. Cost: wrap-around fetch logic and a memory that supports it. Both 3 and 4 pay mainly with large blocks, where the transfer is a large part of the penalty, and both gain less when the processor soon needs another word of the block.

5. A blocking cache stalls the processor on a miss even if the next accesses would hit. A non-blocking (lockup-free) cache keeps serving accesses while misses are outstanding, each tracked in a Miss Status Holding Register (MSHR). Hit under miss: hits proceed while one miss is pending. Miss under miss: several misses are serviced in parallel (memory-level parallelism), with several MSHRs and a memory that accepts several requests. Benefit: the miss penalty is overlapped with useful work and with other misses, so the effective miss penalty drops; each miss itself is not shorter. It needs a processor with independent work, such as an out-of-order core. Cost: MSHRs, complexity, memory ordering.

6. An L2, larger and slower than L1 but much faster than main memory, catches most L1 misses: AMAT = L1 Hit Time + L1 Miss Rate × (L2 Hit Time + L2 Miss Rate × L2 Miss Penalty), with the local L2 miss rate; the bracket is the new L1 miss penalty. Example: 0.05 × (10 + 0.10 × 100) adds 1 cycle per access instead of 0.05 × 100 = 5. Design: much larger (hundreds of KB to MBs), more associative (8 to 16 ways), usually write-back, its slower hit time acceptable because it is not on the processor's critical cycle. Cost: every L1 miss pays the L2 lookup; area and power.

7. Inclusive: L2 holds a copy of every block in L1, so a coherence check in a multiprocessor can rely on L2 alone; the price is duplicated capacity. Exclusive: a block is either in L1 or in L2, never in both, so the total capacity is the sum of the two. Non-inclusive non-exclusive (NINE): no strict relation. In multicores a private L2 per core reduces contention and a shared L3 helps sharing and coherence.

8. In a write-through cache every store goes to memory through the write buffer; without merging, stores to adjacent addresses each become a memory transaction. A merging write buffer keeps block-sized entries with the aligned block address, a data field and a byte-valid mask; a store to a block already in the buffer is written into its entry instead of taking a new one. Benefit: fewer and larger transactions, less bus contention, so read misses wait less for the bus and the buffer fills less often. Cost: matching logic and masks; a partial entry needs a byte-enabled write or a read-merge-write; a full buffer still stalls.

The form is the June 2026 question: eight sub-points, about five lines each. Give three things in each: the mechanism, the term of AMAT it attacks, and its cost. Sub-points 3 and 4 are best answered with the three penalties; sub-point 6 with the formula from the A4 sheet; sub-point 5 with the sentence "it overlaps the miss, it does not shorten it".

Lesson 26 · Cheaper misses: reads first, the critical word, caches that do not block, the second level · question 2 of 7 · open in the lesson

(MULTIPLE ANSWERS) Which of the following cache improvements are effective in reducing the miss penalty?

  • Answer 1: Adopting higher associativity in designing the cache to reducing the impact of collisions when the correct block must be loaded in the cache. Higher associativity removes conflict misses: it lowers the miss rate. A miss that still happens costs the same.
  • Answer 2: Avoiding address translation during indexing of the cache to minimize the management time of miss penalties. This takes the TLB off the path of every hit: it lowers the hit time. The notes' solution ticks it; it is wrong.
  • Answer 3: Combining a small and fast level-1 cache with a slower but larger level-2 cache to capture many accesses that would go to the main memory. An L1 miss is served by L2 most of the time: the L1 miss penalty becomes L2 Hit Time + L2 Miss Rate × L2 Miss Penalty.
  • Answer 4: Giving priority to read misses over writes, exploiting techniques to serve the reads before the writes have been completed. The read miss no longer waits for buffered writes or for a dirty write-back: each read miss is serviced sooner. The notes' solution rejects it; it is correct.
Show model answer

Answers 3 and 4. Answer 1 reduces the miss rate (conflict misses); Answer 2 reduces the hit time; Answer 3 replaces most trips to main memory with an L2 access; Answer 4 lets a read miss start its fetch without waiting for pending writes.

This is the quiz of the 8 January 2026 paper as the notes transcribe it (pp. 503–504), with the options verbatim; the notes' worked solution picks 2 and 3 (red pen in section 6). If the paper asks you to motivate the answer, one line per option with the term of AMAT is enough.

Lesson 26 · Cheaper misses: reads first, the critical word, caches that do not block, the second level · question 3 of 7 · open in the lesson

(SINGLE ANSWER) A cache has blocks of 8 words. On a miss, main memory needs an access latency of 30 clock cycles before the transfer starts, then transfers one word per clock cycle. The CPU requests word 5 (words are numbered from 0). How many stall cycles does the CPU pay with (i) a full-block fetch, (ii) early restart, (iii) critical word first?

  • Answer 1: 38, 36, 31 30 + 8 = 38; word 5 is the sixth to arrive, 30 + 5 + 1 = 36; sent first, 30 + 1 = 31.
  • Answer 2: 37, 35, 30 This counts the first word as arriving at the end of the latency, which the text excludes: the transfer starts after the 30 cycles.
  • Answer 3: 38, 35, 31 Early restart waits for words 0 to 5, six words, not five: 30 + 6 = 36.
  • Answer 4: 38, 36, 36 Critical word first sends word 5 first, so its position no longer matters.
Show model answer

Answer 1. Full block: L + n = 30 + 8 = 38. Early restart: L + k + 1 = 30 + 5 + 1 = 36. Critical word first: L + 1 = 31.

The whole question is in the off-by-one. Read how the text defines the latency, write \(t(p) = L + p + 1\) for the word sent \(p\)-th, and the three numbers follow.

Lesson 26 · Cheaper misses: reads first, the critical word, caches that do not block, the second level · question 4 of 7 · open in the lesson

(True/False) In a non-blocking cache with miss-under-miss support, each individual miss is serviced in fewer clock cycles than in a blocking cache.

  • True Main memory is just as slow: every miss still costs the full miss penalty. What changes is that the misses overlap each other and the hits.
  • False Right: the cache overlaps misses, it does not shorten them. The effective penalty seen by the processor drops; the penalty of each miss does not.
Show model answer

False. A non-blocking cache keeps serving hits and starts further misses while one is outstanding (tracked in MSHRs). Each miss takes as long as before; the processor simply does other work, so the stall it sees, the effective miss penalty, is smaller.

The distinction between the miss penalty and the effective miss penalty is the point. The widget of section 4 shows it: the orange bars keep their length in every mode.

Lesson 26 · Cheaper misses: reads first, the critical word, caches that do not block, the second level · question 5 of 7 · open in the lesson

A cache has blocks of 16 words. On a miss, main memory needs an access latency of 40 clock cycles before the transfer starts, then transfers one word per clock cycle, in order from word 0. With early restart, how many clock cycles does the CPU stall when it requests word 9 (words numbered from 0)?

Show model answer
\[ L + k + 1 = 40 + 9 + 1 = 50 \text{ clock cycles} \]

For comparison: full-block fetch 40 + 16 = 56, critical word first 40 + 1 = 41.

Early restart does not change the order: words 0 to 9 must arrive, ten transfer cycles after the 40 of latency.

Lesson 26 · Cheaper misses: reads first, the critical word, caches that do not block, the second level · question 6 of 7 · open in the lesson

Let us consider a computer with L1 and L2 caches with the following parameters: Hit Time L1 = 1 clock cycle; Hit Rate L1 = 95%; Hit Time L2 = 10 clock cycles; Hit Rate L2 = 90%; Miss Penalty L2 = 100 clock cycles.

1. How much is the miss penalty of L1? 2. How much is the AMAT? 3. How much is the Global Miss Rate for the Last Level Cache? 4. How much would the AMAT be without L2, if the L1 misses were served by main memory in 100 clock cycles? 5. How much is the speed-up of the average memory access due to L2?

Show model answer

Miss Rate L1 = 1 − 0.95 = 0.05; Miss Rate L2 (local) = 1 − 0.90 = 0.10.

1. The L1 miss penalty, in clock cycles:

\[ MP_{L1} = 10 + 0.10 \times 100 = 20 \]

2. The AMAT, in clock cycles:

\[ \text{AMAT} = 1 + 0.05 \times 20 = 2 \]

3. The global miss rate of L2, the last-level cache:

\[ 0.05 \times 0.10 = 0.005 = 0.5\% \]

4. Without L2, in clock cycles:

\[ \text{AMAT} = 1 + 0.05 \times 100 = 6 \]

5. Speed-up of the average access: 6 / 2 = 3.

These are the notes' Example 16 (p. 351) with an L1 hit time of 1 cycle, written in the form of the January 2026 quiz. The trap is item 1: the notes call the 10 cycles the L1 miss penalty, but they are the L2 hit time (red pen in section 5). Turn every hit rate into a miss rate before you substitute.

Lesson 26 · Cheaper misses: reads first, the critical word, caches that do not block, the second level · question 7 of 7 · open in the lesson

A write-through cache has a merging write buffer of 4 entries; each entry holds a 32-byte block with a byte-valid mask. With R1 = 0x1000 and R2 = 0x2000, the CPU executes the following stores (8 bytes each) before the bus becomes free:

SD  F2, 0(R1)
SD  F4, 8(R1)
SD  F6, 0(R2)
SD  F8, 16(R1)
SD  F10, 24(R1)
SD  F12, 8(R2)

Complete a table with the columns Store | Address | Block base | Action | Valid bytes of the entry after the store. How many write transactions reach memory with and without merging, and of which kind?

Show model answer
StoreAddressBlock baseActionValid bytes after
SD F2, 0(R1)0x10000x1000allocate E0E0: 0–7
SD F4, 8(R1)0x10080x1000merge into E0E0: 0–15
SD F6, 0(R2)0x20000x2000allocate E1E1: 0–7
SD F8, 16(R1)0x10100x1000merge into E0E0: 0–23
SD F10, 24(R1)0x10180x1000merge into E0E0: 0–31 (full)
SD F12, 8(R2)0x20080x2000merge into E1E1: 0–15 (partial)

With merging: 2 entries and 2 transactions, one full 32-byte write for E0 and one partial 16-byte write for E1 (with byte enables, or a read-merge-write if the bus has none). Without merging: 6 transactions, one per store; the 4-entry buffer is full after the fourth store, so the fifth and the sixth store stall the CPU until an entry has been written to memory.

The block base is the address with its 5 low bits cleared (32-byte blocks). Three points to get right: the alignment, the merge into an existing entry even when another block came in between (the third store), and the difference between a full and a partial flush. The widget of section 2 replays this stream ("two blocks, interleaved").

Lesson 27 · Virtual memory in one lesson, and VIPT: start the cache before the TLB answers

Lesson 27 · Virtual memory in one lesson, and VIPT: start the cache before the TLB answers · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used in the memory hierarchy of modern processors: 1. Paged virtual memory; 2. Per-process page tables; 3. Translation lookaside buffer (TLB); 4. Handling of TLB misses and page faults; 5. Virtually indexed, physically tagged (VIPT) L1 caches; 6. Indexing the cache with page-offset bits only; 7. Higher associativity in a VIPT L1 cache; 8. Physically indexed, physically tagged (PIPT) L2 and L3 caches.

Show model answer

1. The virtual and the physical address spaces are divided into pages of one fixed size (for example 4 KB). Each process sees a large, private, contiguous virtual space; the OS maps its pages onto physical frames anywhere in RAM. A virtual address is VPN | page offset; translation replaces the VPN with the PFN and leaves the offset unchanged. Benefits: programs larger than RAM (main memory acts as a cache for the disk), protection and isolation between processes, relocation, sharing of frames; fixed-size pages avoid external fragmentation. Cost: a translation on every access.

2. Each process has a page table in memory, indexed by the VPN; each entry holds the PFN, a valid bit, a dirty bit, a use bit and protection bits. The same virtual address in two processes maps to different frames (isolation), two VPNs may point to one frame (sharing), and the hardware enforces the permissions. Because a page fault costs millions of cycles, placement is fully associative (any frame), replacement approximates LRU with the use bit, and the write policy is always write-back with the dirty bit. Cost: memory for the tables, hence multi-level tables.

3. A small, fast, fully or highly associative cache of recent translations: tag = VPN, data = PFN and the flags. It is looked up on every access; on a hit the physical address is available in about one cycle, with the protection check. Benefit: without it every access would need an extra memory access to read the page table. Cost: it must stay tiny (tens of entries) to answer within the cycle.

4. On a TLB miss the page table is walked in memory, by a hardware walker or a software handler, in tens of cycles; if the entry is valid it is inserted into the TLB and the access completes, with no OS involvement for a hardware walker. If the entry is invalid, the page is not in RAM: a page-fault exception transfers control to the OS, which chooses a frame (writing back a dirty victim), reads the page from the disk, updates the entry and restarts the faulting instruction; this costs millions of cycles and requires precise exceptions. A TLB miss is not a page fault.

5. The cache index is taken from the virtual address and the tag from the physical address. The set is read while the TLB translates the VPN; the PFN is then compared with the tags of the set. Benefit: the TLB latency leaves the hit time, max(TLB, set read) + compare instead of TLB + cache, for example 1 cycle instead of 2 (notes, p. 360); since most accesses are hits, the AMAT drops. The TLB is still read on every access, for the tag and the permissions. Cost: the size restriction of point 7.

6. Translation never changes the page offset, so index and block-offset bits taken from it are the same in the virtual and the physical address and can be used before the TLB answers (the page offset trick). It also solves synonyms, two virtual addresses mapped to one physical address (shared memory, mapped files): all aliases select the same set and, with physical tags, match the same line, so only one copy exists and no stale value can be read. A VIVT cache could keep two copies with different virtual tags.

7. All index bits must lie in the page offset: index bits + block-offset bits ≤ page-offset bits, that is cache size / associativity ≤ page size. With 4 KB pages and 64-byte blocks a 32 KB 4-way cache (8 KB per way, 7 index bits) takes one index bit from the VPN; 8 ways make it safe (4 KB per way), and 48 KB needs 12 ways. A larger VIPT L1 therefore needs more ways. Cost: more comparators, a wider way multiplexer, more energy and a longer hit time, which way prediction mitigates. Alternatives: page colouring, hardware alias detection, larger pages.

8. L2 and L3 use the physical address for both index and tag. They are accessed only after an L1 miss, when the TLB has already translated the address, so translation adds nothing to their access and they have no synonym problem and no page-size limit: they can be large (MBs) and highly associative. Their longer hit time is acceptable because it is paid only on L1 misses.

The form is the June 2026 question: eight sub-points, about five lines each. For each technique the examiner looks for the mechanism, what it buys and what it costs. Sub-points 4 and 7 carry the usual traps: a TLB miss is not a page fault, and the law limits one way, not the whole cache.

Lesson 27 · Virtual memory in one lesson, and VIPT: start the cache before the TLB answers · question 2 of 7 · open in the lesson

A processor has 32-bit virtual addresses, 4 KB pages and an L1 data cache with 32-byte blocks. 1. The L1 is 8 KB, 2-way set-associative: give the structure of the address as seen by the cache (tag | index | offset, with bit positions) and say whether the cache can be virtually indexed and physically tagged without synonym problems. 2. The designers want 64 KB, keeping 2 ways: how many index bits come from the virtual page number, and in how many sets could an alias of a block be found? 3. What is the minimum associativity of a 64 KB VIPT L1? 4. Give two other ways to make the 64 KB 2-way cache safe.

Show model answer

Page offset = log₂ 4096 = 12 bits, [11:0]. Block offset = log₂ 32 = 5 bits, [4:0].

1. Sets = 8 KB / (32 B × 2) = 128, so the index has 7 bits, [11:5], and the tag 32 − 7 − 5 = 20 bits, [31:12]: |20-bit tag | 7-bit index | 5-bit offset|. Index + offset = 7 + 5 = 12 bits = the page offset; equivalently 8 KB / 2 = 4 KB ≤ 4 KB. The cache can be VIPT, and its tag is exactly the PFN.

2. Sets = 64 KB / (32 B × 2) = 1024, so the index has 10 bits, [14:5]. Bits 14, 13 and 12 lie above the page offset: k = 10 + 5 − 12 = 3 bits come from the VPN, and an alias may be in any of 2³ = 8 sets.

3. Minimum associativity = 64 KB / 4 KB = 16 ways: 128 sets, index [11:5] again.

4. Pages of 32 KB (15 offset bits contain index [14:5]); page colouring by the OS, so that all aliases of a frame agree on virtual-address bits 14 to 12; hardware that checks the 8 candidate sets on a miss and removes a duplicate (as the AMD Opteron did).

Part 1 is the address-structure quiz of July 2024 (lesson 23) with one more question: do index and offset fit in the page offset? The examiner checks the count k = i + o − p and the \(2^k\) candidate sets, and that the fixes act on C / A or on P, never on the block size.

Lesson 27 · Virtual memory in one lesson, and VIPT: start the cache before the TLB answers · question 3 of 7 · open in the lesson

Pages are 4 KB. The L1 data cache is 4 KB, direct-mapped, with 64-byte blocks, write-back and write-allocate. The operating system maps the virtual addresses VA1 = 0x4000_1234 and VA2 = 0x8000_1234 to the same physical address PA = 0x1000_1234, where memory holds 0. The CPU performs: (1) write 7 via VA1; (2) read via VA2; (3) write 9 via VA2; (4) read via VA1. Give the set that all four accesses use, then complete the table Type of memory access | Hit/ Miss Type | Cache Tag | Dirty bit | Write in memory | Value returned, first for a virtually indexed, virtually tagged cache, then for a virtually indexed, physically tagged one. Does either design return a wrong value?

Show model answer

64 sets: index = bits [11:6] of the page offset 0x234 = 001000 = set 8 for all three addresses. Virtual tags: 0x40001 (VA1) and 0x80001 (VA2); physical tag: 0x10001.

VIVT:

Type of
memory access
Hit/ Miss
Type
Cache
Tag
Dirty
bit
Write in
memory
Value
returned
Write 7 via VA1Cold-start Miss0x400011No—
Read via VA2Cold-start Miss0x800010Yes (7)7
Write 9 via VA2Hit0x800011No—
Read via VA1Conflict Miss0x400010Yes (9)9

VIPT:

Type of
memory access
Hit/ Miss
Type
Cache
Tag
Dirty
bit
Write in
memory
Value
returned
Write 7 via VA1Cold-start Miss0x100011No—
Read via VA2Hit0x100011No7
Write 9 via VA2Hit0x100011No—
Read via VA1Hit0x100011No9

In the VIVT table, "Yes (7)" means that the dirty line of VA1, holding 7, is written back to PA 0x1000_1234 before VA2's block is fetched; that fetch then reads the 7.

Neither design returns a wrong value. The aliases share set 8, and a direct-mapped set holds one block: the VIVT cache never has two copies, it pays 3 misses out of 4 and 2 write-backs instead (ping-pong). The VIPT cache has 1 miss and 3 hits. With a second way (8 KB 2-way) the VIVT cache would keep both copies and both reads would return stale values.

This is the notes' own Example 20 configuration, run to the end: it is the counterexample to their "Set 10 / Set 42" story (red pen in section 4). The examiner checks the set from the page offset, the tags as page numbers (0x40001, not 0x4000), and the write-backs. A VIVT cache must also translate the victim's address to write it back to PA 0x1000_1234; the table assumes it does.

Lesson 27 · Virtual memory in one lesson, and VIPT: start the cache before the TLB answers · question 4 of 7 · open in the lesson

A physically indexed L1 cache waits for the TLB: TLB lookup 1 clock cycle, then the cache hit 1 clock cycle. A VIPT version overlaps the TLB lookup completely with the indexing, so its hit takes 1 clock cycle. In both designs the miss rate is 5 % and the miss penalty 20 clock cycles. How much is the speed-up of the average memory access time of the VIPT design over the serial one?

Show model answer
\[ \text{AMAT}_{\text{serial}} = 2 + 0.05 \times 20 = 3 \] \[ \text{AMAT}_{\text{VIPT}} = 1 + 0.05 \times 20 = 2 \]

Speed-up = 3 / 2 = 1.5.

The miss term is the same 1 cycle in both designs: only the hit time changes. The widget of section 3 shows that the gap stays one cycle at any miss rate.

Lesson 27 · Virtual memory in one lesson, and VIPT: start the cache before the TLB answers · question 5 of 7 · open in the lesson

(SINGLE ANSWER) An L1 data cache of 64 KB with 64-byte blocks must be virtually indexed and physically tagged on a machine with 4 KB pages. What is the minimum associativity such that no index bit comes from the virtual page number?

  • Answer 1: 4-way 16 KB per way: 8 index bits [13:6], two of them from the VPN.
  • Answer 2: 8-way 8 KB per way: 7 index bits [12:6], bit 12 still from the VPN.
  • Answer 3: 16-way 64 KB / 16 = 4 KB per way = one page: 64 sets, index [11:6].
  • Answer 4: 32-way Safe, with 2 KB per way, but not the minimum: 16 ways already fit.
Show model answer

Answer 3. Minimum associativity = cache size / page size = 64 KB / 4 KB = 16. The block size does not enter: it moves bits between index and block offset, not out of the page offset.

The quick route is the law, C / A ≤ P; the slow route counts sets and bits. Both give 16. Answer 2 is the near miss: 8 ways halve the overflow, but bit 12 is still a VPN bit.

Lesson 27 · Virtual memory in one lesson, and VIPT: start the cache before the TLB answers · question 6 of 7 · open in the lesson

(SINGLE ANSWER) In a virtually indexed, physically tagged cache, the tag stored with each block is:

  • Answer 1: the virtual page number of the address that brought the block into the cache That is a virtually tagged (VIVT) cache, the design with synonyms.
  • Answer 2: bits of the physical address, from the physical page number supplied by the TLB The tag is physical: every alias of the block matches it.
  • Answer 3: the page offset of the address The page offset supplies the index and the block offset; it is never compared.
  • Answer 4: no tag, because the index identifies the block Many blocks share an index; without a tag a hit could not be recognised.
Show model answer

Answer 2. The index comes from the page-offset bits of the virtual address, the tag from the physical address: the PFN delivered by the TLB is compared with the tags of the selected set.

Read the name backwards: physically tagged. The distractors are the other two designs and the index.

Lesson 27 · Virtual memory in one lesson, and VIPT: start the cache before the TLB answers · question 7 of 7 · open in the lesson

(True/False) A TLB miss means that the page is not in main memory, so the operating system must load it from the disk.

  • True That describes a page fault. After a TLB miss the page is usually in memory, and the walk only refills the TLB.
  • False A TLB miss is a miss in the cache of translations: the page table is walked in tens of cycles. Only an invalid entry, a page fault, involves the disk.
Show model answer

False. On a TLB miss the page table in memory is walked and the translation inserted into the TLB, in tens of cycles. Only if the page-table entry is invalid does a page fault occur, and the OS loads the page from the disk, in millions of cycles.

The distinction between the two misses is the whole point. If asked to motivate, give the cost of each.

Lesson 28 · Hit time is the critical path: small L1, pipelined writes, and the nineteen-technique scorecard

Lesson 28 · Hit time is the critical path: small L1, pipelined writes, and the nineteen-technique scorecard · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used to improve the performance of a cache, and say which term of the average memory access time each one reduces: 1. Small and simple first-level caches; 2. Way prediction; 3. Avoiding address translation during indexing of the cache; 4. Pipelined writes; 5. Small sub-blocks for write-through caches; 6. Victim cache; 7. Giving priority to read misses over writes; 8. Second-level caches.

Show model answer
  1. Hit time. The L1 is accessed on every cycle, so its access time bounds the clock period or adds pipeline stages. A small array has short wires, a simple index decoder and a small tag array; low associativity needs few comparators and, when direct-mapped, no way-select multiplexer, so the data can be sent on while the tag is compared. Benefit: minimum hit time and lower energy per access. Cost: a higher miss rate, worth it only if (MR_small − MR_big) × MP < HT_big − HT_small, i.e. when a fast L2 keeps the miss penalty small.
  2. Hit time. A small table remembers, for each set, the way that hit last; only that way is read and its data is sent at once, as in a direct-mapped cache, while one tag comparison confirms the hit. A wrong guess costs an extra cycle to check the other ways, and the table is updated. Benefit: the hit time and energy of a direct-mapped cache with the miss rate of a set-associative one. It does not reduce the miss rate.
  3. Hit time. The cache is indexed with bits of the virtual address that lie in the page offset, identical in the physical address, while the TLB translates in parallel; the physical tag is compared at the end (virtually indexed, physically tagged). Benefit: the TLB leaves the critical path of every hit. Constraint: index and block-offset bits must fit in the page offset, so cache size / associativity ≤ page size (for example 32 KB, 8-way, with 4 KB pages).
  4. Hit time. A write hit is slower than a read hit, because the tag must be checked before the data array is written: a wrong read can be discarded, a wrong write cannot. The write is split into stages (address decode, tag check, data write) and a new write enters every cycle; the data write of one store overlaps the tag check of the next, the data waiting in a delayed-write buffer. Benefit: one write per cycle instead of one every k cycles; the latency of a write does not change. Loads must check the buffer for a pending write to the same address.
  5. Hit time. Each one-word sub-block has its own valid bit, so the cache writes the word and the tag in parallel with the tag check. Match: the write was right (set the word's valid bit if needed). Mismatch: the overwritten word belonged to another block that memory already holds (write-through), so the line keeps the new tag with only this word valid. Benefit: writes never wait for the tag check, and a write miss fetches nothing. Usable only with write-through: with write-back a dirty block could be destroyed.
  6. Miss rate. A small fully associative buffer (4–16 entries) between the cache and the next level keeps the blocks recently evicted; on a miss it is searched, and a hit there swaps the block back into the cache. It removes many conflict misses of a direct-mapped cache without changing its hit time. Seen from the L1 alone, a victim-cache hit is a cheap miss.
  7. Miss penalty. A read miss stalls the processor, a buffered write does not; so read misses are served before the writes waiting in the write buffer, after checking the buffer for the same address (otherwise a RAW hazard through memory). In a write-back cache a dirty victim is moved to the write buffer and written after the new block has been fetched. Benefit: the read-miss penalty no longer includes pending writes.
  8. Miss penalty. An L2, larger and slower than the L1 but much faster than main memory, serves most L1 misses: AMAT = L1 Hit Time + L1 Miss Rate × (L2 Hit Time + L2 Miss Rate × L2 Miss Penalty), with the local L2 miss rate. The L1 miss rate is unchanged; the L1 miss penalty falls, and the global miss rate (L1 Miss Rate × L2 Miss Rate) is the fraction of accesses that reaches memory. It also makes a small, fast L1 affordable.

Eight sub-points in the form of June 2026, about five lines each. A complete sub-point names the mechanism, the term of AMAT and the cost. Two traps: putting "avoiding address translation" under the miss penalty (the January 2026 quiz of lesson 26), and crediting an L2 with a lower L1 miss rate. For sub-point 4, start with why a write hit is slow; for sub-point 5, with the three cases.

Lesson 28 · Hit time is the critical path: small L1, pipelined writes, and the nineteen-technique scorecard · question 2 of 6 · open in the lesson

Let us consider two designs for the first-level cache of a processor. Design S: 16 KB direct-mapped cache with Hit Time = 1 clock cycle and Miss Rate = 6%. Design B: 64 KB 4-way set associative cache with Hit Time = 2 clock cycles and Miss Rate = 3%. Both are backed by the same L2 cache with Hit Time L2 = 10 clock cycles, Miss Rate L2 (local) = 20% and Miss Penalty L2 = 100 clock cycles.

1. How much is the miss penalty of L1? 2. How much is the AMAT of each design? 3. For which L1 miss penalty would the two designs have the same AMAT? 4. How much would the AMAT of each design be without the L2, if the L1 misses were served by main memory in 100 clock cycles? Which design would you choose in each case?

Show model answer

1. Miss Penalty L1 = Hit Time L2 + Miss Rate L2 × Miss Penalty L2, in clock cycles:

\[ MP_{L1} = 10 + 0.20 \times 100 = 30 \]

2. AMAT = Hit Time + Miss Rate × Miss Penalty, in clock cycles:

\[ \text{AMAT}_S = 1 + 0.06 \times 30 = 2.8 \] \[ \text{AMAT}_B = 2 + 0.03 \times 30 = 2.9 \]

Design S is faster by 0.1 clock cycles per access.

3. Equal AMAT when the extra misses of S cost exactly the cycle it saves on every hit:

\[ 1 + 0.06\, MP = 2 + 0.03\, MP \] \[ MP = \frac{2 - 1}{0.06 - 0.03} = 33.3 \]

S is faster for an L1 miss penalty below about 33 clock cycles.

4. Without the L2 the miss penalty is 100 clock cycles:

\[ \text{AMAT}_S = 1 + 0.06 \times 100 = 7.0 \] \[ \text{AMAT}_B = 2 + 0.03 \times 100 = 5.0 \]

With the L2 choose S (2.8 against 2.9); without it choose B (5.0 against 7.0).

Work in this order: first the L1 miss penalty, from the two-level formula of the example A4 sheet, then the two AMATs. The trap is to use 100 cycles as the L1 miss penalty in part 2. Note how close 30 is to the break-even 33.3: a slightly slower L2 would flip the choice.

Lesson 28 · Hit time is the critical path: small L1, pipelined writes, and the nineteen-technique scorecard · question 3 of 6 · open in the lesson

The write hits of a cache go through a write path of four one-cycle stages (address decode, tag check, data array update, write buffer update). With pipelined writes, how many clock cycles do 10 back-to-back store hits need, from the first decode to the last stage of the tenth store?

Show model answer
\[ k + N - 1 = 4 + 10 - 1 = 13 \]

Without pipelining \(kN\) = 40 clock cycles. The throughput becomes one store per cycle instead of one every 4; each store still takes 4 cycles.

The pipeline fill counts once: the first store needs all four cycles, each of the other nine finishes one cycle later. The same arithmetic as N instructions in a k-stage pipeline (lesson 3).

Lesson 28 · Hit time is the critical path: small L1, pipelined writes, and the nineteen-technique scorecard · question 4 of 6 · open in the lesson

(MULTIPLE ANSWERS) Which of the following cache improvements are effective in reducing the hit time?

  • Answer 1: Adopting higher associativity to reduce conflict misses It lowers the miss rate and lengthens the hit: the way-select multiplexer waits for more comparisons.
  • Answer 2: Avoiding address translation during indexing of the cache Right: the cache is indexed while the TLB translates, so translation leaves the path of every hit (lesson 27).
  • Answer 3: Small and simple first-level caches Right: short wires, few comparators, no way-select multiplexer.
  • Answer 4: Critical word first It shortens the miss penalty: the requested word arrives first.
  • Answer 5: Pipelined writes Right: a write hit no longer holds the cache for its tag check and its data write in a row.
Show model answer

Answers 2, 3 and 5. Answer 1 reduces the miss rate (and increases the hit time); Answer 4 reduces the miss penalty.

The options mix the hit-time list of the notes (p. 369) with one miss-rate and one miss-penalty technique, the way the January 2026 quiz built its wrong answers. Sort each option by the term it changes and the answer follows.

Lesson 28 · Hit time is the critical path: small L1, pipelined writes, and the nineteen-technique scorecard · question 5 of 6 · open in the lesson

(MULTIPLE ANSWERS) Which of the following changes increase the hit time of a first-level cache?

  • Answer 1: Increasing the block size, keeping the cache size No: at a fixed cache size the tag, the comparisons and the data array stay the same; the price of larger blocks is the miss penalty.
  • Answer 2: Increasing the associativity Right: more tags to compare, and the way-select multiplexer waits for them.
  • Answer 3: Increasing the cache size Right: a bigger array has longer wires and a bigger decoder.
  • Answer 4: Adding a victim cache No: it is searched only after a miss, so the hit path does not change.
  • Answer 5: Adding a second-level cache No: the L1 hit is untouched; the L2 lookup is part of the L1 miss penalty.
Show model answer

Answers 2 and 3. A larger block raises the miss penalty, a victim cache and an L2 act only after an L1 miss.

Answers 1 and 5 are the cells a and f of Table 29 that this lesson corrects. If the paper asks you to motivate, give one line per option: the term it really changes.

Lesson 28 · Hit time is the critical path: small L1, pipelined writes, and the nineteen-technique scorecard · question 6 of 6 · open in the lesson

(True/False) Pipelining the cache writes reduces the latency of each individual write.

  • True Each write still goes through all its stages; only the next write no longer waits for it.
  • False Right: pipelining raises the number of writes per cycle, not the speed of one write.
Show model answer

False. With pipelined writes a new write can start every cycle, so the throughput rises (to one write per cycle in Example 22 of the notes), but each write still needs its address decode, tag check and data write: "latency still 3, but overlapped". Its data may even wait longer in the delayed-write buffer when loads are using the data array.

Motivate a true/false with the mechanism: throughput against latency, the same distinction as for an instruction pipeline.

To the filters ↑

Module 7 · Threads, vectors and GPUs

25 questions · Notes, chapters 7–9 · multithreading, SIMD and vector machines, VMIPS and convoys, GPUs, tensor cores and NPUs

Lesson 29 · Multithreading: fine-grained, coarse-grained, SMT, and the exam’s per-thread CPI

Lesson 29 · Multithreading: fine-grained, coarse-grained, SMT, and the exam’s per-thread CPI · question 1 of 7 · open in the lesson

QUESTION 2: MULTITHREADING (5 points). Let's consider the fine-grained and simultaneous multithreading techniques used to manage thread-level parallelism by hardware processors. Answer to the following questions:

  • Explain the main concepts for each technique.
  • For each technique, make an example with up to 4 threads (T1, T2, T3, T4) on a quad-issue processor.
  • Let's consider a quad-issue SMT processor that can manage up to 4 threads: How much is the ideal CPI? How much is the ideal per-thread CPI?
  • What are the main benefits for each technique?
  • What are the main drawbacks for each technique?
Show model answer

Concepts. Fine-grained MT: the core holds the context (PC, registers) of several threads and switches thread every clock cycle, round robin, skipping a thread that is stalled; in each cycle all the issue slots belong to one thread. SMT: on a dynamically scheduled (out-of-order, renamed) superscalar, the issue slots of one cycle are filled with ready instructions of several threads; each thread has its own PC and renaming table, instructions carry a thread tag in the reservation stations and the ROB, and functional units and caches are shared.

Example, fine-grained (one thread per cycle; T4 is stalled at C7 and skipped):

CycleIssue 1Issue 2Issue 3Issue 4
C0T1T1T1–
C1T2T2T2–
C2T3T3T3–
C3T4T4T4–
C4T1T1––
C5T2T2––
C6T3–––
C7T1T1T1T1
C8T2T2T2–
C9T3T3––

Example, SMT (several threads per cycle; T4 is stalled from C3 to C6 and the others take its slots):

CycleIssue 1Issue 2Issue 3Issue 4
C0T1T2T3T4
C1T2T3T4T1
C2T3T4T1T2
C3T1T1T2T3
C4T1T1T1T2
C5T2T2T2T1
C6T3T3T1–
C7T4T4T3T3
C8T3T4T4T4
C9T3T3T3T4

Ideal CPI = 1 / issue width = 1/4 = 0.25. Ideal per-thread CPI = threads / issue width = 4/4 = 1: the four slots are shared by four threads, one instruction per cycle each.

Benefits. Fine-grained: hides short and long stalls (RAW, mispredictions, misses), because a stalled thread just loses its turn; no switch cost; simple fair rotation. SMT: the highest throughput, because it fills both the empty cycles (vertical waste) and the empty slots inside a cycle (horizontal waste); it combines ILP and TLP at a small hardware cost on an out-of-order core.

Drawbacks. Fine-grained: each thread runs slower when the others are ready (one cycle in N); the slots a thread cannot fill in its cycle stay empty; a thread selection every cycle. SMT: the threads compete for caches, functional units and branch predictors, so per-thread performance is lower and unpredictable; complex fetch, issue and commit logic; a larger register file.

This is the July 2024 question, a two-column table with five rows; the CPI row is asked for SMT only. What it checks: the rule "one thread per cycle" against "several threads per cycle", said in the concepts and visible in the drawings; the two numbers with their reason; benefits and drawbacks named in terms of waste. The two grids are the widget's exam example, quad-issue with four threads: fine-grained fills 26 of 40 slots, SMT 39. Any grid that respects the two rules is a valid example.

Lesson 29 · Multithreading: fine-grained, coarse-grained, SMT, and the exam’s per-thread CPI · question 2 of 7 · open in the lesson

QUESTION 2: MULTICORE PROCESSORS (5 points). High-performance multicore processors today use a combination of several computer architecture techniques. Let's consider a single-chip dual-core shared-memory architecture where each core is a dual-issue superscalar processor with multi-threading up to 2 threads per core.

  • Explain the preferred technique used to manage the multiple threads for each core.
  • Make an example of scheduling up to 4 threads per chip where T1 and T2 are executed on Core1 and T3 and T4 on Core2 (table: Cycle C0–C9 × Core 1: Issue 1, Issue 2 × Core 2: Issue 1, Issue 2).
  • Let's consider our dual-issue SMT processor that can manage up to 4 concurrent threads (2-thread per core): How much is the ideal per core CPI? How much is the ideal dual-core CPI? How much is the ideal per-thread CPI?
  • Explain the preferred technique used in each superscalar processor to manage the instruction scheduling in each thread.
  • Explain the preferred technique used to manage the cache coherency problem in the dual core chip.
Show model answer

Threads in each core: simultaneous multithreading (Intel Hyper-Threading style). Both hardware threads of a core are active at once and, in the same cycle, their ready instructions fill the two issue slots of the shared out-of-order engine; per thread a PC and a renaming table, thread tags in the reservation stations and the ROB; caches and functional units shared.

CycleCore 1Core 2
Issue 1Issue 2Issue 1Issue 2
C0T1T2T3T4
C1T2T1T4T3
C2T1T2T3T4
C3T2T1T3–
C4T1T2––
C5T2T1––
C6T1T2T3T3
C7T2T1T4T3
C8T1–T3T4
C9T1–T4T3

Ideal CPIs: per core = 1/2 = 0.5; dual-core = 1/(2 × 2) = 0.25, since the chip completes four instructions per cycle; per thread = 2/2 = 1, since each thread shares its core's two slots with one other thread.

Scheduling inside each thread: dynamic scheduling — Tomasulo's algorithm with reservation stations and register renaming, out-of-order execution, and a reorder buffer for speculation with in-order commit, together with dynamic branch prediction.

Coherence: each core has private caches holding copies of shared blocks; a snooping write-invalidate, write-back protocol (MESI) on the shared bus keeps them coherent: a write to a shared block first invalidates the other copies.

The June 2025 question. The schedule is the widget's exam example split over two cores. At C4 and C5 both threads of core 2 are stalled: its slots stay empty, because core 1's threads cannot issue on core 2 — the thread-to-core assignment is part of the question. Any schedule in which each thread stays on its core and either thread of a core may take both of its slots is a valid example. For the last row snooping is the natural choice: two cores on one chip share a bus, while directories serve machines with many nodes (lessons 37–38).

Lesson 29 · Multithreading: fine-grained, coarse-grained, SMT, and the exam’s per-thread CPI · question 3 of 7 · open in the lesson

Question 1: Instruction-Level and Thread-Level Parallelism. Modern processors exploit Instruction Level Parallelism and Thread Level Parallelism. Answer to the following questions:

  • Explain the main concepts for each approach (Instruction Level Parallelism ILP, Thread Level Parallelism TLP).
  • Which type of technique can be applied in superscalar processors to combine both ILP and TLP?
  • Explain what type of instruction scheduling is used in superscalar processors to combine both ILP and TLP?
  • What are the main hardware modifications required for a generic superscalar processor to support both ILP and TLP?
Show model answer

ILP executes independent instructions of one instruction stream in parallel: pipelining, multiple issue (superscalar or VLIW), dynamic scheduling with out-of-order execution, register renaming against WAR and WAW hazards, branch prediction and speculation. It is limited by true dependences, control dependences and memory latency, is extracted mostly by the hardware (by the compiler in a VLIW) and speeds up one thread. TLP executes independent instruction streams — threads or processes provided by the programmer or the OS — in parallel: multithreading in one core (coarse-grained, fine-grained, SMT), multicores and shared-memory multiprocessors (coherent caches, synchronisation with locks and barriers), and clusters with private memories and message passing. It raises the throughput of a multithreaded workload.

Combining both: simultaneous multithreading, which fills the issue slots of a superscalar in the same cycle with instructions of several threads.

Scheduling: dynamic scheduling — the hardware reorders the instructions at run time (Tomasulo with renaming and a reorder buffer), instead of static scheduling by the compiler as in simple in-order superscalars and VLIWs. One instruction window holds the instructions of all active threads; every cycle the ready instructions, from whichever thread, are issued to the free functional units. Renaming gives each in-flight instruction a unique physical destination, so threads cannot collide on register names.

Hardware: a PC per thread; a renaming table per thread over a larger shared physical register file that holds every thread's architectural registers; a thread tag on every instruction in the reservation stations, the ROB and the load/store queues; per-thread commit and exception squash; a fetch policy that selects the thread each cycle (round robin, ICOUNT); issue logic that picks ready instructions across threads; buffers shared or partitioned between threads; caches, functional units and predictors shared.

The question of the 11 February 2025 paper as the notes transcribe it (p. 574). Their worked answer (pp. 574–577) is long and has three slips, corrected in the red pens of sections 4 and 5: clusters do not share memory, SMT threads raise no coherence problem, and the buffers need not all grow. The compact hardware list of Hennessy and Patterson — a renaming table per thread, separate PCs, commit from several threads — is a good first line, then expand.

Lesson 29 · Multithreading: fine-grained, coarse-grained, SMT, and the exam’s per-thread CPI · question 4 of 7 · open in the lesson

QUESTION 1: SUPERSCALAR PROCESSORS (8 points). Explain the main concepts and benefits of each one of the following techniques used by modern superscalar processors (Tomasulo-style): 1. Dynamic Instruction Scheduling; 2. Dynamic branch prediction and speculative execution; 3. Multiple-issue pipeline; 4. Reservation stations; 5. Dynamic Register Renaming; 6. Out-of-Order Execution; 7. Reorder Buffer; 8. Simultaneous multi-threading.

Here: sub-point 8 only, in five lines.

Show model answer

8. Simultaneous multi-threading. Several hardware threads are active at once in one out-of-order superscalar core: each keeps its own PC and renaming table over the shared physical registers, and a thread tag in the reservation stations and the ROB keeps results and commits apart. Every cycle the issue logic sends the ready instructions of any thread to the free functional units, so one cycle mixes threads. Benefit: the other threads fill the slots that one thread's ILP leaves empty (vertical and horizontal waste) — higher throughput and unit utilisation for little hardware (Hyper-Threading: under 5 % of the die, up to 30 % more throughput). Cost: shared caches and units, so single threads run slower and less predictably.

The June 2026 paper asks eight techniques in five lines each, one point apiece; SMT is sub-point 8. A good answer names four things: several threads issue in the same cycle (the line that separates SMT from fine-grained multithreading), on an out-of-order core with per-thread renaming and thread tags, filling the slots ILP leaves empty, at the price of contention. The other seven sub-points belong to lessons 5 to 18.

Lesson 29 · Multithreading: fine-grained, coarse-grained, SMT, and the exam’s per-thread CPI · question 5 of 7 · open in the lesson

(SINGLE ANSWER) Let's consider a quad-issue SMT processor that can manage up to 8 simultaneous threads. What are the values of the ideal CPI and the ideal per-thread CPI?

  • Answer 1: Ideal CPI = 1 & Ideal per-thread CPI = 0.125 1 is the ideal of a single-issue pipeline, and 0.125 = 1/8 divides by the threads, as if sharing made a thread faster than the core.
  • Answer 2: Ideal CPI = 0.5 & Ideal per-thread CPI = 2 The per-thread value is right, but 0.5 is the ideal of a dual-issue core; four slots give 1/4.
  • Answer 3: Ideal CPI = 0.25 & Ideal per-thread CPI = 2 1/w = 1/4 = 0.25; eight threads share four slots, half an instruction per cycle each: 8/4 = 2.
  • Answer 4: Ideal CPI = 0.5 & Ideal per-thread CPI = 4 Both values belong to a dual-issue core with 8 threads: 1/2 and 8/2.
  • Answer 5: Ideal CPI = 0.25 & Ideal per-thread CPI = 4 The core value is right; 4 would need sixteen threads on four slots.
Show model answer

Answer 3. Ideal CPI = 1 / issue width = 1/4 = 0.25; ideal per-thread CPI = threads / issue width = 8/4 = 2.

The June 2025 quiz, with its options verbatim. All three papers build the five options from the same few numbers permuted, so the only defence is the two formulas: 1/w for the core, n/w per thread. The CPI widget of section 4 drills the other two papers' versions.

Lesson 29 · Multithreading: fine-grained, coarse-grained, SMT, and the exam’s per-thread CPI · question 6 of 7 · open in the lesson

(SINGLE ANSWER, 1 point) Let's consider a dual-issue SMT processor that can manage up to 4 hardware threads. What are the values of the ideal CPI and the ideal per-thread CPI? Answer 1: Ideal CPI = 1 & Ideal per-thread CPI = 0.25. Answer 2: Ideal CPI = 0.25 & Ideal per-thread CPI = 0.25. Answer 3: Ideal CPI = 0.5 & Ideal per-thread CPI = 2. Answer 4: Ideal CPI = 0.5 & Ideal per-thread CPI = 1. Answer 5: Ideal CPI = 0.25 & Ideal per-thread CPI = 4.

Make a practical example of SMT scheduling with up to 4 threads (T1, T2, T3, T4) on the dual-issue processor (1 point), in the table C0–C9.

Show model answer

Answer 3: ideal CPI = 1/2 = 0.5; ideal per-thread CPI = 4/2 = 2.

CycleIssue 1Issue 2
C0T1T2
C1T2T3
C2T3T4
C3T4T1
C4T1T2
C5T2T3
C6T3T4
C7T1T2
C8T1T2
C9T2T3

In every cycle the two slots hold instructions of two threads issued together. From C7 on T4 waits for a miss and the other threads take its slots.

The June 2026 Question 5: 1 point for the option and 1 for the example. The example must show what makes SMT simultaneous — different threads in the same row; a row with the same thread twice is allowed too (that thread had two ready instructions). This grid is the widget's exam example on the dual-issue core; it fills all 20 slots.

Lesson 29 · Multithreading: fine-grained, coarse-grained, SMT, and the exam’s per-thread CPI · question 7 of 7 · open in the lesson

(True/False) In fine-grained multithreading, instructions from different threads can be issued in the same clock cycle.

  • True That is the definition of simultaneous multithreading. Fine-grained MT changes thread between cycles; inside a cycle all the issued instructions belong to one thread.
  • False Right: one thread per cycle, a different one every cycle. That is exactly why fine-grained MT leaves horizontal waste.
Show model answer

False. Fine-grained multithreading switches thread every clock cycle, so consecutive cycles may belong to different threads, but within one cycle only one thread issues; issuing from several threads in the same cycle is simultaneous multithreading.

The classic confusion in the July 2024 two-column answer. If the drawing of the fine-grained column shows two threads in one row, the example contradicts the concept.

Lesson 30 · Why Cray threw away the cache: Flynn, SIMD and the vector idea

Lesson 30 · Why Cray threw away the cache: Flynn, SIMD and the vector idea · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following topics of SIMD and vector architectures: 1. Data-level parallelism; 2. Flynn's taxonomy and the class of a superscalar processor; 3. SIMD execution with a single program counter; 4. Array processors vs pipelined vector processors; 5. Vector register file; 6. Deeply pipelined vector functional units; 7. Interleaved memory banks; 8. Little or no data cache.

Show model answer

1. Data-level parallelism. The same operation applied independently to many data items, as in Z[i] = X[i] + Y[i]: no element waits for another. It is a property of the program, exploited by SIMD and vector hardware with one instruction per data operation instead of one per element; the fetch, decode and issue cost per element is divided by the vector length, so it costs far less energy than extracting the same parallelism as ILP.

2. Flynn's taxonomy and the superscalar. Flynn classifies machines by the number of instruction streams and data streams. A superscalar fetches several different instructions per cycle from one program counter: one instruction stream, each instruction on its own operands, so it is SISD and exploits ILP. The benefit of the classification is to separate ILP (more instructions per cycle from one stream), DLP (one instruction on many data, SIMD) and TLP (many streams, MIMD): Flynn counts streams, not width.

3. SIMD with a single PC. One control unit fetches each instruction once and broadcasts it to many processing elements, which execute it in lockstep on their own data. Benefits: one fetch and decode per operation instead of per PE (energy), compact code, no synchronisation between PEs. Drawback: divergent control flow must be handled by masking off elements.

4. Array vs vector processors. An array processor has N processing elements working side by side; an operation with latency L keeps them frozen, so it takes L × ⌈n/N⌉ cycles and the latency is exposed on every round, and the programmer thinks in PEs and local memories. A vector processor pipelines its units: the latency is paid once and then one result per cycle, L + n cycles (6 + 64 = 70), and the programmer thinks in vector registers. On long vectors one L-stage pipelined unit does the work of about L unpipelined ones.

5. Vector register file. Registers holding whole vectors (VMIPS: 8 registers of 64 × 64-bit elements, 16 read and 8 write ports through a crossbar), used register-to-register: each element is loaded once and reused by several instructions, and the pipelines are fed from registers without stalling on memory. It is compiler-controlled, unlike a cache: no tags, no misses.

6. Deeply pipelined functional units. Each unit accepts a new element every cycle. Element independence means no hazard checks between elements, so the pipelines can be deep and fast, and the start-up latency is amortised over the whole vector: about one result per cycle per unit. Cost: every instruction pays its start-up, so short vectors are inefficient.

7. Interleaved memory banks. Consecutive words are placed in consecutive banks; each bank is busy for several cycles after an access, but together they deliver one word per cycle to the vector load/store unit (Cray-1: 16 banks, 4-cycle bank busy time). Benefit: the bandwidth needed by streaming loads and stores; cost: many banks, and conflicts when a stride keeps hitting the same bank.

8. Little or no data cache. Vector accesses are predictable — the instruction states which words it needs — and streaming kernels use each element once, so a cache would add latency and area for little reuse. Bandwidth comes from the banks, latency is amortised by pipelining and buffered in the vector registers; a small scalar cache may serve the scalar side, which the vector side bypasses.

The 22 June 2026 paper asks its 8-point question in exactly this form, there on Tomasulo-style techniques, with five lines per item. For each item write the mechanism in one sentence, then the benefit, then a cost or a condition. Items 2 and 4 carry the two traps of the topic: "superscalar = SIMD" and the notes' "latency × vector length" for arrays.

Lesson 30 · Why Cray threw away the cache: Flynn, SIMD and the vector idea · question 2 of 6 · open in the lesson

Let's consider Flynn's taxonomy. In which class is an out-of-order superscalar processor that issues up to 4 instructions per clock cycle from a single thread? (Single answer.)

  • SISD One program counter, one instruction stream: the four instructions of a cycle are different instructions of the same stream. Parallelism across instructions is ILP, not a second stream.
  • SIMD SIMD is one instruction applied to many data elements; the superscalar issues several different instructions, each on its own operands.
  • MISD MISD would need several instruction streams on a single data stream; it is essentially hypothetical.
  • MIMD MIMD needs several instruction streams, one PC per thread or core; a single core running one thread has one.
Show model answer

Answer 1: SISD. Flynn's classification counts instruction and data streams, not issue width: a superscalar fetches all its instructions from one program counter.

The notes file it under "Practical clarification" (p. 388) because it is the classic confusion. A good motivation line: "streams, not width; superscalar = ILP within one stream".

Lesson 30 · Why Cray threw away the cache: Flynn, SIMD and the vector idea · question 3 of 6 · open in the lesson

True or false: in a vector processor with fully pipelined functional units, the latency of a functional unit is paid once for each element of the vector.

  • True That describes a single unpipelined unit (the array with N = 1) or a scalar loop: L × n. In a pipelined unit the elements overlap, L + n cycles.
  • False The latency (start-up) is paid once per vector instruction; after it, one element completes every cycle: 6 + 64 = 70 cycles for 64 elements with a 6-cycle adder.
Show model answer

False. The latency is paid once per vector instruction (the start-up); then the pipeline delivers one result per clock cycle, so n elements take about L + n cycles, not L × n.

The True/False form of the June 2025 paper's GPU quiz, on the idea behind every vector timing in lesson 31. If asked to motivate, give both counts with numbers.

Lesson 30 · Why Cray threw away the cache: Flynn, SIMD and the vector idea · question 4 of 6 · open in the lesson

Which features allow a classic (Cray-style) vector processor to keep its functional units busy with little or no data cache? (Multiple answers.)

  • Interleaved memory banks that together deliver one word per clock cycle Each bank is busy for several cycles, but consecutive words sit in different banks: bandwidth without a cache.
  • Vector registers loaded and reused under compiler control They buffer whole vectors next to the units; the compiler decides what is loaded, so nothing misses.
  • Pipelined load/store and arithmetic units that pay the latency once per vector Memory latency is paid once per vector load, then one word per cycle: it is amortised, not hidden by a cache.
  • A large branch target buffer that predicts the next memory address A BTB predicts branch targets, not data addresses; a vector loop has no per-element branches to predict anyway.
  • The high temporal reuse of the vector elements Streaming kernels use each element once; it is the lack of reuse that makes a cache useless here.
Show model answer

Answers 1, 2 and 3. Vector accesses are predictable and stream each element once: interleaved banks supply the bandwidth, pipelined units pay the latency once per vector, and the vector registers act as a compiler-managed buffer.

The last option is the trap: caches live on reuse, and the reason vector machines drop them is that streams have none. Choosing it means confusing locality with data-level parallelism — the slip of the notes on p. 387.

Lesson 30 · Why Cray threw away the cache: Flynn, SIMD and the vector idea · question 5 of 6 · open in the lesson

Let's consider a vector processor whose FP add unit is fully pipelined with a start-up latency of 6 clock cycles. How many clock cycles does ADDVV.D V3, V1, V2 take on vectors of 64 elements, counting the start-up and then one result per cycle?

Show model answer
\[ T = \text{start-up} + n = 6 + 64 = 70 \ \text{cycles} \]

For comparison: one unpipelined adder would need 6 × 64 = 384 cycles of computation; an array of 64 unpipelined PEs about 6, with 64 adders instead of one.

The papers' convoy quizzes ignore the start-up (cycles = convoys × vector length, lesson 31); a question about one instruction with a given start-up counts it. Read which of the two the question wants.

Lesson 30 · Why Cray threw away the cache: Flynn, SIMD and the vector idea · question 6 of 6 · open in the lesson

Let's consider DAXPY on 64 elements. The scalar MIPS code has 2 set-up instructions and a loop body of 9 instructions executed once per element; the VMIPS code has 6 instructions. By what factor does vectorisation reduce the number of executed instructions?

Show model answer
\[ IC_{\text{MIPS}} = 2 + 9 \times 64 = 578 \] \[ \frac{IC_{\text{MIPS}}}{IC_{\text{VMIPS}}} = \frac{578}{6} = 96.3 \]

Write the instruction count before dividing: 9 × 64 = 576 forgets the set-up. If the question asks where the difference goes, 572 = 315 element instructions + 192 pointer and bound updates + 64 branches + 1 set-up.

Lesson 31 · VMIPS and the art of counting convoys: chaining, lanes, lengths, masks and banks

Lesson 31 · VMIPS and the art of counting convoys: chaining, lanes, lengths, masks and banks · question 1 of 7 · open in the lesson

Consider a vector processor architecture, as VMIPS shown in the figure (main memory, vector load/store unit, vector registers, scalar registers, and the FP add/subtract, FP multiply, FP divide, integer and logical vector units).

Present the main concepts. Present the main advantages of vector execution with respect to scalar execution, detailing the features of the vector architecture that provide the advantage.

Show model answer

Main concepts. A vector processor is a SIMD machine: one instruction operates on whole vectors held in vector registers. VMIPS is the scalar MIPS pipeline plus a vector unit: (1) a vector register file — 8 registers of 64 elements of 64 bits, with many read and write ports (16 and 8) through a crossbar — a compiler-controlled buffer between memory and the functional units; (2) deeply pipelined vector functional units (FP add/subtract, FP multiply, FP divide, integer, logical) that deliver one result per cycle after a start-up latency; (3) a vector load/store unit that streams one word per cycle from interleaved memory banks, with unit-stride, strided (LVWS) and indexed (gather/scatter) accesses; (4) scalar registers for addresses, strides and the scalar operands of instructions such as MULVS.D; (5) the vector-length register VLR (0 ≤ VLR ≤ MVL), used with strip mining for loops of any length, and the vector mask register for loops with an IF. Execution time is counted in convoys — instructions that run together, one per unit, dependent ones only with chaining — and chimes of about VL cycles: T ≈ convoys × VL.

Advantages and the feature that provides each. (a) Far fewer instructions fetched, decoded and issued: one vector instruction does the work of a whole loop (DAXPY on 64 elements: 6 instructions instead of about 578) — vector registers and vector instructions; less instruction bandwidth and energy. (b) Almost no loop overhead: index updates and loop branches disappear, one branch per strip of up to MVL elements instead of one per element, hence far fewer control hazards and mispredictions — vector-length semantics, VLR and strip mining. (c) Deep pipelines without stalls: the elements of a vector are independent, so no hazard checks inside an instruction, and dependences between vector instructions are checked once per vector, not once per element — pipelined vector units. (d) Overlap of dependent operations and of several units: chaining forwards element by element and several units run in one convoy (DAXPY in 3 chimes, 192 cycles, instead of 4 chimes, 256) — multiple units plus chaining. (e) Memory latency paid once per vector and a sustained bandwidth of one word per cycle: known access patterns let the load/store unit stream from interleaved banks, with little or no data cache — vector load/store unit plus banks. (f) Scalability without changing the code: L lanes process L elements per cycle, ⌈VL/L⌉ cycles per chime, same instructions. Limits: the gain needs data-level parallelism; masked elements still cost cycles; bad strides cause bank conflicts.

This is Question 2 of the February 2025 paper (notes, p. 578); lesson 30 redraws its VMIPS figure. The question has two halves: answer both. For the concepts, name the parts of the figure and what each does; for the advantages, tie each one to the feature that delivers it — "fewer instructions, because one vector instruction encodes a whole loop" — with a number where you have one (6 against 578 instructions, 192 against 256 cycles). One line on the limits shows that you know where vectors stop helping.

Lesson 31 · VMIPS and the art of counting convoys: chaining, lanes, lengths, masks and banks · question 2 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by vector processors: (1) Chaining; (2) Multiple lanes; (3) Vector length register and strip mining; (4) Vector mask registers; (5) Interleaved memory banks and strided accesses.

Show model answer

(1) Chaining: the result of a vector unit is forwarded element by element to the next unit, so a dependent vector instruction starts as soon as the first element of its operand is produced, instead of waiting until the whole vector is written back. Benefit: dependent instructions run overlapped in the same convoy, one chime instead of two per dependence (DAXPY: 4 convoys, 256 cycles → 3 convoys, 192 cycles). It is the vector analogue of forwarding; it does not remove structural hazards — one instruction per unit per convoy.

(2) Multiple lanes: each vector unit and the vector register file are split into L lanes; element i of every register lives in lane i mod L, so element-wise operations never cross lanes. Benefit: L elements per cycle, a chime of ⌈VL/L⌉ cycles (64 elements on 4 lanes: 16 cycles), with no change to the ISA or the code. Cost: register-file ports and memory bandwidth grow with L.

(3) VLR and strip mining: MVL is the hardware length of a vector register; the vector length register (0 ≤ VLR ≤ MVL) tells each instruction how many elements to process. Strip mining is the compiler transformation that cuts a loop of n iterations into ⌈n/MVL⌉ strips, the short one with VLR = n mod MVL (260 elements on MVL 64: 4 × 64 + 4). Benefit: one vector loop for any n, no access past the end of the arrays. Cost: a scalar strip loop with its overhead.

(4) Vector mask registers: one bit per element, set by a vector compare; instructions executed under the mask update only the elements whose bit is 1. Benefit: loops with an IF stay vectorizable (predication at vector level), no scalar fallback, any instruction can be masked. Cost: masked elements still take their cycle, so efficiency equals the fraction of active elements.

(5) Interleaved banks: consecutive words go to consecutive banks (bank = (address / word size) mod #banks), so a unit-stride access finds a free bank every cycle and the load/store unit sustains one word per cycle; strided loads (LVWS) and gather/scatter through index vectors handle matrix columns and sparse data. A stride visits #banks / gcd(stride, #banks) banks; if that is less than the bank busy time, accesses stall (8 banks, busy time 6, latency 12, 64 elements: stride 128 hits one bank and takes 391 cycles instead of 76). Fixes: pad rows (129 words), interchange the loops, choose a column-major layout.

The June 2026 paper asked eight such sub-points in one 8-point question, about five lines each; the 2024 and 2025 papers had 5-point open questions. A complete sub-point says what the mechanism does, what it buys — with a number — and what it costs.

Lesson 31 · VMIPS and the art of counting convoys: chaining, lanes, lengths, masks and banks · question 3 of 7 · open in the lesson

Let's consider the following code executed by a Vector Processor with: Vector Register File composed of 32 vectors of 16 elements per 64 bits/element; Scalar FP Register File composed of 32 registers of 64 bits; One Load/Store Vector Unit with operation chaining and memory bandwidth 64 bits; One ADD/SUB Vector Unit with operation chaining; One MUL/DIV Vector Unit with operation chaining.

L.V      V1, R1       # Load vector from mem. addr. R1 into V1
L.V      V3, R2       # Load vector from mem. addr. R2 into V3
ADDVS.D  V2, V1, S1   # FP add vector V1 to scalar S1
MULVS.D  V2, V2, S2   # FP multiply vector V2 to scalar S2
ADDVS.D  V3, V3, S3   # FP add vector V3 to scalar S3
S.V      V2, R1       # Store vector V2 into memory addr. R1
S.V      V3, R2       # Store vector V3 into memory addr. R2

How many convoys? How many clock cycles to execute the code? Motivate your answer by completing the timing scheme (0, 1, … 15 for the first convoy).

  • 2 convoys; 32 clock cycles Four memory instructions share one load/store unit: two convoys would need two of them in each.
  • 3 convoys; 48 clock cycles A load phase, an arithmetic phase and a store phase: that puts two loads and two stores into single convoys, and both ADDVS.D on the one adder.
  • 4 convoys; 64 clock cycles The load/store unit forces four convoys and chaining packs the arithmetic into the first two: 4 × 16 = 64.
  • 5 convoys; 80 clock cycles The count without chaining: ADDVS.D V2 can no longer join L.V V1, nor MULVS.D join ADDVS.D.
Show model answer

Answer 3: 4 convoys; 64 clock cycles. Four memory instructions on one load/store unit need at least four convoys, and four are enough. A convoy lasts 16 cycles: 16 elements, one 64-bit element per cycle (bandwidth 64 bits), start-up ignored.

Convoys and timing scheme, one strip of 16 cycles per convoy (chained instructions start a few cycles after their producer).
firstinstructions of the convoylast
01… L.V V1, R1 · ADDVS.D V2, V1, S1 (chained) · MULVS.D V2, V2, S2 (chained) …15
1617… L.V V3, R2 · ADDVS.D V3, V3, S3 (chained) …31
3233… S.V V2, R1 …47
4849… S.V V3, R2 …63

The same question was Question 6 of July 2024, with the options 3/48, 2/32 and 4/64. The motivation point is the scheme: four strips of 16 cycles. Say why the count cannot be lower — four memory instructions, one load/store unit — and why chaining matters: without it, 5 convoys and 80 cycles. Swapping the second and third convoy (S.V V2 before L.V V3) is equally correct, and so is the scheme packed strictly in listing order: L.V V1 alone in the first strip, then L.V V3 + ADDVS.D V2 + MULVS.D V2, then ADDVS.D V3 + S.V V2, then S.V V3 — the same 4 convoys.

Lesson 31 · VMIPS and the art of counting convoys: chaining, lanes, lengths, masks and banks · question 4 of 7 · open in the lesson

Let's consider the following code executed by a Vector Processor with: Vector Register File composed of 32 vectors of 8 elements per 64 bits/element; Scalar FP Register File composed of 32 registers of 64 bits; One Load/Store Vector Unit with operation chaining and memory bandwidth 64 bits; One ADD/SUB Vector Unit with operation chaining; One MUL/DIV Vector Unit with operation chaining.

L.V      V1, RA
L.V      V2, RB
L.V      V3, RC
MULVS.D  V1, V1, F1
MULVS.D  V2, V2, F2
MULVS.D  V3, V3, F3
ADDVV.D  V2, V2, V1
ADDVV.D  V3, V2, V3
S.V      V3, RD

How many convoys? How many clock cycles to execute the code? Motivate your answer by completing the table (Load/Store Vector Unit, Mul/Div Vector Unit, Add/Sub Vector Unit; 1^ convoy: L.V V1, RA).

  • 2 convoys; 16 clock cycles Four memory instructions on one load/store unit need at least four convoys.
  • 3 convoys; 24 clock cycles Three loads and a store cannot fit in three convoys on one load/store unit.
  • 4 convoys; 32 clock cycles Each multiply chains on its load and each add on its multiply; the store needs a fourth convoy: 4 × 8 = 32.
  • 5 convoys; 40 clock cycles No reading of the rules gives five: chaining with the packing of move 3 reaches the floor of four, and both the count without chaining and the strict listing-order packing give six.
  • 6 convoys; 48 clock cycles The count without chaining — and also the count if you pack strictly in listing order, so that MULVS.D V1 waits behind L.V V2 and L.V V3. With chaining and the packing of move 3, four convoys suffice.
Show model answer

Answer 3: 4 convoys; 4 × 8 = 32 clock cycles (8 elements, one 64-bit element per cycle).

June 2025, Question 4 (recomputed).
Load/Store Vector UnitMul/Div Vector UnitAdd/Sub Vector Unit
1^ convoyL.V V1, RAMULVS.D V1, V1, F1
2^ convoyL.V V2, RBMULVS.D V2, V2, F2ADDVV.D V2, V2, V1
3^ convoyL.V V3, RCMULVS.D V3, V3, F3ADDVV.D V3, V2, V3
4^ convoyS.V V3, RD
5^ convoy
6^ convoy

The single load/store unit serialises the three loads and the store; with chaining each multiply joins the convoy of its load, and each add the convoy of its multiply, its other operand being complete (V1 after the 1^ convoy, V2 after the 2^).

The paper fills in L.V V1, RA and leaves six rows: two stay empty here. MULVS.D V1 joins the first convoy although two loads stand before it in the listing, because it does not depend on them — the packing of move 3. Answer 5, 6 convoys and 48 cycles, is the count without chaining and also the count of a packing that keeps strict listing order. No official key exists for this paper: under the table, write the one-line assumption that independent instructions are grouped regardless of listing order.

Lesson 31 · VMIPS and the art of counting convoys: chaining, lanes, lengths, masks and banks · question 5 of 7 · open in the lesson

Let's consider the following code: for (i=0; i<260; i++) Y[i] = X[i] + Y[i]; Which code transformation can be applied to be executed by the VMIPS processor with a Vector Register File composed of 8 registers of 64 elements and 64 bits/element? Motivate your answer.

  • Trace scheduling A VLIW compiler technique that schedules scalar instructions across branches; this loop body has no branch, and its problem is the vector length.
  • Software pipelining It overlaps iterations of a scalar loop on a statically scheduled machine; it does not make 260 elements fit into 64-element registers.
  • Strip mining 260 > 64, so the loop is cut into strips of at most 64 elements, with the vector length register set for each strip.
  • Apply a mask register A mask handles a conditional statement inside a vector loop; there is none here.
Show model answer

Strip mining. MVL = 64 < n = 260, so the loop is split into ⌈260/64⌉ = 5 strips: four strips of 64 elements and one of 260 mod 64 = 4 elements (first, in Hennessy and Patterson's code, or last), setting VLR before each strip. Each strip executes L.V V1, RX; L.V V2, RY; ADDVV.D V3, V1, V2; S.V V3, RY. A mask register is for an IF inside the loop, which is absent; trace scheduling and software pipelining are VLIW compiler techniques for scheduling scalar instructions.

Question 5 of July 2024; June 2026 asked it again with 16 registers of 32 elements (260 = 8 × 32 + 4). The motivation point is the arithmetic, plus one sentence on why each distractor does not fit.

Lesson 31 · VMIPS and the art of counting convoys: chaining, lanes, lengths, masks and banks · question 6 of 7 · open in the lesson

Let's consider the following code executed by a Vector Processor with: Vector Register File composed of 32 vectors of 16 elements per 32 bits/element; Scalar FP Register File composed of 32 registers of 32 bits; One Load/Store Vector Unit with memory bandwidth 32 bits; One Add/Sub Vector Unit; One Mul/Div Vector Unit. None of the three units has operation chaining.

L.V      V1, RX
ADDVS.D  V1, V1, F0
MULV.D   V2, V1, V1
DIVVS.D  V2, V2, F0
L.V      V3, RY
ADDVV.D  V3, V2, V3
S.V      V2, RZ
S.V      V3, RW

How many clock cycles does the code take?

Show model answer

Without chaining every true dependence ends a convoy, and the chain L.V V1 → ADDVS.D V1 → MULV.D V2 → DIVVS.D V2 → ADDVV.D V3 → S.V V3 has six instructions: 6 convoys. A convoy lasts 16 cycles (16 elements, one 32-bit element per cycle): 6 × 16 = 96 clock cycles.

January 2026 code without chaining (recomputed).
Load/Store Vector UnitMul/Div Vector UnitAdd/Sub Vector Unit
1^ convoyL.V V1, RX
2^ convoyL.V V3, RYADDVS.D V1, V1, F0
3^ convoyMULV.D V2, V1, V1
4^ convoyDIVVS.D V2, V2, F0
5^ convoyS.V V2, RZADDVV.D V3, V2, V3
6^ convoyS.V V3, RW

With chaining, as in the January 2026 paper: 4 convoys, 64 cycles — L.V V1 + ADDVS.D + MULV.D; L.V V3 + DIVVS.D + ADDVV.D; S.V V2; S.V V3.

The code is the January 2026 quiz (notes, p. 501) with chaining removed. Without chaining the floor from the load/store unit (4) is not the answer: the chain of six dependent instructions is longer. Note that the elements are 32 bits here and the bandwidth 32 bits: still one element per cycle.

Lesson 31 · VMIPS and the art of counting convoys: chaining, lanes, lengths, masks and banks · question 7 of 7 · open in the lesson

A vector processor has MVL = 64, 4 lanes, one Load/Store Vector Unit that moves 4 elements per cycle, one MUL/DIV and one ADD/SUB Vector Unit, all with operation chaining. The DAXPY loop Y[i] = a * X[i] + Y[i] runs on n = 1000 elements with strip mining; each strip executes L.V, MULVS.D, L.V, ADDVV.D, S.V. Ignoring start-up and the scalar loop overhead, how many clock cycles does the loop take?

Show model answer

Each strip: 3 convoys (L.V + MULVS.D; L.V + ADDVV.D; S.V). Strips: ⌈1000/64⌉ = 16 — 15 of 64 elements and one of 1000 mod 64 = 40. With 4 lanes a chime takes ⌈VL/4⌉ cycles: 16 for a full strip, 10 for the short one.

\[ T = 15 \times 3 \times 16 + 3 \times 10 \] \[ T = 720 + 30 = 750 \]

750 clock cycles, 0.75 per element.

Two traps: forgetting the short strip (15 × 48 = 720) and charging it a full chime (16 × 48 = 768). Lanes divide the chime, strips multiply the convoys.

Lesson 32 · SIMD today: packed extensions, GPUs, tensor cores and NPUs

Lesson 32 · SIMD today: packed extensions, GPUs, tensor cores and NPUs · question 1 of 5 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used by data-parallel architectures:

  1. SIMD ISA extensions (e.g. SSE/AVX)
  2. Vector length register (VLR) with strip mining
  3. Vector mask registers
  4. Multithreaded SIMD execution in GP-GPUs (warps)
  5. Separate host and device memories in the GP-GPU programming model
  6. Address coalescing in GP-GPUs
  7. Tensor cores
  8. Systolic arrays in Neural Processing Units
Show model answer
  1. A scalar ISA extended with instructions that apply one operation to the elements packed in a wide register (128, 256 or 512 bits: 2, 4 or 8 doubles). Benefits: several data operations per fetched and decoded instruction; cheap to add as extra datapaths in the existing pipeline; little extra state, fed by the caches; available in every CPU, so compilers and libraries use it for media and ML kernels. Limits: the width is fixed in the opcode, so a wider register needs new instructions and recompiled code, leftovers need a scalar remainder loop, and strided/sparse access and masks came late (gather with AVX2, scatter and masks with AVX-512).

  2. VLR holds the number of elements, 0 ≤ VLR ≤ MVL, that every vector instruction processes; MVL is the hardware length of a vector register. Strip mining (a compiler transformation) splits a loop of n iterations into ⌈n/MVL⌉ strips: full strips with VLR = MVL and one strip of n mod MVL. Benefits: one loop handles any n with no remainder loop, nothing beyond the arrays is touched, and the same binary uses more lanes or a longer MVL if the loop takes its strip length from the hardware (ARM SVE, RISC-V V).

  3. A mask register holds one bit per element; a vector compare sets it, and the following vector instructions update only the elements whose bit is 1, leaving the others unchanged (predication). Benefits: loops with if statements stay vectorised, with no branch per element, and masked elements raise no exceptions. Cost: masked elements still use their slot, so an if-else executes both bodies. GPUs do the same per thread (branch divergence).

  4. A GP-GPU streaming multiprocessor is a multithreaded SIMD processor. Threads are grouped into warps of 32; one instruction is fetched per warp and executed in lockstep on the SIMD lanes for all 32 threads, each thread with private registers (SIMT). Many warps are resident; every cycle the warp scheduler issues from a ready one, and since all their registers stay in a large register file, switching costs nothing. Benefits: DRAM latency of hundreds of cycles is hidden by the other warps instead of by caches or out-of-order logic; the programmer writes sequential code for one element; the same kernel scales over any number of SMs.

  5. The CPU (host) and the GPU (device) have separate memory address spaces, physically two DRAMs linked by PCIe/NVLink. The host allocates device memory (cudaMalloc), copies the inputs (cudaMemcpy), launches the kernel and copies the results back. Benefit: the device memory (GDDR/HBM) is built for bandwidth and serves the kernel at full speed. Cost: every transfer crosses the link, so a kernel must do enough work per byte copied; unified memory only automates the migration.

  6. Each thread of a warp computes its own address; the coalescing unit merges the 32 addresses of a warp's load or store into as few wide memory transactions as possible. Consecutive threads touching consecutive words cost one or two transactions — the run-time equivalent of a unit-stride L.V — while column or scattered accesses cost up to 32. Benefit: memory bandwidth is used efficiently without the program stating the stride; it rewards unit-stride data layouts.

  7. A tensor core is a functional unit in each SM that computes D = A × B + C on small matrices as one operation (Volta: 4 × 4, A and B in FP16, accumulation in FP16 or FP32, 64 FMAs per clock), used through a warp-level matrix instruction. Benefits: one instruction for 64 FMAs; each input reused 4 times inside the unit, so less register traffic per flop; reduced precision halves data movement — up to 125 TFLOPS on a V100. Only matrix-shaped, high-intensity work (dense linear algebra, deep learning) gains.

  8. A systolic array is a grid of multiply-accumulate cells in which data moves between neighbours in lockstep, so each operand fetched from memory is used by a whole row or column. In the TPU (256 × 256 8-bit MACs, weight-stationary) the weights stay in the cells, activations flow right and partial sums flow down into accumulators: one activation read feeds 256 MACs. Benefits: very high throughput (92 TOPS) at low energy per operation, simple control, software-managed on-chip memory instead of caches. Limits: only dense matrix work, and a fill/drain latency per stream.

The June 2026 paper asked exactly this form for superscalar techniques: eight sub-points, five lines each. For every point write the mechanism (what the hardware or the compiler does), the benefit, and one cost. Points 2–3 are the notes' own material (lesson 31); points 4–8 are the background of this lesson, which the topic list ("Intro to GP-GPUs; Intro to Tensor Cores", "Intro to Neural Processing Units") makes examinable but the notes do not cover.

Lesson 32 · SIMD today: packed extensions, GPUs, tensor cores and NPUs · question 2 of 5 · open in the lesson

Compare a vector processor (VMIPS-like) and the streaming multiprocessor of a GP-GPU. For each one describe: the main concepts; how the length of a loop is handled; how a conditional statement inside the loop is handled; how memory latency is hidden; the main benefits; the main drawbacks.

Show model answer
Vector processor (VMIPS)GP-GPU streaming multiprocessor
Main conceptsSIMD with one PC; vector registers of MVL = 64 elements; deeply pipelined vector FUs in lanes with chaining; one vector load/store unit; a scalar control processor. One instruction = a whole vector.Multithreaded SIMD: threads grouped in warps of 32; one instruction per warp, executed in lockstep for its 32 threads, each with private registers (SIMT); dozens of resident warps, a warp scheduler issues from a ready one each cycle; a host CPU and a separate device memory.
Loop lengthVLR (≤ MVL) and strip mining: ⌈n/MVL⌉ strips.A grid of n threads in blocks; the tail is masked off by if (i < n); no VLR.
ConditionalsA vector compare sets the mask register; the instructions execute under the mask.Branch divergence: the warp executes both paths, each under a per-thread mask.
Memory latencyPaid once per vector, then one element per cycle from interleaved banks; strided and gather/scatter loads; little or no data cache.Hidden by switching among resident warps, whose registers stay in the register file; coalescing merges a warp's accesses; small caches save bandwidth.
BenefitsFew instructions (DAXPY: 6 instead of 578), no loop overhead, deep pipelines without hazards, energy-efficient, scales with lanes under the same code.Very high throughput on massively parallel work; latency hiding without out-of-order logic; sequential code for one thread; scales with the number of SMs.
DrawbacksOnly vectorisable loops; needs a high-bandwidth memory; masked elements still cost cycles; bank conflicts with bad strides.Divergence and uncoalesced accesses waste lanes; host–device copies; one thread is slow; needs thousands of threads to fill the machine.

The forms of July 2024 (fine-grained vs simultaneous multithreading) and June 2025 (a dual-core chip) were tables with blank lines: one precise line per cell, naming the mechanism and not only the term. The loop-length, conditional and latency rows are the mapping of this lesson — VLR against a masked tail, mask register against divergence, latency amortised by long vectors against latency hidden by warps.

Lesson 32 · SIMD today: packed extensions, GPUs, tensor cores and NPUs · question 3 of 5 · open in the lesson

In the GP-GPU programming model, the CPU (host) and GPU (device) have separate memory address spaces. (True/False)

  • True The host allocates device memory, copies the data in with cudaMemcpy, launches the kernel and copies the results back: two memories, two address spaces.
  • False Unified memory only migrates pages between the two memories automatically; the basic model and the hardware keep two separate memories.
Show model answer

True. The device has its own DRAM; pointers to device memory are valid only on the device, and data moves explicitly (cudaMalloc, cudaMemcpy host to device, kernel launch, cudaMemcpy device to host).

Question 3 of the quizzes of 10 June 2025, word for word — the only GPU question of the three papers. The wrong answer usually comes from unified memory, which automates the copies but does not merge the memories.

Lesson 32 · SIMD today: packed extensions, GPUs, tensor cores and NPUs · question 4 of 5 · open in the lesson

Let's consider the loop for (i=0; i<260; i++) Y[i] = X[i] + Y[i]; compiled for a processor with the AVX-512 SIMD extension (512-bit registers, 64-bit elements), without masked instructions: the leftover elements are handled by a scalar remainder loop. How many SIMD add instructions and how many scalar add instructions are executed? (SINGLE ANSWER)

  • Answer 1: 32 SIMD adds and 4 scalar adds 8 doubles per register: 260 = 32 × 8 + 4.
  • Answer 2: 33 SIMD adds and 0 scalar adds That needs a masked last add, which the question excludes.
  • Answer 3: 65 SIMD adds and 0 scalar adds That is AVX, with 4 doubles per 256-bit register: 260 = 65 × 4.
  • Answer 4: 5 SIMD adds and 0 scalar adds That is the number of strips on VMIPS with MVL = 64, a vector machine, not packed SIMD.
  • Answer 5: 8 SIMD adds and 4 scalar adds 8 is the width of the register, not the number of trips of the loop.
Show model answer

Answer 1. A 512-bit register holds 8 doubles, and 260 = 32 × 8 + 4: the SIMD loop runs 32 times, and the 4 leftover elements go to the scalar remainder loop. With the k-mask registers of AVX-512 the 4 leftovers would take one masked add (33 instructions); on a vector machine the loop is strip-mined with VLR instead (5 strips with MVL = 64).

The same loop as the strip-mining quiz of the papers, on a different machine. The distractors are the counts of the neighbouring machines — 65 for AVX, 33 for the masked version, 5 for the VMIPS strips — in the style the papers build their options.

Lesson 32 · SIMD today: packed extensions, GPUs, tensor cores and NPUs · question 5 of 5 · open in the lesson

Which of the following statements about the streaming multiprocessor of a GP-GPU are true? (MULTIPLE ANSWERS)

  • A warp executes one instruction for its 32 threads in lockstep, each thread with its own registers. SIMT: a warp instruction is a vector instruction of length 32 with per-lane registers.
  • The latency of a DRAM access is hidden mainly by switching to another ready warp. Fine-grained multithreading at no switch cost: the registers of all resident warps stay in the register file.
  • The tail of a loop is handled with a vector length register, as in VMIPS. There is no VLR: the threads with i ≥ n are masked off by the if of the kernel.
  • When the threads of a warp take different paths of an if, both paths are executed, each under a mask. Branch divergence: the vector mask of lesson 31, managed per thread by the hardware.
  • A tensor core performs one fused multiply-add per lane per clock. A tensor core computes D = A × B + C on 4 × 4 matrices: 64 FMAs per clock as one operation.
Show model answer

Answers 1, 2 and 4. A warp is one instruction stream for 32 threads with private registers; latency is hidden by switching warps; divergent paths run one after the other under masks. A GPU has no VLR (the tail is masked), and a tensor core is a matrix unit, not a wider FMA.

The two false options are the traps: carrying the VLR over from the vector machine, and imagining the tensor core as a faster ordinary lane.

To the filters ↑

Module 8 · Multiprocessors and cache coherence

40 questions · Notes, chapter 10 and the past papers · interconnects, shared vs distributed memory, snooping MSI / MESI, directory protocols

Lesson 33 · One machine, many brains: multiprocessors, buses and topologies

Lesson 33 · One machine, many brains: multiprocessors, buses and topologies · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following:

  1. Multiprocessor (tightly coupled, MIMD)
  2. Multicore and manycore processors
  3. Symmetric multiprocessors (SMP)
  4. Large-scale distributed shared-memory multiprocessors
  5. Shared-memory and message-passing communication
  6. Single-bus interconnection
  7. Interconnection networks
  8. Bisection bandwidth
Show model answer

1. A multiprocessor is a computer system with tightly coupled processors coordinated by a single operating system, typically offering a shared address space. Each processor runs its own instruction stream on its own data (MIMD), so the machine exploits thread-level parallelism. Benefits: high throughput on many threads or processes, performance that grows with the number of processors, tolerance of some faults through redundancy, one design from embedded systems to servers. Unlike a cluster, it has one OS and one address space.

2. A multicore puts several cores on the same chip; beyond about 32 cores it is called a manycore. A multicore chip is a small SMP on a chip: private L1/L2 caches, usually a shared last-level cache, uniform access to memory, snooping coherence. Benefit: it turns the transistor budget into throughput through TLP — the industry's answer to the ILP and frequency (power) walls — instead of a wider or faster single core.

3. In an SMP (centralized shared memory) all processors share one physical memory with the same access time for everyone (UMA), usually through a bus; cache coherence is kept by snooping. Benefits: simple, symmetric view for the programmer and the OS, cheap for a few processors. Limit: the shared bus and memory saturate, so SMPs typically stay at or below about 32 processors.

4. In a distributed shared-memory (DSM) multiprocessor the memory is physically distributed among the nodes (processor + caches + local memory module) connected by an interconnection network, but forms one shared address space. Access time is non-uniform (NUMA): local is fast, remote is slower. Benefits: it scales beyond about 32 processors because memory bandwidth grows with the nodes and there is no single memory bottleneck, and it is still programmed with loads and stores. Costs: data placement matters, coherence needs directories, the network is complex.

5. With shared memory, processors communicate implicitly by loads and stores to a common address space: natural to program, but it needs coherence hardware and explicit synchronization (locks, barriers). With message passing, each processor has a private address space and communicates explicitly with send and receive: simpler hardware, explicit control of data movement, harder programming. Both models are Turing complete and each can implement the other, so the choice affects performance, programmability and cost, not what can be computed.

6. All processors, the memory and the I/O share one bus; every memory access (cache miss) is a bus transaction, one at a time. Benefits: cheap, simple, and a broadcast medium — every cache sees every transaction, which snooping coherence needs. Drawback: saturation. If each processor alone uses a fraction d of the bus, throughput grows linearly and then flattens near 1/d processors (commercial systems maxed out at about 36); beyond that, adding a processor only lengthens the queue and slows every access.

7. An interconnection network connects the nodes with many point-to-point links and switches (ring, 2-D mesh, torus, hypercube, crossbar, fat tree), so many transfers proceed in parallel and the bandwidth grows with the system. Benefits: it removes the shared bus from the critical path and scales to hundreds or thousands of processors. Costs: switches and links are expensive, and multiple hops add latency. Networks are compared by total and bisection bandwidth, diameter and node degree.

8. Bisection bandwidth is the minimum, over all cuts that split the network into two halves with equal numbers of nodes, of the total bandwidth of the links crossing the cut. It is the worst case, when half of the nodes communicate with the other half, and it bounds global traffic, while the total bandwidth (M × b, the sum of all links) is the best case for local traffic. Examples: bus b, ring 2b whatever P, 2-D mesh √P·b, hypercube (P/2)·b.

The 2026 paper asks its 8-point question in this form, "Explain the main concepts and benefits of each one of the following …", with five lines for each sub-point; multiprocessors and multicores are an item of the course's topic list. What earns the points: the defining words (tightly coupled, single OS, shared address space, MIMD; UMA and NUMA; implicit versus explicit communication; one transaction at a time; best case versus worst case) and a cost next to every benefit. Sub-point 6 is stronger with the 1/d argument than with the bare number 36.

Lesson 33 · One machine, many brains: multiprocessors, buses and topologies · question 2 of 7 · open in the lesson

Consider a multiprocessor with P = 16 nodes whose interconnection links each have a bandwidth b = 1 GB/s. Complete the following table, then explain which topology you would choose if the 16 processors communicate all-to-all, and why.

TopologyLinksTotal BWBisection BWDiameterPorts per node
Single bus
Ring
2-D mesh (4 × 4)
Hypercube (N = 4)
Fully connected
Show model answer
TopologyNumber of linksTotal bandwidthBisection bandwidthDiameterPorts per node
Single bus1b = 1 GB/sb = 1 GB/s1 (shared)1
RingP = 16P·b = 16 GB/s2b = 2 GB/sP/2 = 82
2-D mesh (4 × 4)2N(N − 1) = 2424 GB/sN·b = 4 GB/s2(N − 1) = 62 to 4
Hypercube (N = 4)NP/2 = 3232 GB/s(P/2)·b = 8 GB/sN = 44
Fully connectedP(P − 1)/2 = 120120 GB/s(P/2)²·b = 64 GB/s115

All-to-all traffic crosses the machine, so it is bounded by the bisection bandwidth, not by the total. The fully connected network has the largest bisection (64 GB/s) and diameter 1, but needs 120 links and 15 ports per node. The hypercube gives 8 GB/s of bisection, so every node can send across the cut at its full link speed (8 GB/s for 8 senders), with only 32 links, 4 ports per node and a diameter of 4: the usual engineering choice at this size. The mesh is cheaper but has half the bisection and diameter 6; the ring and the bus would be throttled to 2 and 1 GB/s.

An exercise in the style of the papers' tables. The two traps: the hypercube bisection (8, not the 6 of the notes' eq. 98) and confusing the total with the bisection when the question is about global traffic. Write the formula before the number in each cell — a correct formula with a slip in the arithmetic is still worth most of the cell.

Lesson 33 · One machine, many brains: multiprocessors, buses and topologies · question 3 of 7 · open in the lesson

A 32-processor distributed shared-memory multiprocessor runs at a clock frequency of 4 GHz. Its base CPI, when every memory reference is satisfied locally, is 0.5. A reference to remote memory takes 100 ns and stalls the processor. If 0.2% of the instructions make a remote reference, what is the CPI of the machine?

Show model answer
\[ T_{CLK} = \frac{1}{4\ \text{GHz}} = 0.25\ \text{ns} \] \[ \text{remote cost} = \frac{100}{0.25} = 400 \text{ cycles} \] \[ CPI = 0.5 + 0.002 \times 400 = 1.3 \]

Without remote references the machine would be 1.3 / 0.5 = 2.6 times faster.

The example comes from Hennessy & Patterson. The marks are in converting the 100 ns into clock cycles (400, not 100 or 0.4) and in weighting the stall by the fraction of instructions that pay it: 0.2% is 0.002, not 0.2.

Lesson 33 · One machine, many brains: multiprocessors, buses and topologies · question 4 of 7 · open in the lesson

You want a speedup of 80 on a multiprocessor with 100 processors. According to Amdahl's law, what is the largest fraction of the original execution time that may remain sequential? Give the answer in percent.

Show model answer
\[ 80 = \frac{1}{(1-F) + F/100} \] \[ 1 - 0.99\,F = 0.0125 \] \[ F = 0.99747, \quad 1 - F \approx 0.25\% \]

The formula sheet's Amdahl's law with S = P. The answer asked for is the sequential fraction 1 − F, not F: answering 99.75% is the classic lost point. The form F = (1 − 1/Speedup)/(1 − 1/S) from lesson 3 gives the same number in one line: 0.9875 / 0.99.

Lesson 33 · One machine, many brains: multiprocessors, buses and topologies · question 5 of 7 · open in the lesson

Which of the following statements about the bisection bandwidth of an interconnection network are true? (Multiple answers)

  • It is the sum of the bandwidths of all the links of the network. That is the total network bandwidth, M × b: the best case, not the worst.
  • It is the minimum bandwidth across any cut that divides the nodes into two equal halves. This is the definition: the narrowest balanced cut decides.
  • For a ring it is 2b regardless of the number of nodes. The cheapest balanced cut, into two arcs, crosses the loop exactly twice, whatever P.
  • For a single bus it equals the total network bandwidth. The bus is one link: total and bisection are both b.
  • For a √P × √P mesh it grows linearly with P. It grows as √P: the cut is one column of N = √P links.
Show model answer

Answers 2, 3 and 4. Answer 1 describes the total bandwidth; the mesh bisection is N·b = √P·b, which grows as the square root of P.

The family of statements mixes the two metrics on purpose. Check each against the ring and the bus, the two cases you can draw in a second.

Lesson 33 · One machine, many brains: multiprocessors, buses and topologies · question 6 of 7 · open in the lesson

A hypercube interconnects P = 64 nodes with links of bandwidth b = 1 GB/s. What is its bisection bandwidth? (Single answer)

  • 10 GB/s That is 2(N − 1)·b with N = 6, the slip of the notes' eq. (98). The cut severs one link per pair of twins.
  • 12 GB/s That is 2N·b, a formula with no derivation behind it. Count instead: the cut along the top address bit severs one link per pair of twins, 32 links.
  • 32 GB/s (P/2)·b = 2^(N−1)·b: cutting along the top address bit severs the 32 links that join the two 5-cubes.
  • 64 GB/s That would be one link per node crossing; each crossing link joins two nodes, so it is P/2, not P.
  • 192 GB/s That is the total bandwidth, N·P/2·b = 6 · 32.
Show model answer

Answer 3: N = log₂64 = 6, bisection = 2^(N−1)·b = (P/2)·b = 32 GB/s; the total is N·P/2·b = 192 GB/s.

The distractors are the notes' wrong formula (10), the total (192) and a double count (64). The quickest route is the doubling picture: a 6-cube is two 5-cubes joined by 32 links.

Lesson 33 · One machine, many brains: multiprocessors, buses and topologies · question 7 of 7 · open in the lesson

In a single-bus multiprocessor, each processor running alone keeps the bus busy 4% of the time. True or false: however many processors are attached, the machine cannot deliver more than the throughput of 25 such processors running alone.

  • True The bus can be busy at most 100% of the time, so it carries the traffic of at most 1 / 0.04 = 25 processors; past that, extra processors only queue.
  • False Adding processors adds demand, not bus capacity: the throughput flattens at 1/d = 25 processors' worth.
Show model answer

True. Throughput ≤ bus capacity / demand per processor = 1 / 0.04 = 25 processors' worth; near that point the bus is saturated and every further processor only lengthens the queue for the bus.

The ceiling is capacity divided by demand, the same argument that gives the notes' ≈ 36. Halve the traffic per processor (bigger caches) and the ceiling doubles.

Lesson 34 · Where does the memory live? UMA, NUMA, DSM, clusters and programming models

Lesson 34 · Where does the memory live? UMA, NUMA, DSM, clusters and programming models · question 1 of 6 · open in the lesson

(SINGLE ANSWER) What type of multiprocessor architecture does the following picture represent?

N0 N3 P0 P3 C0 C3 MM0 MM3 P0, P1, P2, P3 P0, P1, P2, P3 … … …
The picture of the quiz, redrawn: N0 … N3, each with a processor, a cache and a memory module; every memory module is labelled P0, P1, P2, P3.
  • Answer 1: Centralized Memory; Single Logically Shared Address Space There is no central memory: every node has its own module, MM0 … MM3.
  • Answer 2: Centralized Memory; Message Passing Architectures Wrong on both axes: the memory is in the nodes, and the labels say that every processor addresses every module.
  • Answer 3: Distributed Memory; Single Logically Shared Address Space One memory per node (distributed), each addressable by P0–P3 (one shared address space): a DSM, also called NUMA.
  • Answer 4: Distributed Memory; Message Passing Architectures The memory is distributed, but with message passing each module would answer to its own processor only; here every module lists P0, P1, P2, P3.
Show model answer

Answer 3. Each node contains its own processor, private cache and memory module, so the memory is physically distributed and there is no single central memory: Answers 1 and 2 are wrong. Each memory module is annotated with P0, P1, P2, P3: every processor can access every module with ordinary loads and stores, so the memories form a single logically shared address space and Answer 4 is wrong. This is a Distributed Shared Memory (DSM) architecture, also known as NUMA.

This is the quiz of the 8 January 2026 paper as the notes reproduce it (p. 505), options verbatim; the notes' answer, 3, is correct. Read the picture in two moves: count the memories for the column, read the labels for the row. If the paper asks you to motivate, one sentence per axis is the whole answer.

Lesson 34 · Where does the memory live? UMA, NUMA, DSM, clusters and programming models · question 2 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following organizations and models used in multiprocessors: 1. Shared address space; 2. Private address spaces (message passing); 3. Centralized shared-memory multiprocessors (UMA / SMP); 4. Distributed shared-memory multiprocessors (NUMA / DSM); 5. Home node of a block in a DSM; 6. Small-scale multicores; 7. Distributed-memory clusters; 8. Data-parallel (SPMD) programming model. (Five lines each.)

Show model answer

1. All processors see one logical memory: an address names the same location for every processor, any processor can load or store any address, and communication is implicit (one processor stores, another loads). Programmed with threads (Pthreads, OpenMP). Benefits: easy to program, handles irregular and dynamic sharing, low latency for small items, caches reduce remote traffic automatically. Costs: complex hardware (cache coherence), synchronization with locks and barriers, little control of data placement.

2. Each processor has its own address space: the same address names different locations on different processors, no load or store crosses processors, and data moves by explicit send/receive (MPI_Send / MPI_Recv). Benefits: simple hardware with no coherence protocol, the programmer sees when and how much data moves, every send/receive synchronizes, explicit placement, fault isolation. Costs: harder programming, high overhead for fine-grain sharing, data decomposed by hand.

3. One centralized physical memory shared by all processors, with the same latency and bandwidth whichever processor accesses it (symmetric). Processors with private caches, possibly a shared L3, reach it through a bus or crossbar; coherence by snooping. Benefits: the simplest programming (no data placement), sequential code ports easily, a uniform view for the OS. Limit: the single memory and interconnect saturate under contention, about 32 processors in classic designs.

4. Memory physically distributed: each node is processor(s) + caches + a local memory module, and the nodes are joined by a scalable interconnection network. The union of the local memories is one global address space, so programs still use loads and stores. The access time depends on whether the address is in the local module (fast) or in a remote node (slower). Benefits: scales to hundreds of cores, aggregate memory bandwidth grows with the nodes. Costs: performance depends on data placement; a scalable network and directory-based coherence are needed.

5. The home node of a block is the node whose main memory holds it, fixed by the physical address (if every node owns 4 KiB, N2 owns 0x2000–0x2FFF and the block of 0x2200 is homed in N2). In a directory protocol it also keeps the block's directory entry (state and sharer bits), stored with the block in its memory, so every request for the block goes through it. The local node is the node that issues the request. Benefit: the data and its coherence information are found from the address alone, without broadcasts.

6. A multicore chip with a few cores (up to about 8, sometimes 16) is an SMP on a chip: identical cores, uniform access to one main memory, one shared-memory machine for the OS. Private L1 and L2 caches per core hold the working sets and reduce contention; a shared L3 cuts DRAM traffic and is where shared data meets; coherence by snooping on the shared bus. Beyond about 8 cores the L3 is split into banks and the bus becomes a network-on-chip (mesh, ring, crossbar), so several requests are served in parallel.

7. A set of independent computers, each with its own processors, private memory, local disk and OS instance, connected by a network (Ethernet, InfiniBand); no shared address space, communication by explicit message passing with MPI. Benefits: scales to tens of thousands of nodes, memory grows linearly with the nodes, commodity hardware is cheap, one node can fail without crashing the system. Costs: harder programming (partition the data, orchestrate the messages), network latency much higher and bandwidth lower than local DRAM, synchronization at every send/receive.

8. All processors run the same program, each on its own portion of the data (Single Program, Multiple Data): adding two 1000-element vectors, Proc 0 takes indices 0–249, …, Proc 3 750–999. Execution proceeds in bulk-synchronous phases: local computation, global communication or a barrier, next phase (Valiant's BSP model). Benefits: one simple program, high scalability for large and evenly split data, efficient on GPUs and vector units. Costs: load imbalance and stragglers stall everyone at the barrier; it suits regular array computations, not trees or graphs.

The form is the June 2026 question: eight sub-points, about five lines each. Give three things in each: what it is, one concrete detail (a number, an example, an API) and the benefit with its cost. Sub-points 3 and 4 are best written as a pair, uniform against non-uniform latency; sub-point 5 is the July 2024 question "What is the definition of home node?".

Lesson 34 · Where does the memory live? UMA, NUMA, DSM, clusters and programming models · question 3 of 6 · open in the lesson

Consider a distributed shared memory system with 4 nodes (N0, N1, N2, N3); each node has a processor Pi, a cache Ci and a main memory MMi, and the nodes are connected by an interconnection network. Each node owns 4 KiB of the physical addresses: N0 from 0x0000 to 0x0FFF, N1 from 0x1000 to 0x1FFF, N2 from 0x2000 to 0x2FFF, N3 from 0x3000 to 0x3FFF. Processor P0 executes LD F2, 0(R1) with R1 = 0x2200 and misses in C0; no other cache holds a copy of the block.

1. What is the definition of home node? Which node is the home node of this access? 2. Which node is the local node? 3. Describe the path of the request and of the data. 4. What changes, and what does not change, if R1 = 0x0200?

Show model answer

1. The home node of a block is the node whose main memory holds the block; it is fixed by the physical address, and in a directory protocol it also keeps the block's directory entry, so every request for the block goes through it. 0x2200 lies in 0x2000–0x2FFF: the home node is N2.

2. The local node is the node whose processor issues the request: N0.

3. C0 misses; the request leaves N0 and the interconnection network routes it, by address, to N2; MM2 supplies the block (offset 0x200 in its range); the data travels back to N0, is written into C0, and the load completes into F2. It is a remote access: two network crossings and a longer latency than a local access.

4. With 0x0200 the home is N0 itself: home and local coincide, and the miss is served by MM0 without using the network, with the shorter local latency. The program does not change — the same instruction in the same address space; only the latency changes.

Sub-question 1 is the July 2024 question word for word. In the directory exercises a third role appears, the remote node: a node that holds a cached copy of the block (lesson 37). Here no other cache holds a copy, so there is none; do not call N2 "remote" in that exercise vocabulary.

Lesson 34 · Where does the memory live? UMA, NUMA, DSM, clusters and programming models · question 4 of 6 · open in the lesson

Let us consider a distributed shared-memory multiprocessor with 4 nodes (N0, N1, N2, N3) and a clock frequency of 1 GHz. With all memory references hitting in the caches, the CPI is 1. 0.5% of the instructions miss in the cache, and the processor stalls until the miss is served: 80 ns when the home node of the block is the local node, 240 ns when it is another node. Case A: the data of the program are interleaved evenly over the four nodes. Case B: the operating system places the data so that 75% of the misses find their block in the local node. How much is the speed up of case B over case A in terms of CPI?

Show model answer

With \(T_{CLK} = 1\) ns, a local miss costs 80 clock cycles and a remote miss 240. Case A: a quarter of the blocks are homed in the local node, so the average miss penalty and the CPI are

\[ 0.25 \times 80 + 0.75 \times 240 = 200 \] \[ CPI_A = 1 + 0.005 \times 200 = 2 \]

Case B:

\[ 0.75 \times 80 + 0.25 \times 240 = 120 \] \[ CPI_B = 1 + 0.005 \times 120 = 1.6 \]

Speed up in terms of CPI:

\[ \frac{CPI_A}{CPI_B} = \frac{2}{1.6} = 1.25 \]

The same program on the same machine runs 25% faster only because of where its data are placed.

Not a past-paper exercise: it is the formula sheet's CPI with stalls (CPI = 1 + stall cycles per instruction) with the average miss latency of section 3 as the penalty, asked the way the 2025 performance exercise and the 2026 VLIW exercise ("How much is the speed up in terms of CPI?") ask. The two traps: 0.5% is 0.005, and with four nodes an even spread makes only a quarter of the misses local, not half. Lesson 33 works Hennessy & Patterson's version: 0.2% of the instructions make a remote reference of 400 cycles, and a CPI of 0.5 becomes 1.3.

Lesson 34 · Where does the memory live? UMA, NUMA, DSM, clusters and programming models · question 5 of 6 · open in the lesson

(MULTIPLE ANSWERS) Which of the following statements about a distributed shared-memory (DSM, cc-NUMA) multiprocessor are true?

  • Answer 1: Any processor can access any memory location with ordinary load and store instructions. The single global address space: the hardware routes the access to the home node.
  • Answer 2: Processors on different nodes must exchange explicit messages (send/receive) to share data. That is a cluster. In a DSM a load or a store suffices.
  • Answer 3: The access time depends on whether the address belongs to the local memory module or to a remote node. Non-uniform memory access: local inside the node, remote across the network.
  • Answer 4: Each node runs its own instance of the operating system. A DSM is one machine with one OS; an OS instance per node is the mark of a cluster.
  • Answer 5: Cache coherence is typically maintained by a directory stored alongside each memory block. Snooping a network does not scale; the directory notifies only the caches that hold a copy (p. 435).
Show model answer

Answers 1, 3 and 5. A DSM has physically distributed memory, a single logically shared address space reached by loads and stores, non-uniform latency, and directory-based coherence. Answers 2 and 4 describe a distributed-memory cluster.

A multiple-answer quiz as in June 2026. The two wrong options are the cluster's features; sort each option by asking "load/store or send/receive?".

Lesson 34 · Where does the memory live? UMA, NUMA, DSM, clusters and programming models · question 6 of 6 · open in the lesson

(True/False) In a distributed-memory cluster programmed with MPI, a process can read a variable of a process running on another node with an ordinary load instruction.

  • True Each node has its own private address space; the memory of another node is out of reach of loads and stores.
  • False Right: the variable must be requested and sent as a message (MPI_Send / MPI_Recv).
Show model answer

False. In a cluster every node has its own private memory and address space, and the memory of one node cannot be accessed directly by another node via loads and stores; data moves only through explicit messages, with MPI_Send and MPI_Recv.

The true/false form of June 2025. The same statement is true for a DSM; the word "cluster" decides.

Lesson 35 · The day the caches disagreed: coherence, snooping and the MSI machine

Lesson 35 · The day the caches disagreed: coherence, snooping and the MSI machine · question 1 of 6 · open in the lesson

Explain the main concepts and benefits of each one of the following techniques used to keep the private caches of a shared-memory multiprocessor coherent:

1. Caching of shared data (migration and replication); 2. Cache coherence; 3. Memory consistency; 4. Write-invalidate protocol; 5. Write-update protocol; 6. Snooping protocol; 7. Duplicate snoop tags; 8. MSI protocol.

Show model answer

1. A private cache keeps a copy of a block next to the core. For shared data it gives migration — the block moves to the cache of the core using it, so accesses no longer go to memory or over the interconnect — and replication — a read-shared block gets a copy in every reader's cache, so readers do not contend for one copy. Benefit: lower latency, less bus and memory traffic. Cost: several copies of one block, hence the coherence problem.

2. A memory system is coherent if (1) a processor that writes X and then reads X, with no other write in between, reads its own value; (2) a read of X by P2 after a write by P1 returns P1's value if enough time has passed and no other write intervened; (3) writes to the same location are serialized: all processors see them in the same order. It concerns one location at a time.

3. Consistency defines when a write becomes visible to the other processors and in which order loads and stores to different addresses may be observed. Example: P0 writes A = 1 then B = 2, P1 reads B then A: sequential consistency forbids reading B = 2 and A = 0, relaxed models allow it. A coherent memory need not be sequentially consistent.

4. Before writing a shared block, the writer broadcasts an invalidate; all other copies become Invalid and the writer gets exclusive ownership. Further writes are local and silent until another processor requests the block; that processor misses and gets the data from the owner or from memory. Benefit: traffic only on the first write — the choice of almost all modern multiprocessors, with write-back caches.

5. Every write broadcasts the new value to all caches holding the block (and usually to memory), which update their copies. Benefit: readers never miss and never see stale data. Cost: one bus transaction per write, also for repeated writes to one word or to the words of one block, so it wastes bandwidth; it pays off only for producer–consumer sharing.

6. The caches share a bus, which is a broadcast medium: every cache controller monitors every transaction and reacts if it holds the block (invalidates it or supplies the data). No central directory; one transaction informs all caches; the bus order serializes the writes. Suitable for small symmetric (UMA) multiprocessors; it does not scale, because broadcast traffic, electrical load and serialization grow with the number of processors.

7. A second copy of the cache's tag array — tag and coherence state, no data — used only by the snooper. Bus transactions are checked there while the processor keeps using the main tags, so snooping does not stall the pipeline: it removes the structural hazard on the tag array. Cost: area, and both copies must be updated together.

8. Each block is Modified (only copy, dirty), Shared (clean, possibly in other caches) or Invalid. A read miss puts a Read Miss on the bus (→ S), a write miss a Write Miss (→ M), a write hit in S an Invalidate (→ M); read hits and write hits in M are silent. A snooped Read Miss turns M into S with a write-back; a snooped Write Miss turns S or M into I (M supplies the block and writes it back first); a snooped Invalidate turns S into I. A replaced Modified block is written back, a replaced Shared block leaves silently.

This is the format of the 8-point question of the 22 June 2026 paper, with about five lines per sub-point. Each line should name the mechanism and its benefit; points 4–6 together answer the snooping half of Question 1 of the January 2026 paper as the notes reproduce it (pp. 495–497). The usual slip is in point 2: "every processor sees a write immediately" — the definition says "after enough time", and the timing belongs to consistency.

Lesson 35 · The day the caches disagreed: coherence, snooping and the MSI machine · question 2 of 6 · open in the lesson

Let's consider a single-chip dual-core shared-memory architecture where each core is a dual-issue superscalar processor with multi-threading up to 2 threads per core. Explain the preferred technique used to manage the cache coherency problem in the dual core chip.

Show model answer

A snooping, write-invalidate protocol with write-back caches (MSI, in practice MESI). The private caches of the two cores sit on a shared on-chip bus that acts as a broadcast medium: each cache controller monitors every transaction, with duplicate snoop tags, and keeps a coherence state per block. Before a core writes a block that the other core may hold, it broadcasts an invalidate, so the other copy becomes Invalid and later writes stay local. A read miss on a block that the other cache holds Modified is served by that cache, which writes the block back and goes to Shared. With two cores the broadcast is cheap and the bus serializes the writes, so no directory is needed — directories are for many nodes with distributed memory.

This is the last row of Question 2 (5 points in all) of the 10 June 2025 paper. A good answer names snooping, write-invalidate and write-back, and gives the reason: two cores on one chip share a broadcast medium. Naming MESI, the refinement of lesson 36, adds precision; a directory answers a different machine.

Lesson 35 · The day the caches disagreed: coherence, snooping and the MSI machine · question 3 of 6 · open in the lesson

Let's consider the following access patterns on a dual processor system with a direct-mapped, write-back cache with one cache block per processor and a two cache block memory. Assume the MSI protocol is used, with write-back caches, write-allocate, and write-invalidate of other caches. Please complete the following table. How many times is a block written back to memory, and in which cycles?

CycleAfter OperationP0 cache block stateP1 cache block stateMemory at bl. 0 up to date?Memory at bl. 1 up to date?
0P0: Read Bl. 0Shared (0)InvalidYesYes
1P1: Read Bl. 0
2P1: Write Bl. 0
3P1: Write Bl. 0
4P0: Read Bl. 0
5P0: Write Bl. 1
6P1: Read Bl. 1
7P1: Write Bl. 0
8P1: Read Bl. 1
9P0: Write Bl. 1
10P1: Write Bl. 1
Show model answer
CycleAfter OperationP0 cache block stateP1 cache block stateMemory at bl. 0 up to date?Memory at bl. 1 up to date?Bus transaction (comment)
0P0: Read Bl. 0Shared (0)InvalidYesYesRead Miss; memory supplies
1P1: Read Bl. 0Shared (0)Shared (0)YesYesRead Miss; memory supplies
2P1: Write Bl. 0InvalidMod (0)NoYeswrite hit in S: Invalidate
3P1: Write Bl. 0InvalidMod (0)NoYeswrite hit in M: none
4P0: Read Bl. 0Shared (0)Shared (0)YesYesRead Miss; P1 supplies and writes back
5P0: Write Bl. 1Mod (1)Shared (0)YesNoP0 drops Shared (0) silently; Write Miss
6P1: Read Bl. 1Shared (1)Shared (1)YesYesP1 drops Shared (0) silently; Read Miss; P0 supplies and writes back
7P1: Write Bl. 0Shared (1)Mod (0)NoYesP1 drops Shared (1) silently; Write Miss
8P1: Read Bl. 1Shared (1)Shared (1)YesYesP1 writes back block 0 (replacement); Read Miss; memory supplies
9P0: Write Bl. 1Mod (1)InvalidYesNowrite hit in S: Invalidate
10P1: Write Bl. 1InvalidMod (1)YesNoWrite Miss; P0 supplies, writes back, invalidates

Four write-backs: cycles 4 and 6 (a Modified block answers a Read Miss: M → S), cycle 8 (a Modified block is replaced: M → I) and cycle 10 (a Modified block answers a Write Miss: M → I).

The wording is that of the MESI tables of the papers (Exercise 3 of January 2026 as the notes reproduce it, Quiz 7 of June 2026) with MSI in place of MESI. The traps: the silent write hit in M (cycle 3); the owner's write-back that turns "up to date" back to Yes (cycles 4, 6); the silent eviction of a Shared block, which leaves the other copy untouched (cycles 5–7); the write-back on the replacement of a Modified block (cycle 8). The four write-backs cover all three ways of leaving M. Under MESI (lesson 36) only cycle 0 would change: Excl (0).

Lesson 35 · The day the caches disagreed: coherence, snooping and the MSI machine · question 4 of 6 · open in the lesson

Processors P0 and P1 both hold block X in their write-back caches. P0 then writes X ten times in a row, while P1 does not access it. How many coherence transactions appear on the bus under a write-invalidate protocol and under a write-update protocol?

  • 10 and 10 Invalidate pays only for the first write: afterwards P0 owns the block and the other nine writes are silent hits.
  • 1 and 10 One Invalidate, then nine silent hits in M; update must broadcast each of the ten new values because P1 still holds a copy.
  • 10 and 1 The other way round: update cannot batch writes, every new value must reach P1's copy.
  • 0 and 0 P1 holds a copy, so at least the first write must invalidate or update it; otherwise P1 could read a stale value.
Show model answer

Answer: 1 and 10. Write-invalidate sends one invalidation for the first write; the block is then exclusively owned and the remaining writes are local. Write-update broadcasts every write.

This is the first of Hennessy & Patterson's three characteristics, in numbers, and the slope of the traffic meter. A "motivate your answer" line would be: invalidation is per block and per ownership, update per write.

Lesson 35 · The day the caches disagreed: coherence, snooping and the MSI machine · question 5 of 6 · open in the lesson

How does an MSI write-invalidate write-back protocol manage a Write Hit on a cache block which is Shared in another cache? (Multiple answers.)

  • The status of the cache block becomes Modified S → M: after the write this cache holds the only, dirty copy.
  • The cache block is retrieved from memory It is a hit: the data is already in the cache, nothing is fetched.
  • The cache block is retrieved from another cache Same reason: a write hit needs permission, not data.
  • An invalidate is broadcasted on the bus to the other copies of the block The other sharer must drop its copy: that is the S → M arrow, PrWr / Invalidate.
  • The cache block is overwritten in the processor's cache Write-back: the new value goes into the cache line only, and memory becomes stale.
Show model answer

Answers 1, 4 and 5: an invalidate is broadcast, the block is written in the cache and becomes Modified; nothing is retrieved because the block is already present.

Quiz 2 of the 22 June 2026 paper asks exactly this for MESI, and in MESI the answer is the same. Its Quiz 1 — a write hit on an Exclusive block — needs the E state of lesson 36.

Lesson 35 · The day the caches disagreed: coherence, snooping and the MSI machine · question 6 of 6 · open in the lesson

True or false: in an MSI snooping protocol with write-back caches, after a cache that holds a block in Modified state answers another processor's read miss, main memory holds an up-to-date copy of the block.

  • True The owner supplies the block and memory takes it from the bus: M → S with a write-back. Both copies are Shared, that is clean.
  • False Memory could stay stale only if a dirty block could be shared, which needs the Owned state of MOESI. In MSI a Shared copy is clean by definition.
Show model answer

True. On the snooped read miss the Modified copy is written back while it is supplied; both caches end in Shared and memory is up to date.

Row 3 of the table in Quiz 7 of the 22 June 2026 paper — one of its correct rows — prints exactly this: P3 reads block 0 while P1 holds it Modified, and "Memory at bl. 0 up to date?" becomes Yes. The notes argue the opposite on p. 455; see the red pen in section 5.

Lesson 36 · The E in MESI, and the exam table

Lesson 36 · The E in MESI, and the exam table · question 1 of 7 · open in the lesson

Exercise 3 — MESI protocol (January 2026 paper, as transcribed in the notes, p. 493). Let's consider the following access patterns on a dual processor system with a direct-mapped, write-back cache with one cache block per processor and a two cache block memory. Assume the MESI protocol is used, with write-back caches, write-allocate, and write-invalidate of other caches. Please complete the following table:

TAfter OperationP0 cache block stateP1 cache block stateMemory at block 0 up to date?Memory at block 1 up to date?
0P0: read block 1Excl (1)InvalidYesYes
1P1: write block 0
2P0: write block 0
3P1: read block 0
4P0: read block 1
5P1: read block 1
6P0: read block 1
7P1: write block 1
8P0: read block 0
9P1: write block 1
10P1: write block 1
11P0: read block 1
12P1: write block 1
13P0: write block 1
14P1: read block 1
Show model answer
TAfter OperationP0 cache block stateP1 cache block stateMemory at block 0 up to date?Memory at block 1 up to date?
0P0: read block 1Excl (1)InvalidYesYes
1P1: write block 0Excl (1)Mod (0)NoYes
2P0: write block 0Mod (0)InvalidNoYes
3P1: read block 0Shared (0)Shared (0)YesYes
4P0: read block 1Excl (1)Shared (0)YesYes
5P1: read block 1Shared (1)Shared (1)YesYes
6P0: read block 1Shared (1)Shared (1)YesYes
7P1: write block 1InvalidMod (1)YesNo
8P0: read block 0Excl (0)Mod (1)YesNo
9P1: write block 1Excl (0)Mod (1)YesNo
10P1: write block 1Excl (0)Mod (1)YesNo
11P0: read block 1Shared (1)Shared (1)YesYes
12P1: write block 1InvalidMod (1)YesNo
13P0: write block 1Mod (1)InvalidYesNo
14P1: read block 1Shared (1)Shared (1)YesYes

Bus activity, for checking: Read Miss at T = 0, 3, 4, 5, 8, 11, 14; Write Miss at 1, 2, 13; Invalidate at 7, 12; write-backs at 2, 3, 11, 13, 14; silent replacements at 2, 4, 5, 11; nothing at 6, 9, 10.

Three groups of cells need the most care. T = 4: P1 stays Shared (0), because the silent replacement of P0's clean copy is invisible to it — the notes print Excl(0) there. T = 2 and 13: memory is No although the old owner wrote back, because the new owner writes at once. T = 3, 11 and 14: memory returns to Yes after a snooped read of a Mod block. Write each state as the paper does, state and block in brackets, and Invalid with no block.

Lesson 36 · The E in MESI, and the exam table · question 2 of 7 · open in the lesson

Let's consider the following access patterns on a 4-processor system with a direct-mapped, write-back cache with one cache block per processor and a two-cache block memory. Assume the MESI protocol is used, with write-back caches, write-allocate, and write-invalidate of other caches. All caches are initially Invalid. Please complete the following table:

CycleAfter OperationP0 cache block stateP1 cache block stateP2 cache block stateP3 cache block stateMemory at bl. 0 up to date?Memory at bl. 1 up to date?
1P0: Read Bl. 0
2P1: Read Bl. 0
3P1: Write Bl. 0
4P2: Read Bl. 0
5P2: Write Bl. 1
6P1: Write Bl. 0
7P1: Read Bl. 1
8P3: Write Bl. 1
Show model answer
CycleAfter OperationP0 cache block stateP1 cache block stateP2 cache block stateP3 cache block stateMemory at bl. 0 up to date?Memory at bl. 1 up to date?
1P0: Read Bl. 0Excl (0)InvalidInvalidInvalidYesYes
2P1: Read Bl. 0Shared (0)Shared (0)InvalidInvalidYesYes
3P1: Write Bl. 0InvalidMod (0)InvalidInvalidNoYes
4P2: Read Bl. 0InvalidShared (0)Shared (0)InvalidYesYes
5P2: Write Bl. 1InvalidShared (0)Mod (1)InvalidYesNo
6P1: Write Bl. 0InvalidMod (0)Mod (1)InvalidNoNo
7P1: Read Bl. 1InvalidShared (1)Shared (1)InvalidYesYes
8P3: Write Bl. 1InvalidInvalidInvalidMod (1)YesNo

Row 3: write hit in Shared, an Invalidate takes P0 to Invalid. Row 4: P1 writes block 0 back on P2's Read Miss. Row 5: P2's clean Shared (0) leaves silently, so P1 is left as the only holder of block 0 — still Shared. Row 6: P1 therefore broadcasts an Invalidate that nobody needs before going to Mod (0). Row 7: two write-backs in one row — P1 replaces its dirty block 0 (memory at bl. 0 back to Yes), and P2 writes block 1 back on P1's Read Miss. Row 8: the Write Miss invalidates both Shared (1) copies.

A drill in the exact format of the papers, built to contain the two cases their sequences avoid: a lone Shared copy that must still invalidate (row 6) and the replacement of a dirty block (row 7). The exam-table trainer of section 4 produces more drills of this kind (its "random drill").

Lesson 36 · The E in MESI, and the exam table · question 3 of 7 · open in the lesson

(June 2026, Question 1) How does a MESI write-invalidate write-back protocol manage a Write Hit on an Exclusive cache block? (MULTIPLE ANSWERS)

  • Answer 1: The status of the cache block becomes Modified Right: after any write the line is dirty, so E becomes M.
  • Answer 2: The cache block is retrieved from memory It is a hit: the block is already in the cache, and clean.
  • Answer 3: The cache block is retrieved from another cache No other cache holds it — that is what Exclusive means.
  • Answer 4: An invalidate is broadcasted on the bus to the other copies of the block There are no other copies: E → M is silent, and that is the whole point of the E state.
  • Answer 5: The cache block is overwritten in the processor's cache Right: with write-back the write updates the local copy only.
Show model answer

Answers 1 and 5. The block is present and clean and no other cache holds it, so the write is performed in the local cache and the state changes from Exclusive to Modified with no bus transaction: nothing is retrieved and nothing is invalidated.

The question tests the one advantage of MESI over MSI. Ticking Answer 4 is the classic mistake: it describes a write hit on a Shared block, which is the next question of the same paper.

Lesson 36 · The E in MESI, and the exam table · question 4 of 7 · open in the lesson

(June 2026, Question 2) How does a MESI write-invalidate write-back protocol manage a Write Hit on a cache block which is Shared in another cache? (MULTIPLE ANSWERS)

  • Answer 1: The status of the cache block becomes Modified Right: the writer ends with the only, dirty copy.
  • Answer 2: The cache block is retrieved from memory It is a hit: the data is already in the writer's cache.
  • Answer 3: The cache block is retrieved from another cache Same reason: nothing has to be fetched on a hit, only permission is missing.
  • Answer 4: An invalidate is broadcasted on the bus to the other copies of the block Right: the other Shared copies must become Invalid before the write.
  • Answer 5: The cache block is overwritten in the processor's cache Right: the write goes into the local copy (write-back).
Show model answer

Answers 1, 4 and 5. The block is present but not exclusive: the cache broadcasts an invalidate on the bus, the other copies become Invalid, the block is written in the local cache and its state becomes Modified. No data is transferred, because the writer already has the block.

Questions 1 and 2 of the paper differ in one answer, the invalidate. Answers 2 and 3 are the distractors for both: they belong to a miss, not to a hit.

Lesson 36 · The E in MESI, and the exam table · question 5 of 7 · open in the lesson

(June 2026, Question 7) Let's consider the following access patterns on a 4-processor system with a direct-mapped, write-back cache with one cache block per processor and a two-cache block memory. Assume the MESI protocol is used, with write-back caches, write-allocate, and write-invalidate of other caches.

CycleAfter OperationP0 cache block stateP1 cache block stateP2 cache block stateP3 cache block stateMemory at bl. 0 up to date?Memory at bl. 1 up to date?
0P0: write Bl. 1Mod (1)InvalidInvalidInvalidYesNo
1P1: Write Bl. 0Mod (1)Mod (0)InvalidInvalidNoNo
2P2: Write Bl. 1InvalidMod (0)Mod (1)InvalidNoNo
3P3: Read Bl. 0InvalidShared (0)Mod (1)Shared (0)YesNo
4P0: Read Bl. 1Shared (1)Shared (0)Shared (1)Shared (0)YesYes
5P2: Write Bl. 0Shared (1)Shared (0)Mod (0)Shared (0)NoYes

Which is the wrong line? (SINGLE ANSWER) Motivate your answer.

  • Answer 1: Line 1 Correct as printed: P1's write miss finds no other copy of block 0 and takes Mod (0); P0's Mod (1) is another block. Memory: No, No.
  • Answer 2: Line 2 Correct as printed: P0 writes block 1 back and is invalidated, P2 takes Mod (1), and memory at bl. 1 is No again because P2 writes.
  • Answer 3: Line 3 Correct as printed: P1 writes block 0 back on P3's Read Miss and both end Shared (0); memory at bl. 0 is Yes.
  • Answer 4: Line 4 Correct as printed: P2 writes block 1 back on P0's Read Miss, both end Shared (1), memory at bl. 1 is Yes.
  • Answer 5: Line 5 Wrong line: P2's write miss on block 0 must invalidate the Shared (0) copies of P1 and P3.
Show model answer

Answer 5 (Line 5). P2 holds Shared (1), which it replaces silently (clean). Its write on block 0 is a write miss: the write-invalidate protocol places a Write Miss on the bus and every other copy of block 0 must become Invalid, so P1 and P3 cannot remain Shared (0). P2 ends in Mod (0), memory at bl. 0 is not up to date and memory at bl. 1 is. The correct line is:

CycleAfter OperationP0 cache block stateP1 cache block stateP2 cache block stateP3 cache block stateMemory at bl. 0 up to date?Memory at bl. 1 up to date?
5P2: Write Bl. 0Shared (1)InvalidMod (0)InvalidNoYes

The paper leaves an empty row under the motivation lines: that is where the corrected line goes, and writing it is the quickest motivation. Lines 2–4 are the ones that look suspicious and are right — each relies on a write-back that turns the memory column, so check the memory cells with the rule "No exactly while some cache holds the block in Mod".

Lesson 36 · The E in MESI, and the exam table · question 6 of 7 · open in the lesson

(January 2026, Question 1, as transcribed in the notes, p. 495) Let's consider the SNOOPING and the DIRECTORY-BASED protocols used to maintain the cache coherence in modern multiprocessor. Answer the following questions: (a) Explain the main characteristics of each protocol. (b) For which type of multiprocessor architecture is each protocol suitable for? (c) What are the main benefits of each protocol? (d) Explain the two types of Snooping protocol depending on what happens on a write operation. (e) What are the possible coherence states of a block in the home directory and the meaning of the sharer bits?

Show model answer

(a) Snooping: the caches share a broadcast medium, usually a bus. Every coherence request (read miss, write miss, invalidate) is broadcast; every cache controller snoops it, checks its own tags and acts locally — it invalidates its copy, writes a dirty copy back or downgrades it. There is no central record of who holds what, and the bus order serialises the writes. Directory-based: for every memory block a directory entry, kept at the block's home node next to its memory, records the coherence state and which caches hold a copy (the sharer bits). A request goes to the home, which sends point-to-point messages only to the caches involved; nothing is broadcast.

(b) Snooping suits small-scale centralized shared-memory multiprocessors (SMP, UMA) built around one bus, up to a few tens of processors. Directories suit large-scale distributed shared-memory machines (DSM, NUMA), where memory is physically distributed over many nodes joined by a point-to-point interconnection network.

(c) Snooping: simple, with no extra structure; low latency, since one broadcast reaches every cache; write serialization for free from the bus. Directory: scalable, because traffic grows with the number of actual sharers, not with the number of processors; it works with physically distributed memory and any interconnect.

(d) Write-invalidate: before writing, the writer broadcasts an invalidate, every other copy becomes Invalid and the writer holds the only copy, so later writes by the same processor cause no traffic (MSI, MESI). It is the dominant choice because it saves bandwidth. Write-update (write-broadcast): every write broadcasts the new value and every cache holding the block updates its copy; readers never miss, but every write costs bus bandwidth, even when nobody reads the block again.

(e) Uncached: no cache holds the block, memory is up to date. Shared: one or more caches hold clean, read-only copies, memory is up to date. Modified: exactly one cache, the owner, holds the block with write permission, and memory may be stale. The sharer bits are one bit per node (N0 N1 N2 N3, left to right): 1 means that node's cache holds a copy, and in Modified exactly one bit is set, naming the owner. They let the home send invalidations and fetches only to the nodes that hold the block, instead of broadcasting.

What a complete answer contains: the broadcast-versus-point-to-point contrast stated as a mechanism, the matching architectures (SMP / UMA against DSM / NUMA), two benefits for each, the two write policies with their trade-off (bandwidth against read latency), and the three directory states with whether memory is fresh in each. The directory half is developed in lessons 37 and 38. The notes' own answer (pp. 495–497) is sound and uses the papers' name, Modified, for the third directory state. Question 2 of the same paper, on dynamic branch prediction, is drilled in lesson 5.

Lesson 36 · The E in MESI, and the exam table · question 7 of 7 · open in the lesson

Explain the main concepts and benefits of the MESI protocol with respect to MSI: (1) the four states and their meaning; (2) what happens on a read miss; (3) what happens on a write hit in each valid state; (4) when a block is written back to memory; (5) what the new state buys and what it costs in hardware.

Show model answer

(1) Modified: the only copy, dirty — memory is stale. Exclusive: the only copy, clean — it matches memory. Shared: a clean copy that other caches may also hold. Invalid: no valid copy. MSI has only M, S and I, so after a read miss a block always enters S, even when no other cache holds it.

(2) The miss is broadcast as a Read Miss and every other cache checks its tags. If none holds the block, the requester receives it in Exclusive; if one does, in Shared. A holder in Exclusive drops to Shared; a holder in Modified writes the block back, so memory becomes up to date, and drops to Shared.

(3) In Modified the write proceeds locally, with nothing on the bus. In Exclusive the line becomes Modified silently, with no bus transaction, because no other copy exists. In Shared the cache broadcasts an Invalidate, every other copy becomes Invalid and the line becomes Modified — as in MSI.

(4) Only from Modified: when the line is replaced; when another processor's Read Miss for the block is snooped (M → S); when another processor's Write Miss is snooped (M → I). Exclusive, Shared and Invalid lines are never written back.

(5) Benefit: private data — stack data, local variables, many heap objects — is read and then written by one processor. MSI pays a Read Miss plus a useless Invalidate per block and makes the first write wait for the bus; MESI pays only the Read Miss and writes at once, saving bus bandwidth and write latency. Cost: the requester must learn whether another cache holds the block, so the bus needs a shared line that every snooper holding the block asserts during a read miss; the four states still fit in two state bits per line.

The format of the June 2026 open question ("explain the main concepts and benefits"), applied to this lesson. What a complete answer contains: E defined as exclusive and clean; read miss into E only when no other cache holds the block; E → M without bus traffic; the three write-back cases; the benefit stated as bandwidth and latency on private data; the shared line as the cost.

Lesson 37 · The librarian: directory-based protocols, roles and messages

Lesson 37 · The librarian: directory-based protocols, roles and messages · question 1 of 7 · open in the lesson

Explain the main concepts and benefits of each one of the following elements of a directory-based cache coherence protocol for a distributed shared memory multiprocessor: 1. The directory and where it is stored; 2. The directory states of a block; 3. The sharer bits; 4. The home node; 5. The local node and the remote nodes; 6. Point-to-point messages instead of a broadcast; 7. The Fetch and Fetch/Invalidate messages; 8. The Data Write-Back message.

Show model answer
  1. A hardware table in the memory controller of each node, with one entry per memory block of that node's memory, recording the coherence state of the block and which caches hold copies. Logically one place per block (its home); physically distributed with the memories, so the lookups are spread over the nodes. Benefit: coherence without a broadcast medium, scalable to large DSM machines. Cost: storage proportional to blocks × nodes.
  2. Uncached: no cache holds the block, memory has the only valid copy. Shared: one or more caches hold read-only copies, memory is up to date. Modified: exactly one cache, the owner, holds a read-write copy, memory is stale. Benefit: from the state alone the home knows whether it can answer from memory (Uncached, Shared) or must get the block from the owner (Modified). The cache-side states are Invalid, Shared, Modified.
  3. One bit per node, N0 N1 N2 N3 from left to right: bit i = 1 if node i's cache holds a valid copy. All zeros in Uncached, one or more ones in Shared, exactly one in Modified (the owner). Benefit: the home sends invalidations or fetches only to the nodes involved instead of broadcasting. Cost: P bits per block, (P + 2)/(8B) of the memory — 12.9 % for 64 nodes and 64-byte blocks.
  4. The node whose main memory holds the block, fixed by the physical address; it stores the block and its directory entry. Every request for the block passes through its directory, which knows the sharers and the owner and serves the requests to that block one at a time, replacing the order of a bus. Benefit: the place to ask is known from the address alone.
  5. The local node is where the request originates: its processor misses on the block or writes a Shared copy. A remote node already holds a cached copy, Shared or Modified; if Modified it has the only fresh value. Roles belong to one transaction: a node can be home and local at once (a request for a block of its own memory) or home and remote (its own cache holds a copy).
  6. Requests go from the local node to the home only; the home sends Invalidate, Fetch or Fetch/Invalidate only to the nodes in the sharer bits; data comes back as Data Value Reply or Data Write-Back. Traffic grows with the number of actual sharers, not with the number of processors, and no cache looks up requests that do not concern it. Cost: one indirection through the home (more hops, more latency) and the directory storage.
  7. Both are sent by the home to the owner of a Modified block and carry only the address. Fetch serves a Read Miss: the owner returns the data and keeps a read-only copy (Modified → Shared). Fetch/Invalidate serves a Write Miss: the owner returns the data and invalidates its copy (Modified → Invalid), and the requester becomes the new owner. Benefit: the fresh copy is recovered from the only place that holds it.
  8. Sent by a remote owner to the home with the address and the dirty data: in reply to a Fetch or a Fetch/Invalidate, or when the owner evicts a Modified block. The home updates its memory and the entry and, for a request, forwards the data to the requester with a Data Value Reply. It is the only message from a remote node to the home: Shared copies are clean and never send data back.

The form of June 2026: eight sub-points, about five lines each. A complete sub-point names the mechanism, gives one concrete detail (a state, a bit pattern, a message name) and states the benefit with its cost. Three slips to avoid: calling the directory "a central table", listing Invalid among the directory states, and forgetting that Data Write-Back is also the reply to a Fetch.

Lesson 37 · The librarian: directory-based protocols, roles and messages · question 2 of 7 · open in the lesson

Consider a directory-based protocol for a distributed shared memory system with 4 nodes (N0, N1, N2, N3), each node with processor, cache, main memory and directory (the figure of Fig. 1). Please answer the following questions:

  1. What is the definition of home node?
  2. What is the definition of local node?
  3. What is the definition of remote node?
  4. What are the possible messages sent from the local node to the home node?
  5. What are the possible messages sent from the home node to the local node?
  6. What are the possible messages sent from the home node to the remote node?
  7. What are the possible messages sent from the remote node to the home node?
  8. What are the possible coherence states of a block in the local cache?
  9. What are the possible coherence states of a block in the home directory?
  10. What is the meaning of the sharer bits of a block in the home directory?
Show model answer
  1. Home node: the node whose main memory holds the block (fixed by the physical address) and whose directory keeps the block's state and sharer bits; every request for the block goes through it.
  2. Local node: the node whose processor issues the request; the read miss, the write miss or the write hit on a Shared copy originates in its cache.
  3. Remote node: a node that holds a cached copy of the block, Shared or Modified (the owner).
  4. Local → home: Read Miss (P, A); Write Miss (P, A); Invalidate (A), sent on a write hit to a block the local cache holds in Shared.
  5. Home → local: Data Value Reply (D).
  6. Home → remote: Invalidate (A); Fetch (A) — the owner returns the block and goes to Shared; Fetch/Invalidate (A) — the owner returns the block and invalidates its copy.
  7. Remote → home: Data Write-Back (A, D) — the owner's dirty block, in reply to a Fetch or a Fetch/Invalidate, or on eviction.
  8. States in the local cache: 1) Invalid, 2) Shared, 3) Modified.
  9. States in the home directory: 1) Uncached, 2) Shared, 3) Modified.
  10. Sharer bits: a bit vector with one bit per node (N0 N1 N2 N3); bit i = 1 if node i's cache holds a copy. All 0 in Uncached, one or more 1s in Shared, exactly one 1 — the owner — in Modified. They let the home send messages only to the caches involved instead of broadcasting.

Question 1 of July 2024, in its own order. Three things to get right: the home is fixed by the address and not by who asks; Invalidate is listed in both directions (local → home for a write hit on a Shared copy, home → remote to drop a copy); and the two lists of states are not mixed — Invalid belongs to the caches, Uncached to the directory. Lesson 38 drills the same question next to the walkthroughs.

Lesson 37 · The librarian: directory-based protocols, roles and messages · question 3 of 7 · open in the lesson

Let's consider a directory-based protocol for a distributed shared memory system with 4 Nodes (N0, N1, N2, N3) where:

Directory N2 Block B2 | State: Shared | Sharer Bits: 0110 |

For each of the following accesses, each one applied to this initial entry, answer: Home node? Local node? Remote node(s)? What is the initial message sent from the local node to the home node? Which message(s) are sent from the home node to the remote node(s)? Is(are) there any message(s) sent from the remote node(s) to the home node?

(a) Read Miss on B2 from node N0. (b) Write Miss on B2 from node N3. (c) Write Hit on B2 from node N1.

Answer the same questions starting from Directory N2 Block B2 | State: Modified | Sharer Bits: 1000 | for (d) Read Miss on B2 from node N3 and (e) Write Miss on B2 from node N2.

Show model answer

Home node: N2 for every access, because B2 lives in MM2.

AccessLocal nodeRemote node(s)Local → homeHome → remote(s)Remote → home
(a)N0N1, N2 (not contacted)Read Miss (P0, B2)nonenone
(b)N3N1, N2Write Miss (P3, B2)Invalidate (B2) to N1 and to C2none
(c)N1N2Invalidate (B2)Invalidate (B2) to C2none
(d)N3N0 (owner)Read Miss (P3, B2)Fetch (B2)Data Write-Back (B2, data)
(e)N2N0 (owner)Write Miss (P2, B2)Fetch/Invalidate (B2)Data Write-Back (B2, data)

In (a)–(c) N2 is a remote too, because its own cache C2 holds a copy; its Invalidate in (b) and (c) stays inside the node. In (a) nothing goes to the remotes: in Shared, MM2 is up to date and the home replies by itself. In (c) N1 holds a Shared copy, so it is the local node of a write hit. In (e) home and local coincide: the Write Miss and the reply stay inside N2. Nothing returns from Shared copies, which are clean; only the owner N0 returns the block in (d) and (e). The home answers (a), (b), (d) and (e) with a Data Value Reply; in (c) no data is sent, because N1 already holds the block.

The first half of the papers' directory exercise: who plays which part, and which messages exist. Lesson 38 adds the full order of the messages and the final state and sharer bits. The traps: in (a)–(c) N2 is home and remote at once; (c) starts with an Invalidate, not a Write Miss, and needs no Data Value Reply; in (e) home and local coincide, so the Write Miss and the reply never use the network.

Lesson 37 · The librarian: directory-based protocols, roles and messages · question 4 of 7 · open in the lesson

(SINGLE ANSWER) Let's consider the directory-based protocol for multiprocessors. Which is the message type that can be sent from the remote node to the home node of a block?

  • Answer 1: Data value reply It travels home → local: the home's reply that brings the block to the requester.
  • Answer 2: Data write back Right: the owner returns its dirty block to the home, after a Fetch or a Fetch/Invalidate or on eviction.
  • Answer 3: Invalidate Home → remote (drop your copy) or local → home (write hit on a Shared copy); never remote → home.
  • Answer 4: Fetch/Invalidate A command of the home to the owner: home → remote.
Show model answer

Answer 2. Data write back is the only message a remote node sends to the home: the owner's reply to a Fetch or a Fetch/Invalidate, or the write-back of an evicted Modified block.

Quiz 1 of June 2025 as printed, with its typo "form" read as "from". Sort every option by its direction (Fig. 4) and only one survives.

Lesson 37 · The librarian: directory-based protocols, roles and messages · question 5 of 7 · open in the lesson

(MULTIPLE ANSWERS) In a directory-based protocol, which message types can be sent from the home node to a remote node of a block?

  • Answer 1: Read Miss A request of the local node to the home: local → home.
  • Answer 2: Invalidate Right: the home tells a sharer to drop its copy.
  • Answer 3: Fetch Right: the home asks the owner of a Modified block for the data on a Read Miss.
  • Answer 4: Data Write-Back The opposite direction: remote (owner) → home.
  • Answer 5: Fetch/Invalidate Right: the home asks the owner for the data and makes it invalidate its copy, on a Write Miss.
Show model answer

Answers 2, 3 and 5. Read Miss goes local → home and Data Write-Back remote → home.

The July 2024 question "possible messages sent from the home node to the remote node" turned into a multiple-answer quiz. The trap is Invalidate: it also exists local → home, but it is correct here because it exists home → remote too.

Lesson 37 · The librarian: directory-based protocols, roles and messages · question 6 of 7 · open in the lesson

(True/False) In a directory-based protocol, when the state of a block in the home directory is Modified, the copy of the block in the main memory of the home node is up to date.

  • True In Modified the owner has written its copy, and memory has not seen the write.
  • False Right: Modified means one owner with a dirty copy; the memory copy is stale until the owner's Data Write-Back.
Show model answer

False. Memory is up to date in Uncached and Shared; in Modified the only fresh copy is in the owner's cache, which is why the home must send a Fetch or a Fetch/Invalidate before it can reply.

Motivate with the reason the state exists: it tells the home where the valid data is.

Lesson 37 · The librarian: directory-based protocols, roles and messages · question 7 of 7 · open in the lesson

A distributed shared memory system has 32 nodes. Each node has 2 GB (231 bytes) of main memory, the block size is 64 bytes, and every home directory keeps, for each of its memory blocks, 2 state bits and one sharer bit per node. What percentage of the main memory does the directory occupy?

Show model answer
\[ \frac{2^{31}}{2^{6}} = 2^{25} \ \text{blocks per node} \] \[ 32 + 2 = 34 \ \text{bits per entry} \] \[ \frac{34}{8 \cdot 64} = \frac{34}{512} \approx 6.64\,\% \]

Per node: \(34 \times 2^{25}\) bits = \(136 \times 2^{20}\) bytes (136 MB) of directory for 2 GB of memory. With 256 nodes the same blocks need 258 bits each: 258 / 512 ≈ 50.4 %.

Write the entry size first, then divide by the bits of one block: the memory size cancels, so the 2 GB only matters if the question also asks for the size in bytes. The typical slip is dividing by 64 instead of 8 × 64 = 512 bits.

Lesson 38 · Four nodes, one block: directory walkthroughs and the exam exercise

Lesson 38 · Four nodes, one block: directory walkthroughs and the exam exercise · question 1 of 7 · open in the lesson

(22 June 2026, Exercise 3) Consider a directory-based protocol for a distributed shared memory system with 4 nodes (N0, N1, N2, N3). Let's consider: Directory N0 Block B0 | State: SHARED | Sharer Bits: 1001|. Assuming a Write Miss on B0 from N2, please answer to the following questions:

  1. What is the home node?
  2. What is local node?
  3. What is(are) the remote node(s)?
  4. What is the initial message sent from the local node to the home node?
  5. What is the reply message sent from the home node to the local node?
  6. What is the reply message sent from the home node to the remote node(s)?
  7. Is(are) there any message(s) sent from the remote node(s) to the home node? Why?
  8. What is the final coherence state of the block in the home cache?
  9. What is the final coherence state of the block in the local cache?
  10. What are the final coherence state and the sharers bits of the block in the home directory?
  11. Which node is the final owner of the block?
Show model answer
QuestionAnswer
1. Home nodeN0: B0 is in MM0 and its entry in D0.
2. Local nodeN2: the node that issues the Write Miss.
3. Remote node(s)N0 and N3: the nodes whose sharer bits are 1 (1001). N0 is the home and also a remote, because its cache C0 holds a copy.
4. Initial message, local → homeWrite Miss (P = N2, A = B0), from N2 to N0.
5. Reply, home → localData Value Reply (B0), from N0 to N2, with the block read from MM0: memory is up to date because the state is Shared.
6. Reply, home → remote(s)Invalidate (B0) from N0 to N3, and to the home's own cache C0 inside N0.
7. Messages remote → home? Why?No. C0 and C3 hold the block in Shared state: clean copies, identical to MM0, so there is no data to write back; they only invalidate. A Data Write-Back is sent only by an owner in Modified state.
8. Final state in the home cacheInvalid (C0).
9. Final state in the local cacheModified (C2).
10. Home directoryDirectory N0 Block B0 | State: Modified | Sharer Bits: 0010
11. Final ownerN2.

Each box takes one line. The three traps of the form: N0 counted among the remotes, the "no" with its reason (clean copies), and Invalid — not Uncached — for the home cache. You may add that a real machine sends invalidation acknowledgements; the message set of the course has none.

Lesson 38 · Four nodes, one block: directory walkthroughs and the exam exercise · question 2 of 7 · open in the lesson

(10 June 2025, Question 1) Let's consider a directory-based protocol for a distributed shared memory system with 4 Nodes (N0, N1, N2, N3) where we consider the block B1 in the directory of N1: Directory N1 Block B1 | State: Shared | Sharer Bits: 0 1 0 0 |. Given the following sequence of accesses, please answer to the following questions:

  1. Read Miss on B1 from node N2
  2. Write Hit on B1 from node N2
  3. Write Miss on B1 from node N0

For each access: Home node? Local node? Remote node(s)? What is the sequence of messages sent among the nodes? Which are the final coherence state and sharer bits of the block B1 in the home directory?

Show model answer

1. Read Miss on B1 from node N2

Home nodeN1
Local nodeN2
Remote node(s)N1: its cache C1 holds the only copy (not contacted)
Sequence of messages1. N2 → N1 Read Miss (N2, B1)
2. N1 → N2 Data Value Reply (B1 from MM1, up to date in Shared)
B1 in the home directoryState: Shared | Sharer Bits: 0 1 1 0

2. Write Hit on B1 from node N2

Home nodeN1
Local nodeN2
Remote node(s)N1: C1 holds a copy
Sequence of messages1. N2 → N1 Invalidate (B1): the request to invalidate the other copies
2. N1 → C1, inside N1: Invalidate (B1)
No data is sent: N2 already has the block.
B1 in the home directoryState: Modified | Sharer Bits: 0 0 1 0 (owner N2)

3. Write Miss on B1 from node N0

Home nodeN1
Local nodeN0
Remote node(s)N2: the owner, Modified
Sequence of messages1. N0 → N1 Write Miss (N0, B1)
2. N1 → N2 Fetch/Invalidate (B1)
3. N2 → N1 Data Write-Back (B1, data); C2: Modified → Invalid; MM1 updated
4. N1 → N0 Data Value Reply (B1)
B1 in the home directoryState: Modified | Sharer Bits: 1 0 0 0 (owner N0)

Three shapes in one exercise: two messages, 1 + k, four. The classic slips are answering the second access with a Write Miss and a Data Value Reply (the block is already in C2) and forgetting, in the first, that the only copy is the home's own. Writing "N1 (the home's own cache), not contacted" for the first remote leaves no doubt about what you mean.

Lesson 38 · Four nodes, one block: directory walkthroughs and the exam exercise · question 3 of 7 · open in the lesson

Let's consider a directory-based protocol for a distributed shared memory system with 4 Nodes (N0, N1, N2, N3) where we consider the block B2 in the directory of N2: Directory N2 Block B2 | State: Shared | Sharer Bits: 0 0 1 1 |. Given the following sequence of accesses, please answer to the following questions:

  1. Write Miss on B2 from node N1
  2. Read Miss on B2 from node N3
  3. Write Hit on B2 from node N1

For each access: Home node? Local node? Remote node(s)? What is the sequence of messages sent among the nodes? Which are the final coherence state and sharer bits of the block B2 in the home directory?

Show model answer

1. Write Miss on B2 from node N1

Home nodeN2
Local nodeN1
Remote node(s)N2 (its own cache C2) and N3
Sequence of messages1. N1 → N2 Write Miss (N1, B2)
2. N2 → C2, inside N2: Invalidate (B2)
3. N2 → N3 Invalidate (B2)
4. N2 → N1 Data Value Reply (B2 from MM2)
B2 in the home directoryState: Modified | Sharer Bits: 0 1 0 0 (owner N1)

2. Read Miss on B2 from node N3

Home nodeN2
Local nodeN3
Remote node(s)N1: the owner, Modified
Sequence of messages1. N3 → N2 Read Miss (N3, B2)
2. N2 → N1 Fetch (B2)
3. N1 → N2 Data Write-Back (B2, data); C1: Modified → Shared; MM2 up to date
4. N2 → N3 Data Value Reply (B2)
B2 in the home directoryState: Shared | Sharer Bits: 0 1 0 1

3. Write Hit on B2 from node N1

Home nodeN2
Local nodeN1
Remote node(s)N3
Sequence of messages1. N1 → N2 Invalidate (B2): the request to invalidate the other copies
2. N2 → N3 Invalidate (B2)
No data is sent.
B2 in the home directoryState: Modified | Sharer Bits: 0 1 0 0 (owner N1)

Not from a paper: the June 2025 pattern with the home's own copy invalidated in the first access and a Fetch in the second. The second access is the case the notes get wrong (pp. 473 and 477): after the Data Write-Back the memory of N2 is up to date, and both copies are Shared.

Lesson 38 · Four nodes, one block: directory walkthroughs and the exam exercise · question 4 of 7 · open in the lesson

(15 July 2024, Question 1) Consider a directory-based protocol for a distributed shared memory system with 4 nodes (N0, N1, N2, N3). Please answer to the following questions:

  1. What is the definition of home node?
  2. What is the definition of local node?
  3. What is the definition of remote node?
  4. What are the possible messages sent from the local node to the home node?
  5. What are the possible messages sent from the home node to the local node?
  6. What are the possible messages sent from the home node to the remote node?
  7. What are the possible messages sent from the remote node to the home node?
  8. What are the possible coherence states of a block in the local cache?
  9. What are the possible coherence states of a block in the home directory?
  10. What is the meaning of the sharer bits of a block in the home directory?
Show model answer
QuestionAnswer
1. Home nodeThe node whose main memory holds the block, fixed by the physical address; its directory keeps the block's state and sharer bits, and every request for the block goes through it.
2. Local nodeThe node whose processor issues the request: the read or write miss originates in its cache.
3. Remote nodeA node whose cache holds a copy of the block, Shared or Modified. The home may have to invalidate it (a sharer) or fetch the data from it (the owner); the home itself can also be a remote.
4. Local → homeRead Miss (P, A); Write Miss (P, A); Invalidate (A), the request sent on a write hit to a Shared block.
5. Home → localData Value Reply (D): the block, in answer to a Read Miss or a Write Miss.
6. Home → remoteInvalidate (A); Fetch (A): the owner returns the block and goes to Shared; Fetch/Invalidate (A): the owner returns the block and invalidates it.
7. Remote → homeData Write-Back (A, D): the owner's modified block, in reply to a Fetch or a Fetch/Invalidate, or when the owner evicts it.
8. States in the local cache1) Invalid 2) Shared 3) Modified.
9. States in the home directory1) Uncached 2) Shared 3) Modified.
10. Sharer bitsOne bit per node (N0 N1 N2 N3): bit i = 1 means that node i's cache holds a copy. In Uncached all bits are 0; in Shared they mark all the sharers; in Modified exactly one bit is set and it marks the owner. They let the home send Invalidate and Fetch messages only to the nodes concerned, with no broadcast.

Ten short answers. The marks hide in the directions: Invalidate appears twice (local → home and home → remote), and the remote → home list has a single entry, Data Write-Back — the June 2025 quiz asked exactly that. Keep the two lists of states apart: Invalid belongs to caches, Uncached to the directory.

Lesson 38 · Four nodes, one block: directory walkthroughs and the exam exercise · question 5 of 7 · open in the lesson

(15 July 2024, Question 4, SINGLE ANSWER) Let's consider a directory-based protocol for a distributed shared memory system with 4 Nodes (N0, N1, N2, N3) where: Directory N1 Block B1 | State: Shared | Sharer Bits: 1001. Which is the state of the block B1 in N1 after this sequence: Read Miss B1 from local cache N1; Read Miss B1 from local cache N2; Write Hit B1 from local cache N1;

  • Answer 1: Directory N1 Block B1 | State: Shared | Sharer Bits: 1111 That is the entry after the two read misses; the write hit by N1 then invalidates the other three copies.
  • Answer 2: Directory N1 Block B1 | State: Modified | Sharer Bits: 0100 1001 → 1101 (N1 reads, local and home at once) → 1111 (N2 reads) → the write hit by N1 invalidates N0, N2 and N3: Modified, owner N1.
  • Answer 3: Directory N1 Block B1 | State: Shared | Sharer Bits: 0110 A read never removes a sharer: N0 and N3 keep their copies until the write hit, and after it the state is Modified.
  • Answer 4: Directory N1 Block B1 | State: Modified | Sharer Bits: 0110 In Modified exactly one bit is set: the owner's.
Show model answer

Answer 2. Read Miss from N1: N1 is local and home, the block comes from MM1 and N1's bit is set: Shared | 1101. Read Miss from N2: Data Value Reply from MM1: Shared | 1111. Write Hit from N1: N1 holds a Shared copy, so it sends an Invalidate request to the home (itself), which invalidates N0, N2 and N3: Modified | 0100.

Two traps: in the first access local = home, which changes nothing in the rule — N1's bit is set like any reader's, 1001 → 1101; the last is a write hit, so the final state is Modified with one bit, whatever the bits were before.

Lesson 38 · Four nodes, one block: directory walkthroughs and the exam exercise · question 6 of 7 · open in the lesson

(SINGLE ANSWER) Let's consider a directory-based protocol for a distributed shared memory system with 4 Nodes (N0, N1, N2, N3) where: Directory N3 Block B3 | State: Shared | Sharer Bits: 0110. Which is the state of the block B3 in N3 after this sequence: Write Miss B3 from local cache N0; Read Miss B3 from local cache N2;

  • Answer 1: Directory N3 Block B3 | State: Modified | Sharer Bits: 1000 That is the entry after the write miss alone; the read miss from N2 then fetches the block from N0.
  • Answer 2: Directory N3 Block B3 | State: Shared | Sharer Bits: 1010 The write miss invalidates N1 and N2 (Modified | 1000); the read miss from N2 fetches from the owner N0, which keeps a Shared copy.
  • Answer 3: Directory N3 Block B3 | State: Shared | Sharer Bits: 1110 N1's copy was invalidated by the write miss and was never read again.
  • Answer 4: Directory N3 Block B3 | State: Modified | Sharer Bits: 0010 A read miss never makes the reader the owner: both copies end Shared.
Show model answer

Answer 2. Write Miss from N0: the home N3 invalidates N1 and N2 and replies to N0: Modified | 1000. Read Miss from N2: the home sends a Fetch to N0, which returns a Data Write-Back and goes to Shared; the home replies to N2: Shared | 1010, memory up to date.

The July 2024 quiz pattern with a read on a Modified block. The wrong options are the entry after one access (Answer 1), a forgotten invalidation (Answer 3) and a reader made owner (Answer 4).

Lesson 38 · Four nodes, one block: directory walkthroughs and the exam exercise · question 7 of 7 · open in the lesson

(MULTIPLE ANSWERS) Let's consider a directory-based protocol for a distributed shared memory system with 4 Nodes (N0, N1, N2, N3) where: Directory N0 Block B0 | State: Modified | Sharer Bits: 0100. A Read Miss on B0 arrives from node N2. Which of the following statements are true?

  • Answer 1: The home node N0 sends a Fetch message to N1. N1 is the owner: the only node with the fresh value.
  • Answer 2: N1 sends a Data Write-Back to N0 and keeps its copy in Shared state. A Fetch downgrades the owner; a Fetch/Invalidate would invalidate it.
  • Answer 3: N1 sends the block directly to N2 with a Data Value Reply. In the protocol of the course the home replies: owner → home Data Write-Back, then home → local Data Value Reply.
  • Answer 4: At the end of the transaction, the copy of B0 in MM0 is up to date. The Data Write-Back wrote the block into MM0; the final state is Shared, so memory is fresh.
  • Answer 5: At the end of the transaction, the directory entry is Modified | 0010. N2 only reads: the entry becomes Shared | 0110.
Show model answer

Answers 1, 2 and 4. The sequence is N2 → N0 Read Miss, N0 → N1 Fetch, N1 → N0 Data Write-Back (N1: Modified → Shared, MM0 updated), N0 → N2 Data Value Reply. Final entry: Shared | 0110, memory up to date.

A multiple-answer quiz in the June 2026 form. Answer 4 is the statement the notes get wrong (pp. 473 and 477); Answer 3 describes a real-machine optimization, not the protocol of the papers.

To the filters ↑