Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multicore Programming

Similar presentations


Presentation on theme: "Multicore Programming"— Presentation transcript:

1 Multicore Programming
Universal & Cache Tutorial 7 CS Spring 2010

2 Summary Universal overview Universal questions Cache coherency - MESI

3 Theorem: Universality
Consensus is universal From n-thread consensus build a Wait-free Linearizable n-threaded implementation Of any sequentially specified object Art of Multiprocessor Programming 3 3

4 Universal Application Part I
public Response apply(Invoc invoc) { int i = ThreadID.get(); Node prefer = new node(invoc); while (prefer.seq == 0) { Node before = Node.max(head); Node after = before.decideNext.decide(prefer); before.next = after; after.seq = before.seq + 1; head[i] = after; } Notice that the setting could be by a node other than the one whose method call the winning node represents. Art of Multiprocessor Programming 4 4

5 Universal Application Part II
... //compute my response SeqObject MyObject = new SeqObject(); current = tail.next; while (current != prefer){ MyObject.apply(current.invoc); current = current.next; } return MyObject.apply(current.invoc); To compute my response. Art of Multiprocessor Programming 5 5

6 Wait-Free Sliding Help Window
while (announce[i].seq == 0) { Node before = head[i]; Node help = announce[(before.seq + 1 % n)]; if (help.seq == 0) prefer = help; else prefer = announce[i]; Art of Multiprocessor Programming 6 6

7 Ptr to cell thread i wants to append
Wait-free Construction Ptr to cell thread i wants to append announce i tail 1 2 3 4 head i Art of Multiprocessor Programming 7 7

8 Seq The dummy node at the tail of the list is initially set to 1.
Which of the algorithms (wait/lock-free), would cease to work correctly if the sequence number of the dummy node was initially set to 0?

9 Art of Multiprocessor Programming
Universal Object public class Universal { private Node[] head; private Node tail = new Node(); tail.seq = 1; for (int j=0; j < n; j++){ head[j] = tail } tail.seq = 0; Art of Multiprocessor Programming 9 9

10 Seq Solution Doesn't matter for Lock-Free
Won't work for Wait-Free since the announce array is set to the tail.

11 wait-free universal construction
In the wait-free universal construction If each thread first tries to append its own node, and then tries to help the other thread. Explain whether this alternative approach works.

12 Nondeterministic Propose a way to fix the universal
construction to work for objects with nondeterministic sequential specifications.

13 Nondeterministic solution
Replace with an equivalent deterministic object. Add another consensus object to each node, publishing the new state.

14 Headless solution Propose a way to avoid using distributed head.
public class Universal { private Node[] head; private Node tail = new Node(); tail.seq = 1; for (int j=0; j < n; j++){ head[j] = tail }

15 Headless solution Replace the call of max() with :
public Node last(Node tail){ Node prev = tail; Node current = prev.next; while(true){ if(current==null || current.seq==0)‏ return prev; prev = current; current = current.next; }

16 Bounded memory Propose a way to fix the universal
construction to work with bounded of memory.

17 Bounded memory solution
Add a “Garbage collection”. Update the tail reference to next node that all the heads passed.

18 Modified, Exclusive, Shared & Invalid
MESI Modified, Exclusive, Shared & Invalid

19 MESI What is the advantages of distinguishing Exclusive and Modified?
What is the advantages of distinguishing Exclusive and Shared?

20 Art of Multiprocessor Programming
          This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work Under the following conditions: Attribution. You must attribute the work to “The Art of Multiprocessor Programming” (but not in any way that suggests that the authors endorse you or your use of the work). Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to Any of the above conditions can be waived if you get permission from the copyright holder. Nothing in this license impairs or restricts the author's moral rights. Art of Multiprocessor Programming 20 20


Download ppt "Multicore Programming"

Similar presentations


Ads by Google