Foundations to Frontier
Tests
C. Programming, Tools and HPC › C5 High-Performance Computing

GPU Architecture: SMs, Warps, Memory Types and Tensor Cores

GPUs trade the CPU's few fast cores for thousands of simple lanes that hide memory latency by switching between many threads. This topic explains the hardware a CUDA or Triton kernel runs on: streaming multiprocessors (SMs), warps of 32 threads executing in lockstep (SIMT), warp scheduling and latency hiding, occupancy and the resources that limit it (registers, shared memory, block counts), the memory spaces (registers, shared memory/L1, L2, HBM global memory, constant and local memory), coalescing, bank conflicts, branch divergence, and tensor cores for matrix math in FP16/BF16/TF32/FP8. In the exercises you compute occupancy with the A100's limits, count memory sectors for warp access patterns, detect divergence and shared-memory bank conflicts; then you simulate three matrix-transpose kernels warp by warp and sweep occupancy against register use.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

A stadium full of calculators

A CPU is a handful of very clever workers; a GPU is a stadium of tens of thousands of simple ones who all follow the same instructions together, in squads of 32. When one squad waits for data, another squad immediately takes over, so the stadium never idles. It works brilliantly when every worker does the same thing to different data (pixels, matrix entries, particles), and when the squad’s members ask for data that sits side by side in memory.

One warp, 32 threads: coalescing and bank conflicts
element:
32-byte sectors of global memoryblue: bytes the threads asked for · orange: sectors transferred
sectors: 4 · useful bytes 128 of 128 moved · efficiency 100.0%
Shared memory: each thread t reads tile[t][0] of a tile whose rows are 32 words wide
row width:
3232 banks; number = distinct words requested from that bank
bank conflict degree: 32 (32 serialized passes)
Rule of thumb: let thread t touch element t (stride 1, aligned) in global memory, keep structures of arrays rather than arrays of structures, and pad shared-memory tiles by one word so that walking a column spreads over all 32 banks.
Why engineers care

GPUs train every modern neural network and accelerate radiative transfer, CFD, Monte Carlo trajectory dispersions and SAR image formation. Embedded GPUs (Jetson-class) run perception on drones and rovers. Knowing warps, coalescing and occupancy is the difference between a kernel at 5% and at 80% of the hardware.

📝 Quick check (Level 0)
0/3 answered
  1. 1. How many threads are in a warp on NVIDIA GPUs?
  2. 2. GPUs hide memory waits by…
  3. 3. In the demo, which access pattern moves the fewest bytes?

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

The hardware

An NVIDIA GPU has many streaming multiprocessors (A100: 108 SMs; H100 SXM: 132). Each SM has integer and FP32/FP64 units, tensor cores, a large register file (64 K 32-bit registers), shared memory/L1 (up to 228 KB on H100), and warp schedulers. Threads are grouped into blocks (up to 1024 threads) that run on one SM and can cooperate through shared memory; blocks form a grid. The SM executes warps of 32 threads that share one instruction stream (SIMT).

Memory Scope Latency (approx.) Notes
registers thread ~1 cycle spills go to slow “local” memory
shared memory / L1 block / SM ~30 cycles 32 banks of 4 bytes
L2 whole GPU ~200 cycles 40–50 MB on A100/H100
global (HBM) whole GPU ~400–600 cycles 1.6–2 TB/s (A100), 3.35 TB/s (H100 SXM)
📝 Quick check (Level 1)
0/3 answered
  1. 1. Threads of one block can share data through…
  2. 2. SIMT means…
  3. 3. Roughly how much faster is A100 HBM than a desktop DDR4 channel (~25 GB/s)?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

Occupancy and latency hiding

Each SM can hold a limited number of resident warps (64 on A100), blocks (32) and threads (2048). Registers and shared memory are split among resident blocks, so a kernel using many registers per thread fits fewer warps. Occupancy = resident warps / maximum warps. More resident warps give the scheduler more independent work to switch to while others wait on memory (by Little’s law, bytes in flight = bandwidth × latency: about 0.8 MB across an A100). High occupancy is a means, not a goal: kernels that keep data in registers can be fast at 25–50%.

Memory access rules

  • Coalescing: global memory is served in 32-byte sectors (128-byte cache lines). If thread t of a warp reads element t, 128 bytes arrive in 4 sectors; strides or misalignment waste bandwidth.
  • Bank conflicts: shared memory has 32 banks of 4-byte words; threads of a warp hitting different words in one bank are serialized (the same word is broadcast). Padding a 32-wide tile to 33 columns makes column accesses conflict-free.
  • Divergence: if threads of a warp take different branches, the warp executes each path in turn with inactive lanes masked.
