Five things that bite every CUDA / Metal beginner
- Lock-step ≠ order. Threads in a warp share a program counter, but printouts can finish out of sequence because warps from different blocks interleave. Ant #128 often beats Ant #1.
- Too many ants → queue. Launch more blocks than your card has SMs to host concurrently and the extras simply wait their turn. Massive parallel? Yes. Unlimited? No.
- Clock math reality check. 2 GHz × 1,000 threads ≈ 2 million instruction slots per tick — impressive but bounded. Pipeline stalls, memory waits, and bank conflicts erode the headline number.
- Scheduler is the drill sergeant. Hardware decides which warps run when. Your code writes the briefing; the scheduler picks the order. Divergent branches, register pressure, and shared-memory limits all feed into it.
- Warp divergence kills throughput. A 32-thread warp executing
if (thread_id % 2 == 0) ... else ...serializes the two paths — half the warp is idle while the other half runs each branch. Effectively half throughput; severe forms can cut deeper.
Of these, warp divergence is the one beginners design themselves into accidentally most often. The fix isn't to avoid if entirely — it's to keep the branch decision uniform within a warp, so all 32 threads in a warp take the same path.