Lecture 10 · Hardware Specialization

Parallel Computing · Lecture 10。个人学习讲义与配套实验,按主题整理并持续修订。

课程源码 ZIP ↓

个人整理的学习笔记,非官方讲义;课程来源与整理说明见课程介绍。配套示例未逐一运行验证。

本篇目录

Maps to: Stanford CS149 Fall 2025, Lecture 10 (Oct 23), slide deck 10_Specialized (71 slides). Sources: the public Fall 2025 slides; the 2023 lecture video; R. Hameed et al., “Understanding Sources of Inefficiency in General-Purpose Chips” (ISCA 2010); N. Jouppi et al., “In-Datacenter Performance Analysis of a Tensor Processing Unit” (ISCA 2017); H. T. Kung, “Why Systolic Architectures?” (1982). Every experiment and number below was written for these notes and run on the author’s machine (Apple M4 Pro; clang 21, macOS 27; numpy 2.5). Energy numbers are models built from the slides’ ballpark figures, because the machine reports power only to administrators. Code: code/lecture10/. Reading time: ~75 minutes for the prose; ~10 more for the demos.


0. How to read this lecture

0.1 Learning goals

After this lecture you should be able to:

  1. Explain why modern computing is energy-constrained (能耗受限) and why, under a power limit, energy per operation (每次操作的能耗) determines throughput.
  2. Say where the energy of an instruction goes on a general-purpose processor (fetch, decode, control, register files) and why specialization (专用化), by amortizing that overhead and avoiding data movement, gains 10–1000×.
  3. Place DSPs, FPGAs (现场可编程门阵列), ASICs (专用集成电路), GPUs and AI accelerators on the efficiency vs. programmability (效率与可编程性) spectrum.
  4. List the features of an ideal AI accelerator: asynchronous execution, tiled tensors, minimal data movement, special instructions, low-precision number formats (数值格式).
  5. Describe how GPUs specialized: tensor cores (张量核心), the Tensor Memory Accelerator (TMA), FP8/FP4.
  6. Explain how a systolic array (脉动阵列) (Google’s TPU) computes matrix products with almost no data movement, and compare it with SIMD.
  7. Discuss the hardware lottery (硬件彩票) and reconfigurable dataflow (数据流) architectures.

0.2 Prerequisites and scope

  • Prerequisites: Lecture 1 (power wall, energy of data movement), Lecture 2 (SIMD, the cost of an instruction stream), Lecture 7 (GPU SMs), Lecture 9 (GEMM, blocking, low precision).
  • Scope: why and how hardware is specialized, mostly for AI. Programming such hardware (asynchrony, tiles, dataflow) is Lecture 11. Datacenter-scale AI is Lecture 12.

0.3 Section → code map

SectionIdeaDemo in code/lecture10/
§1–§2where the energy goes; instruction overhead; data movement01_energy_model.py
§3.3a matrix unit on the author’s laptop04_matrix_unit
§3.4number formats03_number_formats.py
§4the TPU’s systolic array02_systolic_array.py

Run them all with cd code/lecture10 && make run (~5 seconds).

0.4 Notation

  • pJ = picojoule = 10⁻¹² J. Perf/W (每瓦性能) = operations per second per watt = operations per joule. MAC = multiply-accumulate (one FMA, 2 FLOPs).
  • FP32/BF16/FP16/FP8: floating-point formats with 32/16/16/8 bits (§3.4).

1. Energy-constrained computing

1.1 Everyone is power-limited

Slides 2–4. Mobile devices are limited by battery life and by heat dissipation without a fan. Supercomputers and datacenters are limited by sheer scale: hundreds of thousands of CPUs and GPUs need power, and cooling for the heat it becomes. AI demand is growing exponentially, and datacenters for AI are heavily energy-constrained.

1.2 Power = throughput × energy per operation

Slide 5:

Power = (ops / second) × (joules / op)

If power is fixed (by a battery, a cooling system or a power contract), the only way to get more operations per second is to spend fewer joules per operation. Better energy efficiency is higher performance. The slide’s answer to “how?” is specialization (fixed-function hardware), and the question for the rest of the lecture is how large the improvement can be.

