Docsity

Cache Coherence Protocols: Invalidation vs. Update, MSI, MESI, MOESI, and Hybrid, Slides of Computer Science

Partial preview of the text

Download Cache Coherence Protocols: Invalidation vs. Update, MSI, MESI, MOESI, and Hybrid and more Slides Computer Science in PDF only on Docsity!

Module 9: "Introduction to Shared Memory Multiprocessors"

Lecture 17: "Introduction to Cache Coherence Protocols"

Invalidation vs. Update

Sharing patterns

Migratory hand-off

States of a cache line

Stores

MSI protocol

State transition

MSI example

MESI protocol

State transition

MESI example

MOESI protocol

Hybrid inval+update

Module 9: "Introduction to Shared Memory Multiprocessors"

Lecture 17: "Introduction to Cache Coherence Protocols"

Invalidation vs. Update

Two main classes of protocols: Dictates what action should be taken on a store Invalidation-based protocols invalidate sharers when a store miss appears Update-based protocols update the sharer caches with new value on a store Advantage of update-based protocols: sharers continue to hit in the cache while in invalidation-based protocols sharers will miss next time they try to access the line Advantage of invalidation-based protocols: only store misses go on bus and subsequent stores to the same line are cache hits When is update-based protocol good? What sharing pattern? (large-scale producer/consumer) Otherwise it would just waste bus bandwidth doing useless updates When is invalidation-protocol good? Sequence of multiple writes to a cache line Saves intermediate write transactions Overhead of initiating small updates Invalidation-based protocols are much more popular Some systems support both or maybe some hybrid based on dynamic sharing pattern of a cache line

Sharing patterns

Producer-consumer (initially flag, done are zero) T0: while (!exit) {x=y; flag=1; while (done != k); flag=0; done=0;} T1 to Tk: while (!exit) {while (!flag); use x; done++; while (flag);} Exit condition not shown What if T1 to Tk do not have the outer loop? Migratory (initially flag is zero) T0: x = f0(x); flag++; T1 to Tk: while (flag != pid); x = f1(x); flag++; Migratory hand-off?

Migratory hand-off

Needs a memory writeback on every hand-off r0, w0, r1, w1, r2, w2, r3, w3, r4, w4, … How to avoid these unnecessary writebacks? Saves memory bandwidth Solution: add an owner state (different from M) in caches Only owner can write a line back on eviction Ownership shifts along the migratory chain

Module 9: "Introduction to Shared Memory Multiprocessors"

Lecture 17: "Introduction to Cache Coherence Protocols"

State transition

MSI example

Take the following example P0 reads x, P1 reads x, P1 writes x, P0 reads x, P2 reads x, P3 writes x Assume the state of the cache line containing the address of x is I in all processors

P0 generates BusRd, memory provides line, P0 puts line in S state

P1 generates BusRd, memory provides line, P1 puts line in S state

P1 generates BusUpgr, P0 snoops and invalidates line, memory does not respond, P sets state of line to M

P0 generates BusRd, P1 flushes line and goes to S state, P0 puts line in S state, memory writes back

P2 generates BusRd, memory provides line, P2 puts line in S state

P3 generates BusRdX, P0, P1, P2 snoop and invalidate, memory provides line, P3 puts line in cache in M state

MESI protocol

The most popular invalidation-based protocol e.g., appears in Intel Xeon MP Why need E state? The MSI protocol requires two transactions to go from I to M even if there is no intervening requests for the line: BusRd followed by BusUpgr Save one transaction by having memory controller respond to the first BusRd with E state if there is no other sharer in the system Needs a dedicated control wire that gets asserted by a sharer (wired OR) Processor can write to a line in E state silently

Module 9: "Introduction to Shared Memory Multiprocessors"

Lecture 17: "Introduction to Cache Coherence Protocols"

State transition

MESI example

Take the following example P0 reads x, P0 writes x, P1 reads x, P1 writes x, …

P0 generates BusRd, memory provides line, P0 puts line in cache in E state

P0 does write silently, goes to M state

P1 generates BusRd, P0 provides line, P1 puts line in cache in S state, P0 transitions to S state

Rest is identical to MSI

Consider this example: P0 reads x, P1 reads x, …

P0 generates BusRd, memory provides line, P0 puts line in cache in E state

P1 generates BusRd, memory provides line, P1 puts line in cache in S state, P transitions to S state (no cache-to-cache sharing)

Rest is same as MSI