Docsity

Release Consistency - Parallel Computer Architecture - Lecture Slides, Slides of Computer Science

Toggle sidebar
bg1
Objectives_template
file:///E|/parallel_com_arch/lecture35/35_1.htm[6/13/2012 12:16:31 PM]
Module 15: "Memory Consistency Models"
Lecture 35: "Release Consistency and Delayed Consistency"
Memory Consistency Models
Release consistency
Hardware support
Industry situation
Eager-exclusive reply
Compilers’ job
Delayed consistency
Conclusions
[From Chapters 9 and 11 of Culler, Singh, Gupta]
[Additional reading: Adve and Gharachorloo , WRL Tech Report, 1995]
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Release Consistency - Parallel Computer Architecture - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

file:///E|/parallel_com_arch/lecture35/35_1.htm[6/13/2012 12:16:31 PM]

Module 15: "Memory Consistency Models"

Lecture 35: "Release Consistency and Delayed Consistency"

Memory Consistency Models

Release consistency

Hardware support

Industry situation

Eager-exclusive reply

Compilers’ job

Delayed consistency

Conclusions

[From Chapters 9 and 11 of Culler, Singh, Gupta]

[Additional reading: Adve and Gharachorloo , WRL Tech Report, 1995]

file:///E|/parallel_com_arch/lecture35/35_2.htm[6/13/2012 12:16:31 PM]

Module 15: "Memory Consistency Models"

Lecture 35: "Release Consistency and Delayed Consistency"

Release consistency

Relaxes WO even further Categorize synchronization operations into acquire and release Acquire is a read (e.g., a normal load) or an atomic read-modify-write (e.g., LL/SC pair) used to get access to certain set of protected variables; popular examples of acquire include LOCK operations and waiting on a flag Release is a write (e.g., a normal store) or an atomic read-modify-write (e.g., LL/SC pair) used to grant access to certain set of protected variables to others; popular examples of release include UNLOCK operations and setting a flag Barrier is release (arrival) as well as acquire (departure) Couple of observations There is no harm in issuing the acquire operation and the instructions after it, and committing them before all instructions preceding acquire have committed There is no harm in executing and committing the instructions after release even before the release is committed Of course, such re-ordering applies to only those instructions that access different memory addresses Must not issue any instruction following an acquire before the acquire commits (semantics of acquire must be maintained) Must commit all instructions ahead of release before release can commit (at this point all new values become visible to others)

Synchronization operations must be labeled properly Otherwise compiler must insert fence instructions at acquire and release boundaries (may lose some of the benefits of RC)

file:///E|/parallel_com_arch/lecture35/35_3.htm[6/13/2012 12:16:31 PM]

Module 15: "Memory Consistency Models"

Lecture 35: "Release Consistency and Delayed Consistency"

Eager-exclusive reply

Programmers’ interface P0: A=1; flag=1; P1: while (!flag); print A; Programmer thinks A will be printed as 1 A machine that implements eager-exclusive replies can produce a value of 0 (even if the processor is SC); how? P0: A=1; WMB; flag=1; P1: while (!flag); print A; Formally, at every release boundary (e.g., before UNLOCK, BARRIER, flag set) a WMB must be inserted; WMB will wait for all pending inval acks to be collected before allowing any further issue from store queue Eager-exclusive replies essentially require the same treatment at the programmers’ interface as if RC allowed only write re-ordering (is it similar to PSO? No) The write atomicity is anyway broken P0: A=1; flag=1; P1: while(!flag); print A; Why bother to complicate OTT by holding back writebacks and interventions?

Compilers’ job

Must be careful while carrying out code motion Usually it is very hard to formally argue about correctness of a re-ordering The compiled code must not follow a model that is weaker than whatever is advertised to the programmer The underlying microprocessor normally supports a model that is at least as strong as whatever the compiler offers; it could be stronger, but cannot be weaker (that would be unfaithful to the programmer) A piece of program compiled for RC will still work fine on an SC microprocessor, but will fail to exploit some of the optimizations done by the compiler (here working fine means it will produce an RC-compliant output and that is the programmers’ interface) PC, PSO, TSO do not offer much opportunity for compiler optimization Synchronized or properly labeled programs A program that labels all synchronization operations with some directives is called a synchronized program For locks and barriers it is easy to do; how to identify all event synchronizations through flags? Often the programmer can label these manually Formally, it is necessary to label all competing operations; two conflicting operations (i.e. to the same location and one is a write) from two different processes are said to be competing if they appear back-to-back in at least one possible SC execution A program is synchronized if all competing operations are labeled as synchronization operations Once this (hard part) is done, compiler inserts fence instructions at proper places depending on how relaxed the model is Current state of automatically producing synchronized programs is quite sad Requires enumerating all SC-compliant re-orderings The existing analysis is either conservative or very expensive So normally it becomes programmers’ job One extreme would be to label all operations as competing; this will lead to

