Seyed Masoud Hosseini · Overview · Study log · Ideas · Transcript · RSS feed
Digital Design & Computer Architecture · Lecture 16 of 37 · 1:32:01
Lecture 13: Precise Exceptions
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
- Why does allowing a fast instruction to write its result before an older, slower instruction finishes violate sequential semantics?
- What is the difference between an exception and an interrupt, and why does that difference affect how urgently each is handled?
- Why did forcing every instruction to take the worst-case number of cycles fail as a practical solution to precise exceptions?
- How does a reorder buffer let instructions complete out of order while keeping architectural state updates in program order?
- 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?
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 →