01_energy_model.py, Part C makes it concrete for a 10 W budget: ~1 nJ per useful operation (a general-purpose core with all its overheads) gives 10 Gops/s; a GPU-style core, ~10× better, gives 100 Gops/s; a fixed-function ASIC at ~3 pJ gives over 3 Tops/s.


2. Why general-purpose processors are inefficient

Slide 7 anticipates the objection: this entire course has been about using multi-core CPUs and GPUs efficiently, and now they are “inefficient”? Yes, relative to what the arithmetic itself costs.

2.1 The life of one instruction

Slide 8 lists what executing one instruction involves on a modern processor:

  1. read the instruction: address translation, instruction-cache access;
  2. decode it: translate it to micro-ops, micro-op cache;
  3. check for dependencies and pipeline hazards;
  4. identify an available execution resource;
  5. use the decoded operands to control the register file SRAM (read data);
  6. move data from the register file to the execution unit;
  7. perform the arithmetic operation;
  8. move the result back to the register file;
  9. control the register-file write.

Only step 7 is the operation the program wanted. The slide’s review question: how does SIMD reduce this overhead, and what properties must a computation have? SIMD runs steps 1–6 and 8–9 once for many operations, which requires the same instruction for many data elements (Lecture 2).

2.2 Measured: an H.264 encoder

Slide 9 (Hameed et al., ISCA 2010) breaks down the energy of an H.264 video encoder on a general-purpose processor into functional units (FU), register fetch (RF), pipeline control (Ctrl), pipeline registers (Pip), data cache (D-$) and instruction fetch (IF). The functional units consume a small fraction of the energy, even after the encoder was rewritten with SIMD instructions. The rest is overhead. The paper’s ASIC for the same encoder was hundreds of times more energy-efficient.

2.3 The model of demo 01

Slides 31–32 give the numbers that explain such breakdowns. Slide 31’s ballparks (Bill Dally, Tom Olson), counting only the logic of the operation:

operationenergy
integer op~1 pJ
floating-point op~20 pJ
read 64 bits from a small local SRAM ~1 mm away~26 pJ
read 64 bits from low-power mobile DRAM~1,200 pJ

Slide 32 estimates the overhead of programmability (instruction stream, control) relative to the arithmetic:

instructionFMAs per instructionoverhead (slide 32)model: 20 FMAs of fixed cost per instruction
half-precision FMA12000%2000%
half-precision DP4 (4-element dot product)4500%500%
half-precision 4 × 4 matrix multiply-accumulate6427%31%
H100 tensor-core 16 × 16 × 16 MMA4,096—0.5%

All three of slide 32’s numbers fit one simple model: a fixed cost per instruction of about 20 FMAs’ worth of energy, spread over the operations the instruction performs. The principle, in the slide’s words: amortize the cost of instruction stream processing across many operations of a single complex instruction.

Data movement is the other half. Demo 01, Part B estimates the energy per FLOP of a matrix multiply:

implementationDRAMSRAMinstruction overheadarithmetictotal, pJ per FLOP
textbook loop, every operand from DRAM, scalar6001320010823
cache-blocked (64 × 64 tiles), NEON9.413501082
+ register blocking (Lecture 9’s 8 × 12 kernel)9.42.7501072
matrix unit with 256 × 256 on-chip tiles (TPU-like)2.30.1~01012

With no reuse, each FLOP costs ~80× its arithmetic, almost all of it DRAM traffic. Lecture 9’s blocking fixed most of that, an energy optimization as much as a speed one, and left the instruction overhead as the largest remaining cost. Only a specialized unit that executes large tiles per instruction, and passes operands between neighbouring cells instead of through register files, gets the arithmetic to dominate.

2.4 How large are the gains?

Slide 10 (Chung et al., MICRO 2010) compares FFT implementations on CPUs, GPUs, FPGAs and an ASIC. An ASIC delivers the same performance as one CPU core with ~1/1000th the chip area; GPU cores are ~5–7× more area-efficient than CPU cores. Measured by power, the ASIC matches a CPU core using ~1/100th of the power.

