AMD's PC Sampling: Two Methods That Turn GPU Hotspot Hunting from Counter-Guessing into a Diagnostic Loop
A ROCm engineering blog details how software-based (host-trap) and hardware-based (stochastic) PC sampling complement each other to identify where GPU time is spent and why waves stall there. A worked GEMM example shows the full loop: host-trap pinpoints a single hot line, stochastic reveals 93% of stalls are WAITCNT on uncoalesced global loads, an LDS-tiling rewrite achieves ~3.0× speedup, and re-running both methods confirms the stall pattern shifted from memory-bound to issue-bound.
Hardware performance counters tell you a GPU kernel is memory-bound, that occupancy is low, or that L2 miss rates are high. They do not tell you which line of your code is responsible. This gap between aggregate metrics and source-level attribution is the problem AMD's ROCprofiler-SDK PC Sampling addresses, and a November 2026 blog post by Vladimir Indic walks through how two complementary methods close it.
PC sampling works by periodically capturing the program counter of executing waves on the GPU, then aggregating thousands of samples into a statistical hotspot profile. Unlike instrumentation-based approaches, it requires no kernel modification, no recompilation, and no serialization of concurrent execution. The sampled binary is the same binary that runs in production. The method resolves hotspots to individual instructions, and — when the binary carries debug symbols — maps them back to source lines.
The SDK provides two methods that target the same problem from different directions. Software-based host-trap sampling runs a background thread on the host CPU that periodically fires a trap signal broadcast to every compute unit. Each CU with a resident wave in the targeted slot pauses, captures its state (PC, exec mask, dispatch ID, wave coordinates), writes it to a GPU buffer, and resumes. The interval is specified in microseconds and the method is available on AMD CDNA GPUs starting with the MI200 series. Hardware-based stochastic sampling lives on each CU: every N GPU cycles, dedicated hardware picks one resident wave, snapshots its state, and writes it to a buffer. No host involvement. It requires CDNA 3 or later and adds four fields per sample: whether the wave issued an instruction that cycle, what type of instruction it was, the stall reason if it did not issue, and the number of waves resident on the CU.