file:///E|/parallel_com_arch/lecture35/35_3.htm[6/13/2012 12:16:31 PM]

performance poorer than SC (why?) Sometimes a programmer may choose to leave some competing operations unlabeled (i.e. intentionally introduce data races); leads to better performance if either it does not compromise correctness (due to some peculiar program behavior) or it is okay to have non-deterministic outcome (e.g., red-black ordering)

file:///E|/parallel_com_arch/lecture35/ex_3.htm[6/13/2012 12:16:32 PM]

Exercise : 3

These problems should be tried after module 15 is completed.

  1. [5+5] Consider a 512-node system. Each node has 4 GB of main memory. The cache block size is 128 bytes. What is the total directory memory size for (a) bitvector, (b) DiriB with i=3?
  2. [5+5+5+10] For a simple two-processor NUMA system, the number of cache misses to three virtual pages X, Y, Z is as follows.

Page X: P0 has 14 misses, P1 has 11 misses. P1 takes the first miss. Page Y: P0 has zero misses, P1 has 18 misses. Page Z: P0 has 15 misses, P1 has 9 misses. P0 takes the first miss.

The remote to local miss latency ratio is four. Evaluate the aggregate time spent in misses by the two processors in each of the following policies. Assume that a local miss takes 400 cycles.

(a) First touch placement. (b) All three pages on P0. (c) All three pages on P1. (d) Best possible application-directed static placement i.e. a one-time call to the OS to place the three pages.

  1. [30] Suppose you want to transpose a matrix in parallel. The source matrix is A and the destination matrix is B. Both A and B are decomposed in such a way that each node gets a chunk of consecutive rows. Application-directed page placement is used to map the pages belonging to each chunk in the local memory of the respective nodes. Now the transpose can be done in two ways. The first algorithm, known as "local read algorithm", allows each node to transpose the band of rows local to it. So naturally this algorithm involves a large fraction of remote writes to matrix B. Assume that the band is wide enough so that there is no false sharing when writing to matrix B. The second algorithm, known as "local write algorithm", allows each node to transpose a band of columns of A such that all the writes to B are local. Naturally, this algorithm involves a large number of remote reads in matrix A. Assume that the algorithms are properly tiled so that the cache utilization is good. In both the cases, before doing the transpose, every node reads and writes to its local segment in A and after doing the transpose every node reads and writes to its local segment in B. Assuming an invalidation-based cache coherence protocol, briefly but clearly explain which algorithm is expected to deliver better performance. How much synchronization does each algorithm require (in terms of the number of critical sections and barriers)? Assume that the caches are of infinite capacity and that a remote write is equally expensive in all respects as a remote read because in both cases the retirement is held up for a sequentially consistent implementation.
  2. [5+5] If a compiler reorders accesses according to WO and the underlying

file:///E|/parallel_com_arch/lecture35/ex_3.htm[6/13/2012 12:16:32 PM]

processor is SC, what is the consistency model observed by the programmer? What if the compiler produces SC code, but the processor is RC?

  1. [5+5] Consider the following piece of code running on a faulty microprocessor system which does not preserve any program order other than true data and control dependence order.

LOCK (L1) load A store A UNLOCK (L1) load B store B LOCK (L1) load C store C UNLOCK (L1)

(a) Insert appropriate WMB and MB instructions to enforce SC. Do not over- insert anything. (b) Repeat part (a) to enforce RC.

  1. [5+10] Consider implementing a directory-based protocol to keep the private L1 caches of the cores in a chip-multiprocessor (CMP) coherent. Assume that the CMP has a shared L2 cache. The most natural way of doing it is to attach a directory to the tag of each L2 cache block. An L1 cache miss gets forwarded to the L2 cache. The directory entry is looked up in parallel with the L2 cache block. Does this implementation suit an inclusive hierarchy or exclusive hierarchy? Explain. If the cache block sizes of the L1 cache and the L2 cache are different, explain briefly how you will manage the state of the L2 cache block on receiving a writeback from the L1 cache. Do not assume per sector directory entry in this design.