Slide 18’s rules of thumb, compared with high-quality C code on a CPU:

  • throughput-maximized processors (GPU cores): ~10× better performance per watt, if the code maps well to wide data-parallel execution and is compute-bound;
  • fixed-function ASICs: 100–1000× or more, if the code is compute-bound and not floating-point math.

3. The spectrum of specialized hardware

3.1 DSPs, Anton, FPGAs

  • Digital signal processors (slide 11): still programmable, but with simpler instruction-stream control and complex instructions that do many operations each. Qualcomm’s Hexagon DSP (in Snapdragon phone chips, e.g. Google Pixel) uses VLIW (“very long instruction word”: one instruction specifies several different operations, unlike SIMD’s one operation on many data). In the inner loop of an FFT it performs 29 RISC-like operations per cycle. It is used for the modem, audio and, increasingly, image processing.
  • Anton (slide 12, D. E. Shaw Research): a supercomputer for molecular dynamics. It has ASICs for particle-particle interactions (512 of them in Anton 1, 2008), a throughput subsystem for FFTs, and a custom low-latency network shaped for N-body communication. Anton 3 (2025) is about 20× faster than a contemporary GPU for its task.
  • FPGAs (slides 14–17): a middle ground between an ASIC and a processor. The chip provides an array of logic blocks connected by programmable interconnect, and the programmer’s logic is implemented directly in them. The basic element is a lookup table (LUT, 查找表): a 6-input LUT is a 64-entry truth table that can implement any 6-input boolean function. A 40-input AND takes eight LUT6s chained, with a delay of 3 levels. Modern FPGAs add “hard” blocks: SRAM memory blocks, DSP multiplier blocks, even ARM or RISC-V CPUs. FPGAs are programmed in hardware description languages such as Verilog, and are rentable in the cloud (Amazon EC2 F1/F2).

3.2 Efficiency vs. programmability

Slide 19 (after Pat Hanrahan) orders the options:

efficiency vs. an energy-optimized CPUprogrammability
throughput processor (GPU)~10×easy to program
programmable DSP~20×
domain-specific accelerator (Google TPU)~50×? (jury still out)limited domain, programmed with DSLs (e.g. for DNNs)
FPGA / reconfigurable logicdifficult to program (an active research area)
ASIC (video encode/decode, audio playback, camera RAW processing, neural nets?)~100–1000×not programmable; costs tens to hundreds of millions of dollars to design, verify and manufacture

Every step to the right of a CPU buys efficiency with generality. The rest of the lecture is about where AI hardware sits on this line.

3.3 Found on the author’s laptop: a matrix unit

Lecture 9 ended with Apple’s Accelerate library computing a matrix multiply 6.5× faster than our best code on all 8 performance cores. 04_matrix_unit measures it properly against Lecture 9’s NEON micro-kernel. The comparison is in GFLOP/s; every result is checked against a double-precision reference:

nNEON, 1 coreNEON, 8 coresAccelerate, 1 threadAccelerate, default
12873431,5731,525
5121164081,7363,002
20481187181,6373,276
4096—7801,5162,824

Accelerate does not use the NEON units for this. The M4 has dedicated matrix hardware: Arm’s Scalable Matrix Extension (SME), the descendant of the “AMX” coprocessor in earlier Apple chips. Apple does not document it publicly, so what follows is inferred from timings:

  • One thread driving the matrix unit reaches 1.6 TFLOP/s: 14× one NEON core, and 2.3× all eight NEON cores together.
  • More threads give 2×, not 8×: consistent with one matrix unit per 4-core performance cluster (this chip has two).
  • The largest gap is for small matrices (35× at n = 128), and that is our fault: the NEON code starts 8 threads per call (~20 µs each), far too much for a 4-MFLOP problem, while the matrix unit already runs at 1.5 TFLOP/s.

Slide 43 says of NVIDIA GPUs that “all the TFLOPS are in the tensor cores”. On this laptop, the same holds for the CPU: a matrix multiply belongs on the matrix unit. What we cannot measure is the energy, the lecture’s real argument. Demo 01’s model predicts the energy gap is at least as large as the speed gap.

3.4 Number formats

Slide 33 and Lecture 9’s slide 70: AI hardware uses narrow number formats. A floating-point value is (−1)^S × 1.M × 2^(E − bias); fewer bits mean less memory traffic and cheaper arithmetic. 03_number_formats.py emulates the formats in numpy (round to nearest even, subnormals, saturation):