🐍 Exercise 1: occupancy, coalescing, divergence, banks
Using A100 (sm_80) limits, compute resident blocks, warps, occupancy and the limiting resource for a kernel's block size, registers and shared memory (with allocation granularities); count the 32-byte sectors and efficiency of a warp's global access pattern; count branch-divergence passes; and compute shared-memory bank-conflict degrees.
📝 Quick check (Level 2)
0/3 answered
  1. 1. 256-thread blocks using 64 registers per thread on A100: occupancy?
  2. 2. A warp reads float32 with stride 2 elements. Efficiency?
  3. 3. 32 threads read the same shared-memory word. Conflict degree?

Level 3: Advanced

★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.

Tensor cores

Tensor cores execute small matrix multiply-accumulates (for example a 16×8×16 FP16 MMA per instruction per warp) at a rate far beyond the scalar units: A100 reaches 312 TFLOPS dense FP16/BF16 versus 19.5 TFLOPS FP32 on its CUDA cores; TF32 (FP32 range, 10-bit mantissa) gives 156 TFLOPS for FP32 code; H100 adds FP8. Using them needs matrix shapes that are multiples of 8 or 16, low-precision inputs (C5.5) and data staged through shared memory, which is what cuBLAS, cuDNN, CUTLASS, Triton and torch.compile arrange.

Putting it together: matrix transpose

A transpose reads rows and writes columns. Naively one side is coalesced and the other strided. Staging a 32×32 tile in shared memory makes both global accesses coalesced, but reading a column of the tile hits one bank 32 times; padding the tile to 33 columns removes the conflict. This three-step progression (NVIDIA’s classic transpose example) captures most of GPU memory optimization.

📝 Quick check (Level 3)
0/3 answered
  1. 1. A100 dense FP16 tensor-core peak is roughly how many times its FP32 CUDA-core peak?
  2. 2. Why pad a shared-memory tile to 33 columns?
  3. 3. Tensor cores require…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

GPU memory behaviour, measured

Exercise 1. On sm_80 limits: 256 threads at 32 registers gives 8 blocks and 100% occupancy; at 64 registers, 4 blocks (50%, register-limited); 128 threads with 48 KB of shared memory, 3 blocks (shared-memory-limited); 32-thread blocks stop at the 32-block limit (50%); 1024 threads at 255 registers cannot launch. A coalesced float32 warp load uses 4 sectors, stride 2 uses 8 (50%), stride 32 uses 32 (12.5%), and a 4-byte misalignment adds one sector. Reading a column of a 32-word-wide shared tile is a 32-way conflict; a 33-word-wide tile is conflict-free.

Exercise 2: access patterns, transpose and occupancy.

Pattern (float32, one warp) efficiency
stride 1 / 2 / 4 / 8 / 16 / 32 100% / 50% / 25% / 12.5% / 12.5% / 12.5%
array of structures (3 floats), read x 33%
structure of arrays, read x 100%
Transpose kernel, 256×256 float32 global sectors shared-memory passes
naive 73 728 (4.5× ideal) 0
32×32 shared tile 16 384 (ideal) 67 584
32×33 padded shared tile 16 384 4 096

All three produce the correct transpose. Occupancy of 256-thread blocks with 32 / 40 / 48 / 64 / 96 / 128 / 255 registers: 100 / 75 / 62.5 / 50 / 25 / 25 / 12.5% (register allocation in units of 256 per warp makes 96 and 128 equal).

🐍 Exercise 2 (research): access patterns, transpose and occupancy
Measure sector efficiency for strided warp loads and for array-of-structures versus structure-of-arrays layouts; simulate naive, shared-memory tiled and padded tiled transposes warp by warp (global sectors, bank-conflict passes, correctness); sweep A100 occupancy against registers per thread and block size.

GPUs in AI, robotics and aerospace

  • Training and inference of neural networks: tensor cores for GEMMs and convolutions, memory-bound kernels for everything else.
  • Simulation: Monte Carlo dispersions with millions of independent trajectories, particle methods, lattice-Boltzmann CFD, ray tracing for radiation and sensor simulation.
  • Embedded: Jetson Orin-class modules run perception on robots and drones within tens of watts.
  • Ground processing: SAR focusing and hyperspectral pipelines on GPU clusters.

References

  1. NVIDIA (2024). CUDA C++ Programming Guide and CUDA C++ Best Practices Guide (docs.nvidia.com/cuda).
  2. NVIDIA (2020). NVIDIA A100 Tensor Core GPU Architecture (whitepaper); NVIDIA (2022). NVIDIA H100 Tensor Core GPU Architecture.
  3. M. Harris (2013). “An efficient matrix transpose in CUDA C/C++.” NVIDIA Technical Blog.
  4. V. Volkov (2010). “Better performance at lower occupancy.” GPU Technology Conference.
  5. D. B. Kirk, W. W. Hwu, I. El Hajj (2022). Programming Massively Parallel Processors, 4th ed. Morgan Kaufmann.