computer-architecture memory

Definition

Spatial Cache Locality

Spatial cache locality is the use of spatial memory locality in a cache by loading not only the accessed word, but also nearby words in the same cache block. This is achieved through the block size: when one address is fetched, the whole block containing that address is brought into the cache.

So if the program soon accesses nearby addresses, these later accesses can hit because the neighbouring data was loaded together with the first access.

Example

Larger block size

Suppose a direct-mapped cache has capacity words and block size words.

Then the cache contains

blocks.

If one word is accessed, the cache fetches the whole four-word block that contains it. So later accesses to neighbouring words can hit even though they were not requested originally.

This is exactly how a cache exploits spatial memory locality.