formatbitsexponent / mantissalargest valuerelative step
FP32328 / 233.4 × 10³⁸1.2 × 10⁻⁷
BF16168 / 73.4 × 10³⁸ (FP32’s range)7.8 × 10⁻³
FP16165 / 1065,5049.8 × 10⁻⁴
FP8 E5M285 / 257,3440.25
FP8 E4M384 / 34480.125

BF16 keeps FP32’s exponent (“same range as FP32, but lower accuracy”), which is why it is easy to switch training to. The two FP8 formats trade range against precision (E5M2: range, E4M3: precision; E4M3 gives up infinities to reach 448).

Three lessons from the demo:

  1. Multiply low, accumulate high. A 4,096-long dot product with BF16 inputs has a relative error of 4 × 10⁻⁵ when the running sum is kept in FP32. When the sum itself is kept in BF16, the error is 75%: the sum stops growing near 256, where BF16’s rounding step reaches 2 and every new product in [0, 1) is rounded away (swamping). FP8 sums fail almost at once (98%). This is why tensor cores take FP16/BF16/FP8 inputs and accumulate in FP32 (slide 35: A and B in FP16, D in FP32).
  2. Scale factors. Activations up to ~2,300 do not fit E4M3 (max 448): rounding directly clips 46% of them, a worst-case error of 81% of the maximum. Dividing by a per-tensor scale first, and multiplying back afterwards, brings the error to 3.6%. 8-bit formats are used with a scale factor per tensor (or per block of a tensor).
  3. Cost. An array multiplier’s area and energy grow roughly with the square of the significand width. As a rule of thumb, BF16’s multiplier is ~9× cheaper than FP32’s and FP8’s ~36–64× cheaper, and each value moves 2× or 4× fewer bytes. Slide 41’s H100: 67 TFLOP/s FP32 and 134 TFLOP/s FP16 on the SIMD units, 989 TFLOP/s FP16 on the tensor cores. Narrow formats and matrix instructions multiply together.

4. What an ideal AI accelerator looks like

4.1 Requirements

Slides 20–23. AI progress has relied on hardware improvement as much as on algorithms. Today’s high-performance models run on GPUs, because their computations resemble dense matrix multiplication with high arithmetic intensity, GPUs are flop-rich, and optimized kernel libraries exist (cuDNN). But slide 22 asks: why might a GPU be a sub-optimal platform? Is a general-purpose processor even needed?

An ideal AI model accelerator (slide 23) has:

  • high peak TFLOP/s and high energy efficiency;
  • high memory bandwidth;
  • simple programming for high performance;
  • performance that reaches the bound on compute-bound models and on bandwidth-bound ones.

4.2 Its features

Slides 24–29:

  • Asynchronous (non-blocking) execution (slide 24): start later operations before earlier ones complete, so that load 1 overlaps compute 0, which overlaps store −1 (Lecture 9’s pipelining). Lecture 11 is about programming this.
  • AI models are dataflow graphs (slide 25): operators (GEMM, pooling, softmax, …) connected by tensors, with weights as inputs. The hardware should execute graphs, not instruction streams.
  • Tiled tensors (slide 26), e.g. 16 × 16 or 32 × 32 tiles, as the unit of work: maximum TFLOP/s on GEMM and low instruction overhead. The tiled programming models CUTLASS, Triton and ThunderKittens (Lecture 9) already work this way. GEMM computation is cheap, but data movement is expensive in silicon area, watts and nanoseconds.
  • Minimize the cost of data movement (slide 27): asynchronous compute, asynchronous memory access, and asynchronous chip-to-chip communication, so that compute, memory and communication all overlap.
  • Avoid off-chip data access (slide 28): compute unit to compute unit communication, fusion and pipelining, streaming dataflow.
  • Special instructions (slides 29–32) that amortize the overhead of the instruction stream (§2.3), and number formats that make each operation and each byte cheaper (§3.4).

5. GPUs become AI accelerators

