Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed

Digital Design & Computer Architecture · Lecture 16 of 37 · 1:32:01

Lecture 13: Precise Exceptions

Digital Design and Computer Arch. - L13: Precise Exceptions (Spring 2025) on YouTube

Study guide

What this lecture covers

The lecture answers a question left open from the pipelining lectures: if different functional units take different numbers of cycles (an add finishes in one cycle, a divide in eight), what happens when a younger, faster instruction wants to write its result before an older, slower instruction has finished? Writing out of order would break the von Neumann model's sequential semantics, and it becomes especially dangerous once exceptions and interrupts are involved, because a program that crashes mid-execution needs a clean, well-defined state to recover from.

The lecture builds up the concept of precise exceptions, explains why hardware designers care about them, and walks through how single-cycle, multi-cycle, and pipelined machines each support them. It ends by introducing the reorder buffer, the mechanism that lets instructions complete execution out of order while still updating the architectural state in program order. This sets up the following lecture on out-of-order execution.

Key ideas

  • Exception: an internal, program-caused abnormal condition, such as divide by zero, arithmetic overflow, an undefined opcode, or a page fault.
  • Interrupt: an external event unrelated to the running program, such as a power failure, a network packet arriving, or a timer signal; interrupts are handled by the system, not the program.
  • Precise exception: when an exception is handled, all instructions before the excepting one have fully retired (updated architectural state) and none after it have, giving the programmer a clean, well-defined machine state to debug or recover from.
  • Retire / commit: the point where an instruction's result is written into the architectural state (registers, memory, PC); this must happen strictly in program order.
  • Reorder buffer (ROB): a circular hardware queue that holds decoded-but-not-yet-retired instructions; instructions can write their results into the ROB out of order, but results only move into the register file when an instruction becomes the oldest in the machine.
  • Content-addressable search: because the ROB is indexed by program order rather than by register number, finding "the latest value of register R3" requires comparing the destination register ID of every entry, an expensive, age-based search.
  • Register renaming via indirection: rather than searching the ROB directly, the register file stores a tag pointing to the ROB entry that will produce a register's value, avoiding the costly content-addressable search.
  • False dependences (WAR/WAW): output and anti-dependences on the same architectural register are artifacts of having too few register names, not true data dependences; renaming eliminates them.

Walkthrough

Why out-of-order completion threatens sequential semantics (2:06)

The lecture opens with a pipeline where functional units differ in latency: an integer add finishes in one cycle, a divide might take eight (or, in real processors, 40 to 50). If a fast, younger add instruction is allowed to write its result to the register file before a slower, older divide finishes, the sequential instruction semantics of the von Neumann model are violated. The instructor uses a tram analogy: one delayed tram (an excepting instruction) blocks the cars behind it, and later trams should not be allowed to overtake and "finish" first.

Exceptions vs. interrupts (9:09)

Exceptions are internal to the running program (divide by zero, overflow, undefined opcode, protection violations, page faults). Interrupts are external (power failure, I/O device service requests, timers, machine checks). Both stop the current program, save architectural state, and transfer control to a handler, but they differ in urgency and handling context: exceptions are handled immediately and in the context of the process (so a programmer can catch them), while interrupts can often be deferred and are handled by the operating system.

Why precise exceptions matter (27:27)

Precise exceptions make software debugging and recovery tractable: the programmer knows exactly which instructions completed and which did not, so the program can be restarted or fixed up from a known point. The lecture notes that an early IBM out-of-order machine skipped precise exceptions and, despite being technically advanced, struggled commercially because it was too hard to debug. Precise exceptions also enable clean recovery, easy restart at the faulting program counter, and software emulation of unimplemented instructions (such as emulating multiply or floating-point operations with an exception handler).

Supporting precise exceptions in single-cycle and multi-cycle machines (34:29)

