Master the fundamental concepts of gpu architecture through this focused micro-challenge.
GPUs expose a multi-level memory hierarchy that programmers often manage explicitly. Understanding each level is essential for writing efficient compute kernels and shaders.
If a kernel uses too many registers, the compiler spills them to local memory backed by VRAM. That spill is orders of magnitude slower than keeping values in registers. This tradeoff is called register pressure.
GPUs have enormous bandwidth but terrible latency. The scheduler hides latency by switching to other ready warps while one warp waits on a global load. For example, a kernel that performs one global read per thread with low occupancy may stall frequently because too few warps are available to cover the ~400 cycle VRAM round trip.
cLoading…
Shared memory requires explicit allocation and copy. L1 cache is automatic but smaller. The key insight: maximize active warps and minimize global traffic through shared memory staging and coalesced access.
You will model latency and bandwidth at each hierarchy level and compute how many warps a kernel needs to hide global memory stalls. This task asks you to print per-level access costs and explain when register spills would hurt occupancy. The numbers you compute here connect directly to the coalescing and occupancy exercises that follow.
Write a C program that models GPU memory latency and bandwidth at each hierarchy level.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github