Slides 35–47 trace how NVIDIA’s GPUs added these features:

  • A100 (2020, slide 35): each of its 108 SMs has 64 FP32 ALUs, 32 INT32 ALUs and 4 tensor cores. A tensor core executes an 8 × 4 by 4 × 8 matrix multiply-add (A × B + D, with A and B in FP16 and D in FP32) as a single instruction. The chip: 19.5 TFLOP/s FP32 on the ALUs, 312 TFLOP/s FP16/FP32 mixed on the tensor cores.
  • H100 (2022, slides 36–41): fourth-generation tensor cores (16 × 16 × 16 FP16 MMAs), the Tensor Memory Accelerator (TMA), thread-block clusters, HBM3 with up to 80 GB, 80 billion transistors on TSMC 4 nm. The CUDA hierarchy now maps onto the hardware hierarchy: grid → GPU (80 GB HBM, 50 MB L2); cluster → a group of SMs (up to 16 thread blocks guaranteed to run at the same time on different SMs, sharing their shared memories); thread block → SM (256 KB of shared memory); threads → SIMD lanes. The TMA (slide 40) copies a whole region of a tensor between global and shared memory asynchronously. A single thread issues it with a copy descriptor that describes the region; hardware generates the addresses and signals a barrier when the copy is complete. The whole H100 (slide 41): 144 SMs; tensor cores 989 TFLOP/s FP16; SIMD units 134 TFLOP/s FP16, 67 FP32.
  • All the TFLOPS are in the tensor cores (slide 43): across generations, 89–98% of a GPU’s peak arithmetic is in its tensor cores.
  • Chips keep specializing (slide 44), V100 → A100 → H100 → B100: tensor-core sparsity, FP8 then FP4 formats, a “transformer engine”, asynchronous copies, distributed shared memory, DPX instructions (dynamic programming), L2 cache residency control, a decompression engine. The slide’s question: what are the implications for programmers?
  • B100’s tensor cores (slide 45): operands live in shared memory and a new tensor memory (TMEM), because register-file bandwidth can no longer feed the tensor cores. A single thread issues an MMA, so there are no more warps in the inner loop. Programming them means allocating TMEM and descriptors (tcgen05.alloc), streaming tiles with the TMA (cp.async.bulk.tensor, coordinated with mbarrier), launching asynchronous MMAs (tcgen05.mma, tcgen05.commit) and ordering their retirement (tcgen05.fence). “Not your father’s CUDA.”
  • DSLs for GPU AI kernels (slide 46): Mosaic GPU, CuTe-DSL (CUTLASS in Python), and others.

How ideal are GPUs (slide 47)? Tiled tensors with low instruction overhead: ✅. Asynchronous compute: ✅ (mma_async). Asynchronous memory access: ✅ (TMA + TMEM). Asynchronous chip-to-chip communication and compute-unit-to-compute-unit streaming dataflow: ❓ (thread-block clusters are a step).


6. Google’s TPU and the systolic array

6.1 The TPU

Slides 48–51: everyone is building AI silicon (AWS Trainium, Google TPU, Apple Neural Engine, Intel, SambaNova, Cerebras, NVIDIA’s tensor cores…). Google’s TPU v1 (Jouppi et al., 2017) is the classic case. Its die is dominated by a 256 × 256 matrix multiply unit and on-chip buffers. Arithmetic units take ~30% of the chip, and control takes very little area. It has a handful of key instructions: read host memory, write host memory, read weights, matrix_multiply/convolve, activate. One instruction drives 65,536 multiply-accumulators.

6.2 How a systolic array multiplies

Slides 52–58 show a weight-stationary systolic array for y = W x. PE(k, j) holds weight w_jk and never moves it. Inputs flow right along rows, partial sums flow down columns, and output y_j leaves the bottom of column j. Inputs enter skewed: x_k one cycle after x_(k−1), so that each input meets the right partial sum at the right PE. 02_systolic_array.py simulates it cycle by cycle and traces the slides’ 4 × 4 example symbolically. Each cell shows the partial sum it passes down:

cycle 1:  row 0 | .                | x0*w10           | .  | .
          row 1 | x0*w00 + x1*w01  | .                | .  | .
