My notes on Otterness & Anderson’s paper (UNC Chapel Hill, Real-Time Systems 2022 / RTNS 2021). Everything was measured on a Radeon VII with ROCm 4.2. One idea per note, plus a little toy you can poke at.
1. Open stack, no docs
ROCm is open source, but it’s huge and almost nothing about how it schedules work is written down. So the authors followed a kernel launch through every layer and mapped what happens. Here’s the stack, top to bottom.
2. Streams: ordered inside, parallel across
A kernel is a pile of thread blocks, up to 1,024 threads each. Inside one HIP stream, work runs in order (FIFO). Across streams, work can overlap. That overlap is the whole reason scheduling matters.
3. Prior work is mostly NVIDIA
Earlier real-time GPU research mostly targeted NVIDIA, and since that stack is closed it relied on black-box tests, reverse engineering, or working with the vendor. AMD is open, so here they just read the source and then checked it with experiments.
4. The test GPU
A Radeon VII: 4 shader engines (SEs) with 15 compute units (CUs) each, so 60 CUs. One CU holds up to 2,048 threads, which means the whole GPU can have 122,880 threads resident at once.
5. Same math, different block sizes
Both tasks multiply 1,024×1,024 matrices, one thread per output. The only difference is block shape. MM1024 uses 1,024 blocks of 32×32 threads. MM256 uses 4,096 blocks of 16×16. One MM1024 block is the same work as four MM256 blocks, but the small ones can squeeze into gaps the big ones can’t use.
6. The weird numbers
Two things jump out. Under full sharing, MM256 is the nastiest neighbor you can pick. And the uneven split (an even split plus one CU borrowed from the competitor’s half) is roughly 10× slower than everything else.
Table 1, in ms (mean / worst case). Bars are on a 0–105 ms scale.
7. Streams share 4 queues
Your streams don’t each get their own queue. ROCclr maps them onto a shared pool of 4 HSA queues by default. Two streams that land on the same queue get serialized, even though you declared them independent. The way out: a stream created with a CU mask gets a dedicated queue.
8. Only 32 hardware queue slots
The hardware can run 32 queues at once: 4 ACEs × 8 slots. Go past that and the GPU time-slices all the queues, with no priority. For real-time work, the paper’s advice is to turn oversubscription off.
9. Small blocks cut ahead
ACEs hand out blocks in strict order. But when a big block doesn’t fit, small blocks from the other kernel take the freed space first, so MM256 ends up holding almost the whole GPU. Toy model of one CU (8 slots × 256 threads):
Illustration only. In the paper’s measured timelines, MM256 grabs nearly all GPU capacity once it starts.
10. One lone CU stalls everything
The ACE walks the shader engines in order, and it only skips an SE if every CU on it is masked off. Leave a single CU enabled and dispatch has to wait on that one contended CU every lap around.
Illustration. Measured effect: 7.6 ms → 101.5 ms worst case for MM1024 vs. MM256.
11. CU masks interleave across SEs
You set masks at stream creation with hipExtStreamCreateWithCUMask. Mask bits interleave across the SEs (bit i goes to SE i mod 4), so the layout you pick matters. For uneven splits, spreading CUs across all SEs beats packing whole SEs.
Table 2 values, in ms. The grid shows each layout schematically.
12. Other AMD gotchas
If you’re porting from CUDA, be careful: NVIDIA doesn’t let small blocks cut ahead, so ported code might quietly depend on that ordering. Queue multiplexing is another source of contention, and one environment variable tunes it.
GPU_MAX_HW_QUEUES=8 ./app changes the HSA queue pool size (default 4, see 7).13. Takeaways
If you want predictable latency on AMD GPUs, you have to know the internal scheduling rules, or you pay for it in worst-case response time.
- Mask whole SEs, or spread evenly. Never leave a lone CU on an SE.
- Watch block sizes. Smaller neighbor blocks can starve yours.
- Control queues. Mind the 4-queue pool and the 32-slot limit.
Source: Otterness & Anderson, “Exploring AMD GPU Scheduling Details by Experimenting With ‘Worst Practices’” — paper PDF. The toys in 9 and 10 are simplified illustrations, not the paper’s data.