Registers and Local Memory
The fastest per-thread storage and its spills.
The Fastest Memory You Have
Every thread gets its own private registers, the quickest storage on the chip. They live right next to the math units, so reads cost almost nothing.
Plain Variables Become Registers
When you write a normal local variable in a kernel, the compiler usually keeps it in a register. No special syntax is needed at all. 🙂
__global__ void k() {
int x = 5; // x lives in a register
float y = x * 2.0f;
}All lessons in this course
- Registers and Local Memory
- Global Memory Tradeoffs
- Constant Memory and Its Cache
- A Mental Model of the Hierarchy