cycle 3:  row 0 | .                | .                | .                 | x0*w30
          row 1 | .                | .                | x0*w20 + x1*w21   | .
          row 2 | .                | x0*w10 + x1*w11 + x2*w12 | .         | .
          row 3 | x0*w00 + x1*w01 + x2*w02 + x3*w03 | . | .              | .

y₀ = x₀w₀₀ + x₁w₀₁ + x₂w₀₂ + x₃w₀₃ is complete after 4 cycles; y₃ after 7. For a matrix-matrix product Y = W X (slide 58), the input vectors follow each other one per cycle. The array is a pipeline: B vectors take B + K + M − 2 cycles on a K × M array. Products checked against numpy:

arrayvectors BcyclesPE utilization
4 × 41714%
4 × 4323884%
16 × 161313%
16 × 1625628690%

Systolic arrays need large batches, just as GPUs need many threads.

6.3 SIMD vs. systolic

Slide 59 compares the two styles:

SIMDsystolic array
dataflowcontrol-driven (instructions)data-driven (wavefront)
locality (data reuse)limitedtemporal and spatial
communicationglobal (register file / memory)local (neighbour PEs)
controlcentralizeddistributed
efficiency (perf/mm², perf/W)mediumvery high

Demo 02, Part C counts it for a 16 × 16 array and 256 vectors. Per multiply-add, only 0.13 words come from a buffer or memory: weights once, each input once, each output once. The rest, 1.88 words per MAC, moves between adjacent PEs over short wires, with no register file and no instruction per operation. A SIMD FMA instruction reads three registers and writes one, for every lane, every time.

6.4 Larger products and the TPU’s evolution

Slide 60: a product larger than the array is tiled. Demo 02, Part D computes C (8 × 4096) = A (8 × 8) B (8 × 4096) on a 4 × 4 array, with A cut into four 4 × 4 weight tiles and 4,096 accumulators. The result is correct, utilization is 99.9%, and each value of B is read twice, once per tile row of A. The array size sets the reuse, as the cache size did in Lecture 9.

Slides 64–65: TPU v1 had much higher performance per watt than the contemporary CPUs and GPUs on Google’s inference workloads (both counting the host machine and counting the TPU alone). Later TPU generations added floating point for training (BF16 was invented for TPUs), HBM and high-bandwidth chip-to-chip links for pods of thousands of chips.


7. The hardware lottery and dataflow processors

7.1 The hardware lottery

Slide 66 quotes Sara Hooker: “a research idea wins because it is suited to the available software and hardware, and not because the idea is universally superior to alternative research directions.” TPUs specialize for dense matrix multiplication, whose operational intensity grows with n. Transformer models are built almost entirely from dense MMs, so transformers run superbly on TPUs and GPUs, so research designs more transformer models, so the next hardware specializes further for matrix multiplication. Specialization feeds back into which algorithms are explored.

7.2 Reconfigurable dataflow

Slides 67–70: if AI models are dataflow graphs (GEMMs plus parallel patterns such as map, filter and reduce), build a dataflow processor. Plasticine (Prabhakar et al., ISCA 2017), which became SambaNova’s reconfigurable dataflow architecture (RDU), is a grid of pattern compute units (PCUs) and pattern memory units (PMUs) connected by switches. A model is laid out spatially on the chip: each operator gets its own units, and data streams from one unit to the next.

Against the ideal accelerator (slide 69):

  • it has no instructions, so there is no fetch/decode overhead;
  • its asynchrony is extreme: there is no sequential instruction execution at all, only data flowing when it is ready;
  • dataflow kernel fusion (slide 70) runs a whole FlashAttention block (Q Kᵀ → mask → softmax → dropout → × V) as a metapipeline: different tiles occupy different stages at once, and intermediates pass between PMUs instead of through memory.

Lecture 11 programs this kind of machine.

7.3 Summary (slide 71)

Specialized hardware for executing key DNN computations efficiently features:

  • many arithmetic units;
  • customized or configurable datapaths that move intermediate data directly between processing units, scheduling computation by laying it out spatially on the chip, at multiple granularities;
  • large amounts of on-chip storage for fast access to intermediates.

