Unformatted text preview: to the extent that you might as well have stayed in a sequenCal language CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 26 Mo3va3ng Example (adopted from The Java MCM: Manson, Pugh, Adve) Ini!ally, x == 0, y == 0 Task 1 Task 2 reg1 = x reg2 = y y = 1 x = 2 What could reg1 and reg2 hold at this point? CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 27 Mo3va3ng Example (adopted from The Java MCM: Manson, Pugh, Adve) Ini!ally, x == 0, y == 0 Task 1 Task 2 reg1 = x reg2 = y y = 1 x = 2 reg1 = 0, reg2 = 0 CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 28 Mo3va3ng Example (adopted from The Java MCM: Manson, Pugh, Adve) Ini!ally, x == 0, y == 0 Task 1 Task 2 reg1 = x y = 1 reg2 = y x = 2 reg1 = 0, reg2 = 1 CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 29 Mo3va3ng Example (adopted from The Java MCM: Manson, Pugh, Adve) Ini!ally, x == 0, y == 0 Task 1 Task 2 reg2 = y x = 2 reg1 = x y = 1 reg1 = 2, reg2 = 0 CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 30 A Weaker Model: Sequen3al Consistency • Two parts to the deﬁniCon: – All memory ops within a task complete in program order – Across tasks, memory ops are interleaved in a consistent total order • IntuiCvely: “An interleaving of the tasks’ memops if they were instantaneous” – all of the preceding slides obeyed sequenCal consistency • Not as ideal as strict, but sCll comprehensible • Unfortunately, sCll untenable in general – guaranteeing a consistent, total order on memory ops again implies too much overhead CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 31 Diﬀerence Between Strict and Sequen3al [Clarifying something I stumbled over in lecture a]er the fact] In strict, the global total ordering matches that “which actually happened” according to some global clock In sequenCal, the global total ordering is consistent, but may not reﬂect what happened w.r.t. some global clock if all memory ops were instantaneous – i.e., it takes into account skew in clocks, Cme required for things to percolate through a system CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 32 Mo3va3ng Example (adapted from The Java MCM: Manson, Pugh, Adve) Ini!ally, x == 0, y == 0 Task 1 Task 2 reg1 = x reg2 = y y = 1 x = 2 What about reg1 = 2, reg2 = 1 ? Sadly, yes – this can occur within most languages/architectures CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 33 Mo3va3ng Example (adapted from The Java MCM: Manson, Pugh, Adve) Ini!ally, x == 0, y == 0 Task 1 Task 2 reg1 = x reg2 = y y = 1 x = 2 What about reg1 = 2, reg2 = 1 ? The “blame the compiler” explana3on: • TradiConally, a compiler looks at a single task at a Cme (PracCcally speaking, it can’t consider all possible potenCally concurrent tasks) • To a compiler looking at code in isolaCon, nothing prevents reordering as follows: Code Snippet 1 y = 1 reg1 = x Code Snippet 2 x = 2 reg2 = y (at which point, obvious execuCon interleavings can yield the reg1 = 2, reg2 = 1 result). CSEP 524: P...
View
Full Document
 Winter '09
 CSEP

Click to edit the document details