file:///E|/parallel_com_arch/lecture35/ex_sol_3.htm[6/13/2012 12:16:32 PM]

X P1 22400 4400 26800

Z P0 6000 14400 20400

Z P1 24000 3600 27600

Thus X and Z both should be placed on P0. Y should be placed on P1. The aggregate latency of this is 50800 cycles. As you can see, this is about 7% better than first touch.

  1. [30] Suppose you want to transpose a matrix in parallel. The source matrix is A and the destination matrix is B. Both A and B are decomposed in such a way that each node gets a chunk of consecutive rows. Application-directed page placement is used to map the pages belonging to each chunk in the local memory of the respective nodes. Now the transpose can be done in two ways. The first algorithm, known as "local read algorithm", allows each node to transpose the band of rows local to it. So naturally this algorithm involves a large fraction of remote writes to matrix B. Assume that the band is wide enough so that there is no false sharing when writing to matrix B. The second algorithm, known as "local write algorithm", allows each node to transpose a band of columns of A such that all the writes to B are local. Naturally, this algorithm involves a large number of remote reads in matrix A. Assume that the algorithms are properly tiled so that the cache utilization is good. In both the cases, before doing the transpose, every node reads and writes to its local segment in A and after doing the transpose every node reads and writes to its local segment in B. Assuming an invalidation-based cache coherence protocol, briefly but clearly explain which algorithm is expected to deliver better performance. How much synchronization does each algorithm require (in terms of the number of critical sections and barriers)? Assume that the caches are of infinite capacity and that a remote write is equally expensive in all respects as a remote read because in both cases the retirement is held up for a sequentially consistent implementation.

Solution: Analysis of local read algorithm: Before the algorithm starts, the band of rows to be transposed by a processor is already in its cache. Each remote write to a cache block of B involves a 2-hop transaction (requester to home and back) without involving any invalidation. After transpose each processor has a large number of remote cache blocks in its cache. Here a barrier is needed before a processor is allowed to work on its local rows of B. After the barrier each cache read or write miss to B involves a 2-hop intervention (local home to owner and back). So in this algorithm, each processor suffers from local misses before transpose, 2-hop misses during transpose, and 2-hop misses after transpose.

Analysis of local write algorithm: Before the algorithm starts, the band of columns to be transposed by a processor is quite distributed over the system. In fact, 1/P portion of the column would be in the local cache. Before the transpose starts, a barrier is needed. In the transpose phase, each cache miss of A involves a 2-hop transaction (requester to home's cache and back). Each cache miss to B is a local miss. After the transpose the local band of rows of B is already in the cache of each processor. So they enjoy hits in this phase. So in this algorithm, each processor suffers from local misses before transpose, 2-hop

file:///E|/parallel_com_arch/lecture35/ex_sol_3.htm[6/13/2012 12:16:32 PM]

misses and local misses during transpose, and hits after transpose.

Both the algorithms have the same number of misses, but the local write algorithm has more local misses and less remote misses. Both have the same synchronization requirement. Local write algorithm is better and that's what SPLASH-2 FFT implements. Cheers!

  1. [5+5] If a compiler reorders accesses according to WO and the underlying processor is SC, what is the consistency model observed by the programmer? What if the compiler produces SC code, but the processor is RC?

Solution: WO compiler and SC hardware: programmer sees WO because an SC processor will execute whatever is presented to it in the intuitive order. But since the instruction stream presented to it is already WO, it cannot do any better.

SC compiler and RC hardware: programmer sees RC.

  1. [5+5] Consider the following piece of code running on a faulty microprocessor system which does not preserve any program order other than true data and control dependence order.

LOCK (L1) load A store A UNLOCK (L1) load B store B LOCK (L1) load C store C UNLOCK (L1)

(a) Insert appropriate WMB and MB instructions to enforce SC. Do not over- insert anything. (b) Repeat part (a) to enforce RC.

Solution: (a) MB LOCK(L1) MB load A store A WMB // Need to hold the unlock back before the store to A is done UNLOCK (L1) MB load B store B MB LOCK (L1) MB

file:///E|/parallel_com_arch/lecture35/ex_sol_3.htm[6/13/2012 12:16:32 PM]