Summary

  • Computing is energy-constrained, and Power = ops/s × J/op: under a power limit, better energy efficiency is the only way to more performance.
  • A general-purpose instruction spends most of its energy on fetch, decode, control and register-file traffic. Slide 32’s 2000% / 500% / 27% overheads fit one fixed cost per instruction spread over its operations. Data movement from DRAM costs ~60× an FP operation.
  • Specialization gains ~10× (GPUs) to 100–1000× (ASICs) in perf/W by amortizing instruction overhead over large operations and keeping data local. It costs programmability, along a spectrum from CPUs to ASICs.
  • AI accelerators combine tiled matrix instructions, asynchronous compute and data movement, on-chip reuse (fusion, streaming dataflow) and low-precision formats (multiply in BF16/FP8, accumulate in FP32, with scale factors).
  • GPUs became AI accelerators: tensor cores hold ~90–98% of their FLOPS, plus TMA, clusters, TMEM and FP8/FP4. On the author’s laptop, a matrix unit does 1.6 TFLOP/s from one thread, 14× a NEON core.
  • A systolic array passes data only between neighbours, so a matrix product needs ~0.1 buffer words per MAC; it needs large batches to fill its pipeline.
  • Specialization shapes research (the hardware lottery). Dataflow architectures remove instructions altogether.

Common pitfalls

  • Measuring “efficiency” by speed alone. The slides’ argument is energy per operation. On a power-limited system it determines speed, but the two are not the same measurement.
  • Comparing a specialized unit against unoptimized general-purpose code. Our first comparison included thread start-up overhead in the NEON code: the gap at n = 128 was mostly our software.
  • Accumulating in a low-precision format. Multiply in BF16 or FP8 if you like, but keep the running sum in FP32.
  • Using FP8 without scale factors. Values outside the format’s tiny range clip.
  • Feeding a pipeline too little work. A systolic array, like a GPU, is efficient only with large batches or tiles.
  • Assuming the vendor library uses the hardware you think it uses. Accelerate’s SGEMM never touches NEON for large matrices.

Exercises

  1. Power budget. A phone chip may dissipate 5 W for its neural-network accelerator. How many INT8 MAC operations per second can it sustain at 0.5 pJ per MAC (arithmetic only)? At 5 pJ including overheads? What limits real chips below that?

    Answer5 W / 0.5 pJ = 10¹³ MAC/s (10 TMAC/s); at 5 pJ, 10¹² MAC/s. Real chips spend energy on moving weights and activations (an LPDDR access is ~1,200 pJ per 64 bits), control and leakage, so sustained throughput depends on reuse in on-chip memory.
  2. Instruction overhead. With the fixed-cost model (20 FMAs’ worth of overhead per instruction), what fraction of the energy is arithmetic for a 4-wide NEON FMA, a 32-wide warp FMA, and an 8 × 4 × 8 tensor-core MMA (256 FMAs)?

    AnswerFraction = n / (n + 20): 4 → 17%; 32 → 62%; 256 → 93%.
  3. Systolic timing. A 128 × 128 weight-stationary array processes a batch of B input vectors. How many cycles until all outputs are out, and how large must B be for 95% utilization?

    AnswerB + K + M − 2 = B + 254 cycles. Utilization B / (B + 254) ≥ 0.95 gives B ≥ 4,826 vectors.
  4. Tiling on a systolic array. C = A B with A 512 × 512 and B 512 × 4096 on a 128 × 128 array with 4096 accumulators per column. How many weight tiles are loaded, and how many times is each value of B read?

    AnswerA splits into (512/128)² = 16 weight tiles. Each value of B is read once per tile row of A that uses it: 4 times. Total reads of B: 4 × 512 × 4096 ≈ 8.4M values, for 1.07 G MACs, i.e. one read per 128 MACs.
  5. BF16 swamping. A running BF16 sum adds values in [0, 1). Why does it stop growing near 256? At what value would an FP16 sum stop?

    AnswerWith 7 mantissa bits, numbers in [256, 512) are spaced 256 × 2⁻⁷ = 2 apart. Adding p < 1 rounds back down to the same value. FP16 has 10 mantissa bits: spacing reaches 2 at 2048 (2048 × 2⁻¹⁰ = 2), so an FP16 sum of values < 1 stalls near 2048.
  6. Where to specialize. For each, would you choose a GPU, an FPGA or an ASIC, and why? (a) video decoding in a phone; (b) research on new neural-network layer types; (c) a network packet filter whose rules change monthly.

    Answer(a) ASIC: a fixed, standardized, high-volume function under a strict energy budget. (b) GPU: programmability matters more than the last factor of efficiency, and the software ecosystem exists. (c) FPGA: bit-level, latency-critical processing that must be reconfigured as the rules change, without the cost of a new ASIC.

