counters-tut12 - Click to edit Master subtitle style Art of...

Info iconThis preview shows pages 1–17. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Click to edit Master subtitle style Art of Multiprocessor Multicore Programming Shared Counters Tutorial 12 CS 0368-3469 Spring 2009 Art of Multiprocessor Art of Multiprocessor 22 Summary • Combining Trees • Counting Network Art of Multiprocessor Art of Multiprocessor 33 Art of Multiprocessor Programming 3 Software Combining Tree 4 Contention: All spinning local Parallelism: Potential n/log n speedup Art of Multiprocessor Art of Multiprocessor 44 Art of Multiprocessor Programming 4 Combining Trees Art of Multiprocessor Art of Multiprocessor 55 Art of Multiprocessor Programming 5 Combining Trees +3 Art of Multiprocessor Art of Multiprocessor 66 Art of Multiprocessor Programming 6 Combining Trees +3 +2 Art of Multiprocessor Art of Multiprocessor 77 Art of Multiprocessor Programming 7 Combining Trees +3 +2 Two threads meet, combine sums Art of Multiprocessor Art of Multiprocessor 88 Art of Multiprocessor Programming 8 Combining Trees +3 +2 Two threads meet, combine sums +5 Art of Multiprocessor Art of Multiprocessor 99 Art of Multiprocessor Programming 9 Combining Trees 5 +3 +2 +5 Combined sum added to root Art of Multiprocessor Art of Multiprocessor 1010 Art of Multiprocessor Programming 10 Combining Trees 5 +3 +2 Result returned to children Art of Multiprocessor Art of Multiprocessor 1111 Art of Multiprocessor Programming 11 Combining Trees 5 3 Results returned to threads Art of Multiprocessor Art of Multiprocessor 1212 Trinary CombiningTree • Implement a trinary CombiningTree. – Allows up to three threads coming from three subtrees to combine at a given node. • Estimate the advantages and disadvantages? Art of Multiprocessor Art of Multiprocessor 1313 Trinary Solution enum CStatus{ IDLE,FIRST,SECOND, THIRD,DONE,ROOT} Art of Multiprocessor Art of Multiprocessor 1414 Trinary Solution public class Node3 { boolean locked = false ; // is node locked? int drained = ; // distributing after CStatus3 cStatus; // combining status int firstValue, secondValue, thirdValue; // values int result, secondResult, thirdResult; // results Node3 parent; // reference to parent public Node3() { cStatus = CStatus3.ROOT; } public Node3(Node3 parent) { this .parent = parent; cStatus = CStatus3.IDLE; } Art of Multiprocessor Art of Multiprocessor 1515 public int getAndIncrement(){ CStatus3 myStatus; Stack<Node3> stack = new Stack<Node3>(); Node3 myLeaf = leaf[ ThreadID.get() / 2]; Node3 node = myLeaf; // phase one while ((myStatus = node.precombine()) == CStatus3.IDLE) { node = node.parent; } Node3 stop = node; … } Trinary Solution Art of Multiprocessor Art of Multiprocessor...
View Full Document

This note was uploaded on 10/11/2010 for the course COS COS226 taught by Professor Klazar during the Spring '10 term at University of Pretoria.

Page1 / 40

counters-tut12 - Click to edit Master subtitle style Art of...

This preview shows document pages 1 - 17. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online