Title: Shared Memory Consistency
1Shared Memory Consistency
2Introduction
- Shared Memory consistency is defined as a read
should return a value of last write to same
memory location.
P1
P2
P3
Memory
3Example
- Initially A flag 0
- P1 P2
- A1 while(flag 1)
- flag1 print A
4Sequential Consistency
- Result of an execution is in sequential order for
all processors - Maintaining program order among operations
- Maintaining program order for all operations
(atomicity)
5Program order example
- flag1 flag2 0
- P1 P2
- flag11 flag21
- If (flag20) If (flag10)
- Critical section Critical section
6Atomicity example
- Initially A B 0
- P1 P2 P3
- A1
- if(A1)
- B1
- if(B1)
- register1A
7Implementation
- Architecture without caches
- Write Buffers with read bypassing
- Overlapping writes
- Non blocking reads
8Write Buffers with read bypassing
P2 Flag21 if (Flag10) Critical section
P1 Flag11 if (Flag20) Critical section
9Overlapping writes
Read Data t3 Read Head t2
P2 While(Head1) Data
P1 Data2000 Head1
10Nonblocking Reads
Write Head t3 Write Data t2
General Interconnect
P2 While(Head1) Data
P1 Data2000 Head1
Memory
11Implementation
- Architecture with caches
- Cache coherence Protocols
- Detecting write completion
- Maintaining write atomicity
12Cache coherence Protocols
- A write must eventually be visible to all
processors - Writes to same location must appear in same order
for all processors.
13Detecting write completion
- Acknowledge of an invalidate or update
P1 Data2000 Head1
P2 While(Head1) Data
14Maintaining write atomicity
- Writes to same location should be serialized
- Initially A B C 0
- P1 P2 P3 P4
- A1 A2 while(B!1) while(B!1)
- B1 C1 while(C!1) while(C!1)
- register1A register2A
15Maintaining write atomicity
- Prohibiting a read from returning a newly written
value until all cached copies have
acknowledgement receipts - Initially AB1
- P1 P2 P3
- A1
- if(A1)
- B1
- if (B1)
- register1A
16Compilers
- Hardware techniques
- Compiler techniques
17Hardware techniques
- Prefetching ownership write any write operation
that is delayed due to program order requirement - Servicing read operations that are delayed due to
program order requirement
18Compiler techniques
- To detect when memory operations can be reordered
without violating sequential consistency.
19Relaxed Memory models
- Relax program order requirement
- Write to following read (W-gtR)
- Between two writes (W-gtW)
- Read to following read or write (R-gtRW)
- Write atomicity requirement
- Read returns value before it is made globally
visible. (ROth.-gtWEarly)
20Relaxed Memory models
- Relax both program order and write atomicity
(ROwn-gtWEarly) - A processor can read the value of its own write
before the write is visible to other processors.
21Relax program order requirement
- Write to following read
- IBM 370
- Serialization instructions
- TSO (Total Store Ordering)
- RMW
- PC (Processor Consistency Model)
- RMW
22Example
- Initially A Flag1 Flag2 0
- P1 P2
- Flag11 Flag21
- A1 A2
- register1A register3A
- register2Flag2 register4Flag1
- Result register11, register32,
- register2register40
23Example.
- Initially A B 0
- P1 P2 P3
- A1
- if(A1)
- B1
- if(B1)
- register1A
24Relax program order requirement
- Between two writes or write to read
- PSO (Partial Store Ordering Model)
- Writes are pipelined or overlapped and safety net
used is RMW, STBAR
25Relaxing all program orders
- RCsc
- Release, acquire, RMW
- RCpc
- Release, acquire, RMW
- Alpha
- MB, WMB
- RMO
- MEMBARS
- PowerPC
- SYNC
26(No Transcript)
27References
- S.V. Adve, Kourosh Gharachorloo Shared Memory
Consistency Models A Tutorial - S.V. Adve, Designing Memory Consistency Models
for shared Memory Multi processors - Tracy Harton, Sarita Adve, Evaluation of shared
memory Models with ILP Processors - http//parasol.tamu.edu/rwerger
- Thanks to Dr. Chapman