Spatial Locality: Sequential vs. Strided Access Performance

While sequential array access greatly benefits from cache lines loading entire blocks of data, strided access (skipping elements) can lead to significantly higher cache misses and up to 14x slower performance if strides exceed the cache line size, effectively negating spatial locality benefits.

The top 3

  1. Sequential Access: Up to 14x Faster Than Strided: Optimized sequential memory access can achieve a 10x or even 14x performance boost over strided access due to efficient cache line utilization and effective hardware prefetching.
  2. Main Memory Access: 100x Slower Than L1 Cache: A cache miss forcing data retrieval from main memory can be over 100 times slower than an L1 cache hit, with L1 latency around 1 nanosecond compared to main memory's 100-200 nanoseconds or 60-100+ CPU cycles.
  3. Power-of-2 Strides: Maximize Cache Conflict Misses: Strides that are powers of two can lead to severe cache conflict misses, especially when array sizes or access patterns align with cache line boundaries, causing different data items to map to the same cache set and evict each other.

Sources

Open the full topic