MC&CC
MC&CC
and Cache
Coherence
Table of contents
01 02
Memory Consistency Cache Coherance
01
memory
consistency
Memory Consistency
In modern multi-core systems, memory consistency defines the expected
“Correct” behavior of reads and writes across different processors. It
determines the order in which memory operations are observed, ensuring
correctness in parallel programs.
correct shared memory behavior in terms of loads and stores (memory reads
and writes)
• Coherence invariants :
1. Single-Writer, Multiple-Read
(SWMR) 2. Data-Value Invariant.
Cache Coherance
• Single-Writer–Multiple-Reader (SWMR) Invariant: At any given time, a memory
location is either cached for writing (and reading) at one cache or cached only for
reading at zero to many caches
Cache Coherance
1.Snooping-based Cache
Coherence :
each cache monitors (snoops on) a
shared bus for memory operations. When
a cache miss occurs, the core's cache
controller arbitrates for the shared bus
and broadcasts its request. Other caches
respond with data if they have a copy.
They are conceptually simpler but can
become less scalable as the number of
cores increases, due to the reliance on
broadcasting over a shared bus.
Cache Coherance
• Directory-based Cache Coherence
use a directory to track which caches have
copies of which memory locations. When a
cache miss occurs, the requesting core
queries the directory for information about
where the data is located. The directory then
directs the request to the appropriate cache
or memory controller. Directory protocols are
more scalable than snooping protocols
because they don't rely on broadcasting, but
they add complexity due to the directory
structure and associated overhead.
MSI
States:
• Modified (M): The cache block is updated and different from memory. It must be written back before
another processor can read it.
• Shared (S): The block is clean and can be shared among multiple caches.
• Invalid (I): The block is not valid in the cache.
Key Features:
• Uses an Invalidate-based approach.
• Write operations cause invalidation in other caches.
• Drawback: Requires memory writebacks even for read-only shared data.
MESI
States:
• Modified (M): The cache block is updated and different from
memory. It must be written back before another processor can
read it.
• Exclusive (E) – The cache has the only clean copy (same as
memory, but no other caches have it).
• Shared (S): The block is clean and can be shared among
multiple caches.
• Invalid (I): The block is not valid in the cache.
Key Features:
• E state reduces memory writes: No need to write back if the
block is only in one cache.
• Optimizes performance over MSI by reducing unnecessary
memory traffic.
MOSI
States:
• Modified (M): The cache block is updated and different from memory. It must be written back before
another processor can read it.
• Owned (O) – The cache holds the most recent copy and serves requests to other cores without
updating main memory.
• Shared (S): The block is clean and can be shared among multiple caches.
• Invalid (I): The block is not valid in the cache.
Key Features:
• Reduces writebacks to memory by allowing a cache to supply data instead.
• Useful in systems with high inter-processor communication.
MOSI
• MOESI is the most optimized protocol, used in modern AMD processors.
• It balances memory traffic and performance by allowing cache-to-cache transfers while minimizing
unnecessary writebacks.
• It is preferred in high-performance multiprocessor architectures.
Advantages of MOESI Over Other Protocols
1.Cache-to-Cache Transfers:
⚬ The Owned (O) state allows direct cache sharing, reducing memory accesses.
2.Lower Memory Traffic:
⚬ Unlike MSI, where modified data must be written back to memory, MOESI allows sharing the
latest data without immediate writebacks.
3.Efficiency in Multi-Core Systems:
⚬ Used in AMD Opteron and Ryzen processors to optimize cache performance.
Thank you
Any Questions ?