In a single-cycle machine the problem does not exist, since instruction and cycle boundaries coincide. In a multi-cycle machine, the finite state machine is extended with special states (for example, an "undefined opcode" state and an "overflow" state) that set a cause register, save the excepting PC into an EPC register, and redirect the next PC to an exception handler. The lecture works through the MIPS multi-cycle datapath modifications, including the MFC0 instruction used to copy the cause into a general-purpose register.

The naive fix and its cost (44:41)

For a pipeline with multi-cycle functional units, one "solution" is to force every instruction to take as long as the slowest one, so writes stay in order. This preserves precise exceptions but throws away the performance benefit of fast instructions, similar to reverting to a single-cycle design. The lecture frames this as a non-solution and introduces four real approaches used in practice: the reorder buffer, history buffer, future register file, and checkpointing, focusing on the reorder buffer.

The reorder buffer: mechanism and example (46:42)

The reorder buffer decouples microarchitectural completion from architectural commitment: instructions can finish and write into their allocated ROB entry out of order, but only the oldest instruction in the ROB updates the register file or memory. Each entry tracks validity, destination register, destination value, whether the value has been written, the instruction's PC (for exception handling), and whether it caused an exception. The instructor works through a multi-cycle simulation where two instructions both target register R3, showing how a dependent instruction can search the ROB for the correct, most recent definition of a register.

From content-addressable search to indirection and renaming (1:20:04)

