0PricingLogin
CUDA Academy · Lesson

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

  1. Race Conditions on the GPU
  2. atomicAdd and Friends
  3. Building a Histogram
  4. Custom Atomics with atomicCAS
← Back to CUDA Academy