Cache Coherence
Subject: Computer and Technology noun /kæʃ koʊˈhɪr.əns/ 1 definition
- computer-architecture
- cpu-design
- memory-management
- parallel-computing
-
Definition (noun)
Entry #115 · UpdatedCache Coherence is the architectural property and set of hardware protocols that keep cached copies of shared memory synchronized across multiple processors or cores in a shared-memory system. Whenever two or more cores locally store the same memory block—typically managed at the granularity of a cache line—a write performed by one core must invalidate or update stale copies held elsewhere before other cores read or modify that address. Unlike memory consistency models, which govern the apparent ordering of operations across different memory addresses, cache coherence strictly enforces single-location visibility and write serialization—commonly via hardware state machines such as Modified, Exclusive, Shared, and Invalid (MESI)—so multithreaded software operates reliably without manual cache flushing.
Common Forms
Snooping Coherence: Relies on every cache controller monitoring a shared broadcast interconnect for memory transactions, allowing cores to immediately invalidate or update matching local cache lines in small- to medium-scale multiprocessors.
Directory-Based Coherence: Tracks which caches hold copies of each memory block in a centralized or distributed hardware directory, sending targeted point-to-point messages rather than broadcasts so coherence scales across many-core and multi-socket systems.
Write-Invalidate Protocols: Purge all remote cached copies of a line before a core commits a write—as implemented in MSI, MESI, and MOESI protocols—minimizing interconnect bandwidth during repeated writes by the same core.
Write-Update Protocols: Propagate newly written values directly to all other caches holding a copy of that block instead of invalidating them, reducing read-miss latency on frequently shared data at the expense of higher interconnect traffic.
Example
On a multi-core processor using a MESI snooping protocol, Core 0 and Core 1 initially hold the same 64-byte cache line for a shared reference counter in the Shared (
S) state. When Core 0 increments the counter, its cache controller broadcasts an invalidation signal across the interconnect, transitioning Core 1's copy to Invalid (I) and Core 0's copy to Modified (M) so Core 1 must fetch the updated line instead of reading stale data on its next access.