Home / Glossary / Cache Coherence

On this pageIn more detailWhy it mattersRelated termsRead more

Cache Coherence

Cache coherence is the property that every processor core in a system sees a consistent, up-to-date view of shared data, even though each core keeps its own cached copy.

In more detail

To run fast, each core stores recently used data in a private cache. A problem arises when two cores hold copies of the same data and one changes it. Without coordination, the other would go on using a stale value.

Coherence protocols prevent that. They track the state of each cached block of data in every cache. A widely used scheme, named MESI after its four states, marks a block as:

  • Modified. This cache has the only copy, and has changed it.
  • Exclusive. This cache has the only copy, unchanged.
  • Shared. Other caches may hold copies too.
  • Invalid. This copy must not be used.

Before a core writes to a block, the other copies must be invalidated. Before a core reads a block that another has modified, it must obtain the new value. Either the caches broadcast their requests to one another, called snooping, or a directory records which caches hold what.

Why it matters

Coherence is what allows ordinary multi-threaded software to work correctly on a multicore chip. Programmers can share memory between threads without managing copies by hand.

It comes at a cost. The coordinating messages take time and energy, and the amount of traffic grows with the number of cores. That is a central challenge in manycore processor design, where the messages travel over a network-on-chip.

Coherence also now reaches beyond the processor. CXL lets accelerators take part in it.

Related terms

Read more