GPU Kernels Explained
How a GPU actually executes the maths.
An interactive guide to how a GPU runs kernels, from the A100 to Blackwell: the memory hierarchy, warps, coalescing, occupancy, GEMM, FlashAttention and the warp-specialised tensor-core pipeline, each animated by a tested execution model.
How this is checkedThe GPU model is checked against the CUDA Programming Guide's worked examples (coalescing, bank conflicts, occupancy), and its TypeScript port reproduces the Python reference exactly. How it is tested →
What you'll learn
A GPU can do arithmetic far faster than it can fetch the numbers to do it on. A B200's tensor cores need 313 flops of BF16 work on every byte from its HBM just to keep busy (1,250 at NVFP4); an H100's needed 295 and an A100's 201. Every fast kernel is a way of closing that gap: reuse data close to the ALUs, fetch it in whole transactions, avoid serialising on shared memory, keep the tensor cores fed from a pipeline of loads. Chapter 12 shows how Hopper and Blackwell kernels do it.
Each chapter here is built around an animation, and every frame is computed by a small GPU execution model that is tested against a Python reference. The hardware figures come from NVIDIA's whitepapers and datasheets, the CUDA Programming Guide and published microbenchmarks.
01
The memory hierarchy
Registers, shared memory, L2 and HBM: how much each holds, how fast it moves data, and which one sets a kernel's pace.
02
The roofline
Arithmetic intensity decides whether a kernel waits on memory or on the ALUs; the ridge point is where they meet.
03
Warps, SIMT and divergence
32 threads share one instruction stream; a branch they disagree on runs both ways, with lanes masked off.
04
Coalescing
How a warp's 32 addresses become 32-byte memory transactions, and what stride and alignment cost.
05
Shared-memory bank conflicts
32 banks, one word each per cycle: why a column read serialises 32 ways, and how one word of padding fixes it.
06
Occupancy
Registers, shared memory and warp slots decide how many blocks share an SM, and so how much latency it can hide.
07
GEMM, step by step
Naive, tiled in shared memory, register-blocked, tensor cores: each step reuses data closer to the ALUs and raises the arithmetic intensity.
08
Reductions and warp shuffles
Summing a block's values as a tree in shared memory, three ways, then register to register with warp shuffles.
09
Softmax and FlashAttention
Online softmax keeps a running maximum and rescales; FlashAttention uses it to never write the score matrix to HBM.
10
Split-K, streams and overlap
Double buffering hides copies behind compute; split-K makes enough blocks to fill the GPU when the output is small.
11
Quantised kernels
Low-precision weights cut the bytes a decode step reads; the kernel dequantises them in registers, just before the multiply.
12
Hopper and Blackwell GEMM
TMA fills a ring of shared-memory stages while one thread issues the tensor-core MMAs: warp specialisation, wgmma to tcgen05 and Tensor Memory, and FP8 and FP4 with block scaling.
Every number on the GPUs the model uses, with its source: the GPU presets.
New to the Hardware track? Start here: the four sites in reading order, what you need first, and a glossary of the terms they define.
Built by a hardware engineer
The author designs hardware: the RTL, SoC and signal-integrity work behind this track is public too.
- The author's portfolio: Everything in one place: the hardware work, the explainer sites, the deck series and how every number is checked.
- A transformer decoder in RTL: SystemVerilog with 84 passing tests (a Python golden model and cocotb), synthesised in Vivado 2025.2 for an Artix-7: its 4 × 4 systolic array is 455 LUTs, 901 flip-flops and 16 DSPs at 156.8 MHz (the README's synthesis table).
- The decoder, module by module: A walkthrough of every RTL module, the verification and the synthesis numbers.
- RTL challenges for LLM accelerators: Systolic array, mixed-precision MAC, softmax pipeline, KV cache and more, each simulated (two run inside Systolic Arrays Explained).
- FPGA design challenges: FPGA architecture, synthesis, timing closure and the Vivado and Quartus flows, with RTL exercises.
- A five-stage RISC-V SoC: BRV32P: a pipelined RV32IMC core with caches and an AXI4-Lite fabric in Verilog, and a MESI cache controller (Cache_Controller_MESI).
- Modern SoC design: Slide decks from chiplets and advanced packaging to on-chip interconnects and silicon implementation.
- Equalisation in high-speed serial links: One 28 GBd backplane channel end to end: S-parameters, CTLE, FFE and DFE, a noise budget.
- Signal integrity: Seventeen decks on getting a signal from one chip to another intact, every number computed by a model.
- All the hardware decks: RISC-V, Arm, AMBA, simulators, photonics and more.
Part of a family of sixteen companion sites in four tracks, all in the site menu above: Foundations (Decoder, Training), Hardware (Kernels, Systolic, Accelerators, Racks), Inference (Serving, Architectures, Numerics, Trade-offs) and Agents (Harnesses, Protocols, Context, Orchestration, Evals, Security). This site is the layer underneath: the kernels. How it was built, and how to check it: about.