







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








file:///E|/parallel_com_arch/lecture35/35_1.htm[6/13/2012 12:16:31 PM]
file:///E|/parallel_com_arch/lecture35/35_2.htm[6/13/2012 12:16:31 PM]
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]
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?
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]
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.
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?
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.
file:///E|/parallel_com_arch/lecture35/ex_sol_3.htm[6/13/2012 12:16:32 PM]
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.
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!
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.
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]