Docsity

Cache Coherence - Computer Design and Organisation - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Cache Coherence - Computer Design and Organisation - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Cache Coherence

• Recall the memory wall

  • In multiprocessors the wall might even be higher!
  • Contention on shared-bus
  • Time to travel through an interconnection network

• In addition to the 3 C’s of the cache hierarchy

  • Cache coherence misses

• Cache coherence protocols

  • Shared-bus: Snoopy protocols
  • Other interconnection schemes: Directory protocols

Cache Coherence: The problem

P1 P2 P3 P

Mem.

Initial state: P2 reads A; P3 reads A (note already a decision to make: who sends the value of A?)

A

A A

Write-update

P2 and P3 have read line A; P4 has a write miss on an element of line A

P1 P2 P3 P

Mem.

A’

A’ A’ A’

A write miss looks like a read miss (bring the old value of A in P4) followed by a write hit and a broadcast of the new value of A

Write-invalidate

P2 and P3 have read line A; P4 has a write miss on an element of line A

P1 P2 P3 P

Mem.

Invalid lines

A

A A^ A’

A write miss looks like a read miss (bring the old value of A in P4) followed by a write hit and an invalidation

State Transitions for a Given Cache

Line

  • Those incurred as answers to processor

associated with the cache

  • Read miss, write miss, write on shared line
  • Those incurred by snooping on the bus as

result of other processor actions, e.g.,

  • Read miss by Q might make P’s line transit from M to S
  • Write miss by Q might make P’s line transit from M or S to I (write invalidate protocol)

Basic Write-invalidate Protocol (write-

back write-allocate caches)

  • Needs 3 states associated with each cache line
    • Invalid
    • Shared (read only – can be shared)
    • Modified (only valid copy in the system)
  • Need to decompose state transitions into

those:

  • Induced by the processor attached to the cache
  • Induced by snooping on the bus

Basic 3 State Protocol: Transitions from

Bus Snooping

Inv.

Modified

Bus write Shared

Bus write (^) Bus read

Snoopy protocol implementation

• Simple 3-state fsm?

• Yes but

  • Many more “internal states” because of write buffers,

lock-up free caches, prefetching, split-transaction bus

etc.

  • Example: split-transaction bus. Caches A and B have

line L in state I and cache C has it in state S. Both A

and B want to write L at the same time.

  • Split-transaction means for A and B (in this case)

“Request to read” and for C “Data transfer” But the 2

“Request for read” should not arrive at C before the

“Data transfer”. Need for intermediate states

Illinois Protocol: Design Decisions

• The Exclusive state is there to enhance

performance

  • On a write to a line in E state, no need to send an invalidation message (occurs often for private variables).

• On a read miss with no cache having the line

in Modified state

  • Who sends the data: memory or cache (if any)?
    • Answer: cache for that particular protocol; other protocols might use the memory
  • If more than one cache, which one? Docsity.com

Illinois Protocol: State Diagram

I E

M S

Read miss from mem.

Write hit

Write miss

Read hit

Read/Write Hit

Bus read miss

Write hit

Read miss from cache

Read hit and bus read miss

Bus read miss

bus write miss

bus write miss

bus write miss

Proc. induced

Bus induced

Example: P3 reads A (A comes from

P2)

I E

M S

Read miss from mem.

Write hit

Write miss

Read hit

Hit

Bus read miss

Write hit

Read miss from cache

Read hit and bus read miss

Bus read miss

bus write miss

bus write miss

bus write miss

Proc. induced

Bus induced

Both P2 and P will have A in state S

Example: P4 writes A (A comes

from P2)

I E

M S

Read miss from mem.

Write hit

Write miss

Read hit

Hit

Bus read miss

Write hit

Read miss from cache

Read hit and bus read miss

Bus read miss

bus write miss

bus write miss

bus write miss

Proc. induced

Bus induced

P2 and P3 will have A in state I; P4 will be in state M

Performance of Snoopy Protocols

• Protocol performance depends on the length

of a write run

• Write run: sequence of write references by 1

processor to a shared address (or shared line)

uninterrupted by either access by another

processor or replacement

  • Long write runs better to have write invalidate
  • Short write runs better to have write update

• There have been proposals to make the choice

between protocols at run time Docsity.com

What About Cache Hierarchies?

• Implement snoopy protocol at L2 (board-level)

cache

• Impose multilevel inclusion property

  • Encode in L2 whether the line (or part of it if lines in L2 are longer than lines in L1) is in L1 (1 bit/line or subblock)
  • Disrupt L1 on bus transactions from other processors only if data is there, i.e., L2 shields L from unnecessary checks
  • Total inclusion might be expensive (need for large associativity) if several L1’s share a common L2Docsity.com