Programming Assignment 4 runs on AWS Trainium2, an AI accelerator of exactly this lecture’s kind: a large systolic matrix engine, vector and scalar engines, explicitly managed on-chip SRAM, and DMA engines for asynchronous data movement. You fuse a convolution with max pooling (Lecture 9) by tiling data into its on-chip memories. Lecture 11 covers the programming model. These notes give no solution.

Further reading

  • The Fall 2025 slides for this lecture and the 2023 lecture video.
  • R. Hameed et al., “Understanding Sources of Inefficiency in General-Purpose Chips”, ISCA 2010 (the H.264 study of slide 9).
  • E. S. Chung et al., “Single-Chip Heterogeneous Computing: Does the Future Include Custom Logic, FPGAs, and GPGPUs?”, MICRO 2010 (slide 10).
  • M. Horowitz, “Computing’s Energy Problem (and what we can do about it)”, ISSCC 2014: the energy-per-operation tables behind slide 31.
  • H. T. Kung, “Why Systolic Architectures?”, IEEE Computer, 1982.
  • N. P. Jouppi et al., “In-Datacenter Performance Analysis of a Tensor Processing Unit”, ISCA 2017; and “Ten Lessons From Three Generations Shaped Google’s TPUv4i”, ISCA 2021.
  • S. Hooker, “The Hardware Lottery”, CACM 64(12), 2021.
  • R. Prabhakar et al., “Plasticine: A Reconfigurable Architecture for Parallel Patterns”, ISCA 2017.
  • P. Micikevicius et al., “FP8 Formats for Deep Learning”, 2022.

Preview of Lecture 11 — Programming systems for specialized hardware

Specialized hardware is fast only if programs keep it busy. That means overlapping data movement with computation (asynchrony), thinking in tiles instead of threads, and, for dataflow machines, laying the computation out in space as a pipeline of pipelines (a “metapipeline”). Lecture 11 looks at how to program an H100 near its peak (TMA, warp specialization, producer/consumer pipelines), at tile libraries such as ThunderKittens, and at dataflow programming with parallel patterns.


术语表 (Glossary, English → 中文)

English中文
energy-constrained computing能耗受限计算
energy per operation / perf per watt每次操作能耗 / 每瓦性能
specialization / fixed-function hardware专用化 / 固定功能硬件
instruction overhead (fetch, decode, control)指令开销(取指、译码、控制)
register file寄存器堆
functional unit功能单元
ASIC (application-specific integrated circuit)专用集成电路
DSP (digital signal processor) / VLIW数字信号处理器 / 超长指令字
FPGA (field-programmable gate array)现场可编程门阵列
lookup table (LUT)查找表
hardware description language (Verilog)硬件描述语言
efficiency vs. programmability效率与可编程性
domain-specific accelerator领域专用加速器
asynchronous execution异步执行
dataflow graph / streaming dataflow数据流图 / 流式数据流
tensor core / matrix multiply-accumulate (MMA)张量核心 / 矩阵乘累加
Tensor Memory Accelerator (TMA)张量内存加速器
thread-block cluster线程块簇
number format: FP32 / BF16 / FP16 / FP8数值格式
exponent / mantissa (significand)指数 / 尾数(有效数字)
swamping (in accumulation)淹没(累加中小数被舍去)
scale factor缩放因子
TPU (tensor processing unit)张量处理单元
systolic array / processing element (PE)脉动阵列 / 处理单元
weight-stationary权重驻留
pipeline fill and drain流水线填充与排空
hardware lottery硬件彩票
reconfigurable dataflow architecture可重构数据流架构
metapipeline元流水线
matrix unit (SME / AMX)矩阵计算单元
← 返回课程目录