0PricingLogin
CUDA Academy · Lesson

atomicAdd and Friends

Hardware read-modify-write operations.

One Indivisible Step

An atomic operation reads, modifies, and writes a value as a single step that no other thread can interrupt. That kills the race. ⚛️

Meet atomicAdd

atomicAdd takes a pointer and a value, adds safely, and returns the old value. Many threads can hit the same address with no lost updates.

atomicAdd(total, 1);

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