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
- Race Conditions on the GPU
- atomicAdd and Friends
- Building a Histogram
- Custom Atomics with atomicCAS