Searching the ROB by content (comparing every entry's destination register against the one being looked up) is expensive and gets worse as ROB size grows. The fix is indirection: the register file gains a tag field that, when a register's value is not yet ready, points directly to the ROB entry that will produce it. This is illustrated with a re-run of the earlier example using tags instead of searches, and connected to a real design, the Intel Pentium Pro's register alias table.

Register renaming and closing summary (1:26:08)

The lecture closes by generalizing: tagging registers to ROB entries is a form of register renaming, which eliminates false write-after-write and write-after-read dependences caused by having too few architectural register names, while preserving true (flow) dependences. This gives the illusion of many more registers than the ISA exposes and sets up out-of-order execution, covered next.

Before you watch

  • Review the earlier pipelining lectures on data forwarding, bypassing, and control/data dependence handling in this course, since this lecture assumes familiarity with pipeline hazards.
  • Be comfortable with the basic multi-cycle MIPS datapath and finite state machine, since the lecture extends it directly.
  • Knowing what output and anti-dependences (WAW, WAR) are will help the register renaming discussion make sense.

Check your understanding

  1. Why does allowing a fast instruction to write its result before an older, slower instruction finishes violate sequential semantics?
  2. What is the difference between an exception and an interrupt, and why does that difference affect how urgently each is handled?
  3. Why did forcing every instruction to take the worst-case number of cycles fail as a practical solution to precise exceptions?
  4. How does a reorder buffer let instructions complete out of order while keeping architectural state updates in program order?
  5. Why does searching a reorder buffer by register ID require a content-addressable search, and how does adding tags to the register file avoid it?

Vocabulary

exception (noun)
An abnormal condition caused inside a running program, like dividing by zero.
A divide-by-zero causes an exception in the running program.
interrupt (noun)
An external event unrelated to the running program that needs the system's attention.
A timer interrupt happens no matter what the program is doing.
precise exception (noun)
An exception handled so that all earlier instructions are fully finished and none of the later ones are.
A precise exception gives the programmer a clean state to debug from.
retire (verb)
To make an instruction's result permanent by updating the visible registers or memory, in program order.
An instruction can only retire once all older instructions have retired.
commit (verb)
See retire: to make an instruction's effect final and visible in the machine's real state.
The reorder buffer lets only the oldest instruction commit each cycle.
reorder buffer (noun)
A hardware queue that lets instructions finish out of order but forces their results to be committed in order.
The reorder buffer keeps track of which instruction is oldest and unretired.
content-addressable search (noun)
A search method that looks something up by comparing its content, not by a fixed location.
Finding a register's latest value requires a content-addressable search of the buffer.
register renaming (noun)
Assigning temporary internal names to registers so unrelated instructions don't falsely conflict.
Register renaming removes false dependencies between instructions.
tag (noun)
A small label pointing to where a value will come from, used instead of searching for it directly.
A tag in the register file points to the entry that will produce the value.
false dependence (noun)
An apparent conflict between instructions that isn't a real data relationship, only a naming clash.
Write-after-write is a false dependence caused by limited register names.
write-after-read (WAR) (noun)
A false dependence where a later instruction writes a register an earlier one still needs to read.
Write-after-read dependence disappears once registers are renamed.
write-after-write (WAW) (noun)
A false dependence where two instructions write to the same register.
Write-after-write dependence is removed by writing in program order.
page fault (noun)
An exception caused when a program accesses memory that is not currently available.
A page fault is one type of internal exception.
handler (noun)
A piece of code that runs in response to an exception or interrupt.
Control transfers to a handler when an exception occurs.
cause register (noun)
A register that records why an exception happened.
The cause register stores the code for an undefined-opcode exception.
EPC (exception program counter) (noun)
A register that saves the address of the instruction that caused an exception.
EPC lets the handler know exactly where the program should resume.
tractable (adjective)
Manageable or solvable with a reasonable amount of effort.
Precise exceptions make debugging tractable for programmers.
emulation (noun)
Making one system behave like another by simulating its behavior in software.
Software emulation can handle a multiply instruction the hardware doesn't support.
checkpointing (noun)
Saving a snapshot of a machine's state so it can be restored later if needed.
Checkpointing is one alternative approach to precise exceptions.
sequential semantics (phrase)
The rule that a program's effects must appear as if instructions ran one after another, in order.
Out-of-order completion threatens sequential semantics.
von Neumann model (noun)
The classic computer design where instructions execute one at a time in the stored order.
Sequential semantics come from the von Neumann model.
functional unit (noun)
A piece of hardware, like an ALU or divider, that performs a specific type of computation.
Different functional units take different numbers of cycles to finish.
overflow (noun)
A condition where a computed result is too large to fit in its storage space.
Arithmetic overflow is one type of internal exception.
undefined opcode (phrase)
An instruction bit pattern that does not correspond to any real operation.
An undefined opcode triggers an exception.
protection violation (phrase)
An attempt to access memory or resources that a program is not allowed to use.
A protection violation is handled the same way as other exceptions.
indirection (noun)
Referring to something through a pointer or tag rather than accessing it directly.
Indirection avoids the need to search the whole buffer.
decouple (verb)
To separate two things so one no longer directly controls the other.
The reorder buffer decouples completion from commitment.
circular queue (noun)
A queue structure that wraps back to the beginning once it reaches the end.
The reorder buffer is implemented as a circular queue.
flow dependence (noun)
A true dependence where one instruction needs a value produced by an earlier one.
Register renaming preserves true flow dependences.
illusion (noun)
Something that appears to be true but is created artificially.
Renaming gives the illusion of having more registers than the ISA provides.

From the YouTube description

Digital Design and Computer Architecture, ETH Zürich, Spring 2025 (https://safari.ethz.ch/ddca/spring2025/)

Lecture 13: Precise Exceptions
Lecturer: Prof. Onur Mutlu
Date: 3 April 2025

Lecture 13 Slides (pptx): https://safari.ethz.ch/ddca/spring2025/lib/exe/fetch.php?media=onur-ddca-2025-lecture13-precise-exceptions-afterlecture.pptx
Lecture 13 Slides (pdf): https://safari.ethz.ch/ddca/spring2025/lib/exe/fetch.php?media=onur-ddca-2025-lecture13-precise-exceptions-afterlecture.pdf

Recommended Reading:
====================
A Modern Primer on Processing in Memory
https://arxiv.org/pdf/2012.03112.pdf

Memory-Centric Computing: Solving Computing's Memory Problem
https://www.arxiv.org/pdf/2505.00458

Memory-Centric Computing: Recent Advances in Processing-in-DRAM
https://arxiv.org/pdf/2412.19275

Intelligent Architectures for Intelligent Computing Systems
https://people.inf.ethz.ch/omutlu/pub/intelligent-architectures-for-intelligent-computingsystems-invited_paper_DATE21.pdf

RowHammer: A Retrospective
https://people.inf.ethz.ch/omutlu/pub/RowHammer-Retrospective_ieee_tcad19.pdf

Fundamentally Understanding and Solving RowHammer
https://arxiv.org/pdf/2211.07613.pdf

Accelerating Genome Analysis via Algorithm-Architecture Co-Design
https://people.inf.ethz.ch/omutlu/pub/AcceleratingGenomeAnalysis_dac23.pdf

From Molecules to Genomic Variations: Accelerating Genome Analysis via Intelligent Algorithms and Architectures
https://people.inf.ethz.ch/omutlu/pub/IntelligentGenomeAnalysis_csbj22.pdf

RECOMMENDED LECTURE VIDEOS & PLAYLISTS:
========================================
Digital Design and Computer Architecture Spring 2025 Livestream Lectures Playlist:
https://www.youtube.com/watch?v=ubhxKNlOlRg&list=PL5Q2soXY2Zi9Eo29LMgKVcaydS7V1zZW3&index=3

Fundamentals of Computer Architecture Fall 2025 Livestream Lectures Playlist:
https://www.youtube.com/watch?v=uKgMFj1eQQc&list=PL5Q2soXY2Zi_ZMtqz1r-GHm-zzuE1QfIg&index=2

Seminar in Computer Architecture Spring 2025 Livestream Lectures Playlist:
https://www.youtube.com/watch?v=rqeKNZrLzng&list=PL5Q2soXY2Zi-oIW66TLOjtiqQxlDwNHng&index=2

Computer Architecture Fall 2024 Lectures Playlist:
https://www.youtube.com/watch?v=ziMRjDlLEwo&list=PL5Q2soXY2Zi-LfDdGgWyLcTSqzm6a26wD&index=2

Interview with Professor Onur Mutlu:
https://www.youtube.com/watch?v=8ffSEKZhmvo&list=PL5Q2soXY2Zi8VrmOTz44l2WupethSdh-M&index=9

TCuARCH meets Prof. Onur Mutlu
https://www.youtube.com/watch?v=6Hpn4SAX0dI

Arch. Mentoring Workshop @ISCA'21 - Doing Impactful Research
https://www.youtube.com/watch?v=83tlorht7Mc

The Story of RowHammer Lecture:
https://www.youtube.com/watch?v=sgd7PHQQ1AI&list=PL5Q2soXY2Zi8D_5MGV6EnXEJHnV2YFBJl&index=39

Accelerating Genome Analysis Lecture:
https://www.youtube.com/watch?v=r7sn41lH-4A&list=PL5Q2soXY2Zi8D_5MGV6EnXEJHnV2YFBJl&index=41

Memory-Centric Computing Systems Tutorial at IEDM 2021:
https://www.youtube.com/watch?v=H3sEaINPBOE&list=PL5Q2soXY2Zi8D_5MGV6EnXEJHnV2YFBJl&index=35

Intelligent Architectures for Intelligent Machines Lecture:
https://www.youtube.com/watch?v=GTieZPY4Wmc&list=PL5Q2soXY2Zi8D_5MGV6EnXEJHnV2YFBJl&index=38

Featured Lectures:
https://www.youtube.com/watch?v=jVYCchBGNVc&list=PL5Q2soXY2Zi8VrmOTz44l2WupethSdh-M&index=1

← Lecture 12: Pipelined Processor Design II · Lecture 14: Out-of-Order Execution →