All Topics  
Cache coherency

 

   Email Print
   Bookmark   Link






 

Cache coherency



 
 
In computing, cache
Cache

In computer science, a cache is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch or to compute, compared to the cost of reading the cache....
 coherence
(also cache coherency) refers to the integrity of data stored in local caches of a shared resource. Cache coherence is a special case of memory coherence
Memory coherence

Memory coherence is an issue that affects the design of computer systems in which two or more Central processing units share a common area of memory ....
.

When clients in a system maintain caches
CPU cache

A CPU cache is a cache used by the central processing unit of a computer to reduce the average time to access computer storage. The cache is a smaller, faster memory which stores copies of the data from the most frequently used main memory locations....
 of a common memory resource, problems may arise with inconsistent data.






Discussion
Ask a question about 'Cache coherency'
Start a new discussion about 'Cache coherency'
Answer questions from other users
Full Discussion Forum



Encyclopedia


Cache Coherency Generic
In computing, cache
Cache

In computer science, a cache is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch or to compute, compared to the cost of reading the cache....
 coherence
(also cache coherency) refers to the integrity of data stored in local caches of a shared resource. Cache coherence is a special case of memory coherence
Memory coherence

Memory coherence is an issue that affects the design of computer systems in which two or more Central processing units share a common area of memory ....
.

When clients in a system maintain caches
CPU cache

A CPU cache is a cache used by the central processing unit of a computer to reduce the average time to access computer storage. The cache is a smaller, faster memory which stores copies of the data from the most frequently used main memory locations....
 of a common memory resource, problems may arise with inconsistent data. This is particularly true of CPUs in a multiprocessing
Multiprocessing

Multiprocessing is the use of two or more CPU within a single computer system. The term also refers to the ability of a system to support more than one processor and/or the ability to allocate tasks between them....
 system. Referring to the "Multiple Caches of Shared Resource" figure, if the top client has a copy of a memory block from a previous read and the bottom client changes that memory block, the top client could be left with an invalid cache of memory without any notification of the change. Cache coherence is intended to manage such conflicts and maintain consistency between cache and memory.

Definition

Coherence defines the behavior of reads and writes to the same memory location. The coherence of caches is obtained if the following conditions are met:
  1. A read made by a processor P to a location X that follows a write by the same processor P to X, with no writes of X by another processor occurring between the write and the read instructions made by P, X must always return the value written by P. This condition is related with the program order preservation, and this must be achieved even in monoprocessed architectures.
  2. A read made by a processor P1 to location X that follows a write by another processor P2 to X must return the written value made by P2 if no other writes to X made by any processor occur between the two accesses. This condition defines the concept of coherent view of memory. If processors can read the same old value after the write made by P2, we can say that the memory is incoherent.
  3. Writes to the same location must be sequenced. In other words, if location X received two different values A and B, in this order, by any two processors, the processors can never read location X as B and then read it as A. The location X must be seen with values A and B in that order.


These conditions are defined supposing that the read and write operations are made instantaneously. However, this doesn't happen in computer hardware given memory latency and other aspects of the architecture. A write by processor X may not be seen by a read from processor Y if the read is made within a very small time after the write has been made. The memory consistency model defines when a written value must be seen by a following read instruction made by the other processors.

Cache coherence mechanisms


  • Directory-based coherence mechanisms maintain a central directory of cached blocks.


  • Snooping is the process where the individual caches monitor address lines for accesses to memory locations that they have cached. When a write operation is observed to a location that a cache has a copy of, the cache controller invalidates its own copy of the snooped memory location.


  • Snarfing is where a cache controller watches both address and data in an attempt to update its own copy of a memory location when a second master modifies a location in main memory.


Distributed shared memory
Distributed shared memory

Distributed Shared Memory , also known as a distributed global address space , is a term in computer science that refers to a wide class of software and hardware implementations, in which each node of a computer cluster has access to a large shared memory in addition to each node's limited non-shared private memory....
 systems mimic these mechanisms in an attempt to maintain consistency between blocks of memory in loosely coupled systems.

The two most common types of coherence that are typically studied are Snooping and Directory-based, each having its own benefits and drawbacks. Snooping protocols tend to be faster, if enough bandwidth is available, since all transactions are a request/response seen by all processors. The drawback is that snooping isn't scalable. Every request must be broadcast to all nodes in a system, meaning that as the system gets larger, the size of the (logical or physical) bus and the bandwidth it provides must grow. Directories, on the other hand, tend to have longer latencies (with a 3 hop request/forward/respond) but use much less bandwidth since messages are point to point and not broadcast. For this reason, many of the larger systems (>64 processors) use this type of cache coherence.

Coherence models

Various models and protocols have been devised for maintaining cache coherence, such as:
  • MSI protocol
    MSI protocol

    The MSI protocol is a basic coherence protocol that is used in multiprocessor systems. As with other cache coherency protocols, the letters of the protocol name identify the possible states in which a cache line can be....
  • MESI protocol
    MESI protocol

    The MESI protocol is a widely used cache coherency and memory coherence protocol. It is the most common protocol which supports write-back CPU cache....
  • MOSI protocol
    MOSI protocol

    The MOSI protocol is an extension of the basic MSI protocol cache coherency Protocol . It adds the Owned state, which indicates that the current processor owns this block, and will service requests from other processors for the block....
  • MOESI protocol
    MOESI protocol

    This is a full cache coherency protocol that encompasses all of the possible states commonly used in other protocols. As discussed in AMD64 Architecture Programmer's Manual Vol 2 'System Programming', each cache line is in one of five states:...
  • Write-once protocol
    Write-once (cache coherency)

    In Cache coherency protocol literature, Write-Once is the first write-invalidate protocol defined. It has the optimization of executing write-update on the first write and a write-invalidate on all subsequent writes, reducing the overall Bus traffic in consecutive writes to the Computer storage....
  • Synapse protocol
  • Berkeley protocol
  • Illinois protocol
  • Firefly protocol
    Firefly protocol

    The Firefly cache coherence protocol is the schema used in the DEC Firefly multiprocessor workstation, developed by DEC Systems Research Center....
  • Dragon protocol
    Dragon protocol

    The Dragon cache coherence protocol is the schema used in the Xerox Dragon multiprocessor workstation, developed by Xerox PARC. This protocol uses a write-back policy....
Choice of the consistency model
Consistency model

In computer science, in a distributed system such as a distributed shared memory system or a distributed data store such as a database, filesystem, web caching or Optimistic_replication systems, there are a number of possible data consistency models....
 is crucial to designing a cache coherent system. Coherence models differ in performance and scalability; each must be evaluated for every system design.

Furthermore, transitions between states in any specific implementation of these protocols may vary. For example, an implementation may choose different update and invalidation transitions such as update-on-read, update-on-write, invalidate-on-read, or invalidate-on-write. The choice of transition may affect the amount of inter-cache traffic, which in turn may affect the amount of cache bandwidth available for actual work. This should be taken into consideration in the design of distributed software that could cause strong contention between the caches of multiple processors.

Further reading

  • Handy, Jim. The Cache Memory Book. Academic Press, Inc., 1998. ISBN 0-12-322980-4


See also

  • ccNUMA
  • Write barrier