# NUMA **[NUMA](https://en.wikipedia.org/wiki/Non-uniform_memory_access)** (Non-Uniform Memory Access) describes a multi-socket system where each socket has its own local memory attached, but can also reach remote memory on other sockets over an interconnect. Local memory access is faster than remote, and latency grows with hop count and socket distance. This contrasts with UMA (Uniform Memory Access) where all cores see the same latency. NUMA exists because a single memory controller has bandwidth limits; per-socket controllers scale bandwidth linearly with sockets at the cost of non-uniform latency. ## Example This example shows NUMA effects where thread-memory affinity matters. ```c // compile: gcc -O2 -o numa numa.c // run: numactl -i local ./numa (if numactl available) // description: demonstrate NUMA latency difference between local and remote memory #include #include #include #include #define SIZE 10000000 int main() { int* local = malloc(SIZE * sizeof(int)); memset(local, 0, SIZE * sizeof(int)); clock_t start, end; volatile int sum = 0; // Sequential access (good for NUMA locality) start = clock(); for (int i = 0; i < SIZE; i++) { sum += local[i]; } end = clock(); printf("Local sequential access: %ld cycles\n", end - start); // Strided access (poor NUMA locality) start = clock(); for (int i = 0; i < SIZE; i += 64) { sum += local[i]; } end = clock(); printf("Local strided access: %ld cycles\n", end - start); free(local); return 0; } ```