Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed
Parallel Computing & CUDA · Lecture 19 of 19 · 1:08:18
Lecture 19: Accessing Memory + Course Wrap Up
Study guide
What this lecture covers
This final lecture of the course opens up a topic the class had treated abstractly until now: how DRAM actually works underneath the cache hierarchy. It explains why memory access time is not fixed, walking through the physical steps a DRAM chip takes to turn stored charge into bits on a bus, and then shows how techniques like banking, interleaving and stacked high-bandwidth memory hide that latency and multiply bandwidth. This builds directly on the course's recurring theme that parallelism is comparatively easy while getting data to processors efficiently is the hard problem.
The second half is a more informal wrap-up and audience Q&A. The instructor summarizes the course's big lessons about specialization and scheduling, describes a research project that parallelizes game-engine simulation for AI training, and gives practical advice on choosing next courses, getting involved in research, and navigating early career decisions at Stanford. After watching, you should be able to explain why DRAM access patterns matter for bandwidth and describe the main techniques (bulk transfers, bank pipelining, request reordering, stacked memory) used to make memory systems efficient.
Key ideas
- DRAM access time is variable: unlike a simple mental model of "memory," accessing a DRAM chip takes different amounts of time depending on whether the requested data is already staged in the chip's row buffer.
- Reading data is a multi-step process: precharge (readying bit lines), row activation (copying a row's charge into the row buffer, which destroys the original value), and column selection (reading specific bytes out of the row buffer onto the data pins).
- Row buffer locality is fast, row switches are slow: a second access to the same open row only needs a column selection; switching to a different row requires writing the current row back first, then precharging and activating the new one.
- Banks enable pipelining: a DRAM chip replicates its array, row buffer and control logic into multiple banks so the controller can precharge and activate one bank while transferring data from another, hiding much of the latency.
- Interleaving and channels multiply bandwidth: striping consecutive bytes of a cache line across multiple DRAM chips (and using multiple memory channels) lets a system use its full bus width instead of bottlenecking on one chip's eight data pins.
- The memory controller reorders requests: it buffers cache misses from multiple cores or applications and reorders them to maximize row-buffer hits and bank-level pipelining, trading some latency for higher bandwidth.
- Stacked, high-bandwidth memory shortens the physical distance: placing DRAM dies directly on the same package as the processor, connected via through-silicon vias, allows far wider buses (thousands of bits) and much higher bandwidth than a conventional board-level memory bus.
- The course's overall lesson: identifying parallelism is usually the easy part; scheduling that parallelism and moving data efficiently is where most of the difficulty and payoff lie, and specialization can make otherwise inefficient software dramatically faster.
Walkthrough
Why DRAM access time isn't fixed (0:05)
The lecture reframes memory as a physical array of capacitor-based cells on a DRAM chip, each storing a bit as a voltage. It introduces the basic structure: a limited number of data pins (commonly eight per chip) and a row buffer that temporarily holds one row's worth of bits. Because the chip can only expose data that has been copied into the row buffer, access time depends heavily on whether the requested byte is already there.
Reading a row: precharge, activate, column select (6:11)
The lecture details the three-step process for reading data: precharging the bit lines to a known voltage (about 10 nanoseconds), activating the target row to copy its charge into the row buffer (another roughly 10 nanoseconds, which destructively reads the original cells), and then selecting the desired columns to move those bits onto the memory bus. A follow-up point clarifies that reading an adjacent byte in the same row is much faster, since it skips precharge and activation and only needs a new column selection, while switching to a different row requires writing the current row's data back first.
Pipelining across banks and using bulk transfers (13:18)
A class discussion identifies that memory bus utilization is low if only a fraction of each transfer's cycles are used, and works toward two standard fixes: bulk, contiguous transfers that amortize overhead, and pipelining latency by working on multiple requests at once. The lecture explains that DRAM chips implement pipelining by replicating their array, row buffer and pins into separate banks, so the controller can precharge and activate one bank while transferring data from another. Interleaving addresses across banks and across multiple chips in a DIMM (dual in-line memory module) lets a 64-bit bus be built from several 8-bit chips, and striping consecutive bytes across them is what makes a full cache-line transfer efficient.
The memory controller schedules requests (26:35)
The lecture explains that the memory controller receives cache misses from potentially many cores and applications, buffers them, and reorders them to maximize row-buffer hits and bank-level pipelining rather than serving them strictly in arrival order. This trades some added latency for higher achievable bandwidth, which matters more for bandwidth-bound systems like GPUs than for latency-sensitive real-time workloads. The lecture also covers how DDR (double data rate) memory sends data on both the rising and falling clock edges, and how dual-channel configurations double bandwidth by running two independent buses in parallel; it briefly notes that extra memory chips are sometimes added purely for error-correcting redundancy.
Stacked, high-bandwidth memory (35:45)
To go beyond what board-level wiring can support, the lecture describes stacking DRAM dies directly on the same silicon package as the processor, connected through vertical through-silicon vias instead of board traces. This shortens the physical distance data must travel, making it economical to build memory buses thousands of bits wide instead of 64 bits, at the cost of limited total capacity (a fixed number of gigabytes) compared to conventional DRAM reached over a traditional bus. The lecture connects this directly to the course's earlier flash attention assignment, noting that the optimization was partly designed to keep intermediate matrices inside this smaller, much faster stacked memory rather than spilling to conventional DRAM.
Course wrap-up: lessons, a research example, and next steps (41:51)
The lecture closes with a summary of recurring course themes: most modern devices are heterogeneous multi-core systems, well-optimized code can be dramatically faster than naive code (citing the course's own SIMD and specialized-hardware assignments), and identifying parallelism is usually easier than scheduling it or getting data to processors efficiently. As an example of applying these ideas, the instructor describes a lab project that rewrote game-engine simulation to run thousands of reinforcement-learning training environments in lockstep on a single GPU, replacing large GPU clusters and cutting some training runs from hours to seconds. The remainder is informal advice on follow-on courses, how to get involved in research, and general guidance on early-career decisions, offered as practical next steps for students finishing the course.
Before you watch
- Review how the cache hierarchy and cache misses work, since this lecture picks up right where a last-level cache miss hands off to the memory controller.
- Recall the course's flash attention assignment; the lecture references it directly when explaining stacked high-bandwidth memory.
- No new algorithmic prerequisites are needed for the wrap-up and Q&A portion.
Check your understanding
- Why does accessing a different row in the same DRAM chip take longer than accessing more data from the currently open row?
- What are precharge, row activation and column selection, and what does each step accomplish?
- How do banks and interleaving let a memory system pipeline requests and use its full bus width?
- What tradeoff does a memory controller make when it buffers and reorders cache-miss requests?
- Why does stacking DRAM directly on the processor package allow much wider, higher-bandwidth memory buses?
Vocabulary
- DRAM (noun)
- The main memory technology in computers, storing bits as electrical charge in tiny capacitors.
DRAM access time depends on what data is already staged nearby. - row buffer (noun)
- A temporary storage area in a DRAM chip that holds one row of data ready to be read.
Data must be copied into the row buffer before it can be read out. - precharge (noun)
- The step of resetting a DRAM chip's internal wires to a known voltage before reading.
Precharge must happen before a new row can be activated. - row activation (noun)
- The step of copying a row's stored charge into the row buffer.
Row activation destructively reads the original cells' charge. - column selection (noun)
- The step of choosing specific bytes from the row buffer to send out on the bus.
Column selection sends the requested bytes onto the memory bus. - destructive read (noun)
- A read that erases the original stored value as part of retrieving it.
Row activation is a destructive read of the DRAM cells. - bank (noun)
- A separate section of a DRAM chip that can be worked on independently of others.
Banks let one part of the chip prepare while another transfers data. - pipelining (noun)
- Overlapping different stages of work so multiple items are in progress at once.
Banks enable pipelining of memory requests. - interleaving (noun)
- Spreading consecutive pieces of data across multiple storage units.
Interleaving bytes across chips increases available bandwidth. - channel (noun)
- An independent path connecting the processor to a set of memory chips.
Multiple memory channels can run in parallel to boost bandwidth. - memory controller (noun)
- The hardware component that manages and schedules requests to memory.
The memory controller reorders requests to improve efficiency. - row-buffer hit (noun)
- A memory access that finds its data already in the currently open row.
Reordering requests to maximize row-buffer hits speeds things up. - DDR (double data rate) (noun)
- A memory technology that transfers data on both halves of each clock cycle.
DDR memory doubles bandwidth by using both clock edges. - dual-channel (adjective)
- Describes a system using two independent memory buses running at the same time.
A dual-channel configuration doubles available memory bandwidth. - error-correcting (adjective)
- Able to detect and fix small errors in stored or transmitted data.
Extra chips are sometimes added for error-correcting redundancy. - stacked memory (noun)
- Memory chips physically stacked on top of or next to the processor for shorter, faster connections.
Stacked memory allows much wider data buses than a normal board. - through-silicon via (noun)
- A vertical electrical connection passing through a stack of silicon chip layers.
Through-silicon vias connect stacked memory dies to the processor. - die (noun)
- A single piece of silicon cut from a wafer, containing one chip.
Several memory dies are stacked together in high-bandwidth memory. - capacitor (noun)
- A tiny component that stores an electrical charge representing one bit of data.
Each DRAM cell stores a bit as charge in a capacitor. - bit line (noun)
- A wire in a memory chip used to carry the electrical signal for reading or writing a bit.
Precharge resets the bit lines to a known voltage. - redundancy (noun)
- Extra components or data kept as a backup in case something fails.
Extra memory chips add redundancy for error correction.
From the YouTube description
How DRAM works, suggestions for post-cs149 topics
To follow along with the course, visit the course website:
https://gfxcourses.stanford.edu/cs149/fall23/
Kayvon Fatahalian
Associate Professor of Computer Science, Stanford University
https://graphics.stanford.edu/~kayvonf/
Kunle Olukotun
Cadence Design Systems Professor, Professor of Electrical Engineering and of Computer Science, Stanford University
https://engineering.stanford.edu/people/oyekunle-olukotun
Learn more about the online course and how to enroll: https://online.stanford.edu/courses/cs149-parallel-computing
To view all online courses and programs offered by Stanford, visit: https://online.stanford.edu/
