Building a Histogram
Atomics with shared-memory privatization.
What a Histogram Counts
A histogram counts how many inputs fall into each bin. Many threads will want to increment the same bin, so this is an atomics problem. 📊
The Naive Approach
Each thread reads one element, finds its bin, and increments that bin. Without protection, popular bins lose counts to races.
All lessons in this course
- Race Conditions on the GPU
- atomicAdd and Friends
- Building a Histogram
- Custom Atomics with atomicCAS