Professional Documents
Culture Documents
Cache Coherence Protocols For Sequential Consistency: Computer Science and Artificial Intelligence Lab M.I.T
Cache Coherence Protocols For Sequential Consistency: Computer Science and Artificial Intelligence Lab M.I.T
for
Sequential Consistency
Arvind
M.I.T.
Systems view
snooper
(WbReq, InvReq, InvRep)
load/store
buffers pushout (WbRep) Memory
CPU Cache
(ShReq, ExReq)
Blocking caches CPU/Memory
In order, one request at a time + CC ⇒ SC Interface
Non-blocking caches
Multiple requests (different addresses) concurrently + CC
⇒ Relaxed memory models
CC ensures that all processors observe the same
order of loads and stores to an address
November 14, 2005
6.823 L18- 3
Arvind
Interconnect
M aka Home
a ∈ Li ⇒ a ∈ Li+1
⇒
write request:
read request:
State Encoding
P P P P
(Sh, ∈) a L1 L1 L1
P
6 7 8 9
P 5 L1
(Sh, ∈) 2 a 3 L2 4 a (Sh, R(6))
Interconnect
1 a (Ex, R(2,4))
Inv
invalidate flush
store
load
optimizations
Sh Ex
store
write-back
Child c Child c
Parent m Parent m
Child c idc
Parent m idp
Parent m idp
• Writeback rule
W(idc) == m.state(a) & Ex == c.state(a)
→ m.setState(a, R({idc}))
msetData(a, c.data(a));
c.setState(a, Sh);
• Invalidate rule
R(dir) == m.state(a) & idc ∈ dir & Sh == c.state(a)
→ m.setState(a, R(dir - idc))
c.invalidate(a);
Child c idc
Parent m idp
Protocol Design
*Note*
(The rest of the material will be covered during the next lecture.)
P P
in out
PP m
• Each cache has 2 pairs of queues
– one pair (c2m, m2c) to communicate with the memory
– one pair (p2m, m2p) to communicate with the processor
• Messages format:
msg(idsrc,iddest,cmd,priority,a,v)
• FIFO messages passing between each (src,dest) pair
except a Low priority (L) msg cannot block a high
priority (H) msg
November 14, 2005
6.823 L18- 16
Arvind
priority
– In Practice:
H
• Separate Queues L
• Shared buses for both networks
Operations on cache:
cache.state(a) – returns state s
cache.data(a) - returns data v
cache.setState(a,s), cache.setData(a,v), cache.invalidate(a)
Flush rule
cache.state(a) is Ex
→ cache.invalidate(a)
c2m.enq (Msg(id, Home, FlushRep, a, cache.data(v))
Writeback rule
cache.state(a) is Ex
→ cache.setState(a, Sh)
c2m.enq (Msg(id, Home, WbRep, a, cache.data(v)))
This rule may be applied if the cache/processor knows it
is the “last store” operation to the location.
Cache Rule
m.state(a) is R(dir) & id ∉ dir
→ m.setState(a, R(id+dir))
out.enq(Msg(Home,id,ShRep, a,m.data(a)))
• Load-hit rule
Load(a)==inst
& cache.state(a) is Sh or Ex
→ p2m.deq
m2p.enq(cache.data(a))
• Load-miss rule
Load(a)==inst
& cache.state(a) is Nothing
→ c2m.enq(Msg(id, Home, ShReq, a)
cache.setState(a,Pending)
• Store-hit rule
Store(a,v)==inst
& cache.state(a) is Ex
→ p2m.deq;
m2p.enq(Ack)
cache.setData(a, v)
• Store-miss rules
Store(a,v)==inst
cache.setState(a,Nothing)
Msg(id,Home,ShReq,a) ==mmsg
& m.state(a) is W(id’) & (id’ is not id)
→ m.setState(a, TW(id’));
out.enq(Msg(Home,id’,WbReq, a))
Msg(id,Home,ExReq,a) ==mmsg
& m.state(a) is R(dir) & !(dir is empty or has only id)
→ m.setState(a, TR(dir-{id}))
out.enq(multicast(Home,dir-{id},InvReq, a)
Outstanding Exclusive Copy
Msg(id,Home,ExReq,a) ==mmsg
& m.state(a) is W(id’) & (id’ is not id)
→ m.setState(a, TW(id’))
out.enq(Msg(Home,id’,FlushReq, a)
November 14, 2005
6.823 L18- 25
Arvind
ShRep
Msg(Home, id, ShRep, a, v) == msg
-- cache.state(a) must be Pending or Nothing
→ m2c.deq
cache.setState(a, Sh)
cache.setData(a, v)
ExRep
Msg(Home, id, ExRep, a, v) == msg
-- cache.state(a) must be Pending or Nothing
→ m2c.deq
cache.setState(a, Ex)
cache.setData(a, v)
InvReq
Msg(Home,id,InvReq,a) == msg
& cache.state(a) is Sh
→ m2c.deq
cache.invalidate(a)
c2m.enq (Msg(id, Home, InvRep, a))
Msg(Home,id,InvReq,a) == msg
& cache.state(a) is Nothing or Pending
→ m2c.deq
WbReq
Msg(Home,id,WbReq,a) == msg
& cache.state(a) is Ex
→ m2c.deq
cache.setState(a, Sh)
c2m.enq (Msg(id, Home, WbRep, a, cache.data(v)))
Msg(Home,id,WbReq,a) == msg
& cache.state(a) is Sh or Nothing or Pending
→ m2c.deq
FlushReq
Msg(Home,id,FlushReq,a) == msg
& cache.state(a) is Ex
→ m2c.deq
cache.invalidate(a)
c2m.enq (Msg(id, Home, FlushRep, a, cache.data(v)))
Msg(Home,id,FlushReq,a) == msg
& cache.state(a) is Sh
→ m2c.deq
cache.invalidate(a)
Msg(Home,id,FlushReq,a) == msg
→ m2c.deq
(at home)
InvRep
Msg(id,Home,InvRep,a) == mmsg
& m.state(a) is TR(dir)
→ deq mmsg;
m.setState(a, TR(dir-{id}))
Msg(id,Home,InvRep,a) == mmsg
& m.state(a) is R(dir)
→
deq mmsg;
m.setState(a, R(dir-{id}))
(at home)
WbRep
Msg(id,Home,WbRep,a,v) == mmsg
-- m.state(a) must be TW(id) or W(id)
→ deq mmsg;
m.setState(a, R(id))
m.setData(a,v)
FlushRep
Msg(id,Home,FlushRep,a,v) == mmsg
-- m.state(a) must be TW(id) or W(id)
→ deq mmsg;
m.setState(a, R(Empty))
m.setData(a,v)
Non-Blocking Caches
new reqs
• Non-blocking caches are enq
needed to tolerate large p2m
memory latencies
incomingQ
• To get non-blocking property
deferQ
we implement p2m with 2
FIFOs (deferQ, incomingQ)
Handle
Req.
November 14, 2005
6.823 L18- 32
Arvind
Conclusion
Thank you !
Protocol Diagram
ShReq
a
Dir a: Sh {}
Dir a: Sh {1}
Main Memory
Protocol Diagram
ShResp
<a,v>
Dir a: Sh {1}
Main Memory
Protocol Diagram
ShReq
a
Dir a: Sh {1}
Dir a: Sh {1,2}
Main Memory
Protocol Diagram
ShResp
<a,v>
Dir a: Sh {1,2}
Main Memory
Protocol Diagram
Dir a: Sh {1,2}
Main Memory
Protocol Diagram
Dir a: Sh {}
Dir a: Sh {1,2} Main Memory
Dir a: Ex {N}
Protocol Diagram
ShReq WBReq
a a
Dir a: Ex {N}
Main Memory
Protocol Diagram
ShResp WBResp
<a,v'> <a,v'>
Dir a: Ex {N}
Dir a: Sh {1,N}
Main Memory