Spatial and Temporal Locality

Back to Cache Hierarchy

Spatial locality: if a memory location is accessed, nearby locations are likely to be accessed soon (arrays, sequential iteration). Temporal locality: if a location is accessed, it is likely to be accessed again soon (loops, hot variables). Cache-friendly code exploits both.

memory-models cache locality