1 / 11

Lecture 5 prepared by: Dragos Brad (#222839) Mariam Abdi

Lecture 5 prepared by: Dragos Brad (#222839) Mariam Abdi. Two levels: Upper (software) - describes the algorithm in terms of a sequence of time units, where each time unit may include any number of concurrent operations. Note:  no need to mention processors

jabir
Download Presentation

Lecture 5 prepared by: Dragos Brad (#222839) Mariam Abdi

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 5prepared by: Dragos Brad (#222839)Mariam Abdi

  2. Two levels: Upper (software) - describes the algorithm in terms of a sequence of time units, where each time unit may include any number of concurrent operations. Note:  no need to mention processors  the numnber of operations is easy to compute Lower (hardware) - this level will not be addressed in the course. Work-Time Frameworkchapter 1 (Jaja’s book)

  3. Let the Wi(n) be the number of operations performed in step i (1  i  T(n)). Simulate each set of Wi(n) operations in parallel steps by a p-processor PRAM. P-Processor PRAM: T(n) T(n)   i=1 i=1           W2(n) W(n) W1(n) Wi(n) Wi(n) Wi(n)  + + ... p p p p p p 1 + T(n) + WT Scheduling Principle

  4. Summary of Chapter 1 • Know what’s meant by the Upper level • Work of an algorithm equals the total sum of all operations • T(n) = time it takes a processor to complete work • Speed-up = Sequential_time / T(n) • Cost(n) = T(n) P(n) • PRam Model and other models were discussed

  5. Techniques - Part 1chapter 2 (Jaja’s book) 1) Balanced Trees: Builds a balanced tree on the input elements and traverses the tree forward and backward to and from the root. Example: The Prefix-Sum Problem There is a sequence of n-elements {x1, x2, …,xn} drawn from a set S with the binary associative operation *. The prefix sums of this sequence are the n partial sums defined by: si = x1 * x2 * … * xi, 1  i  n A balanced binary tree will be used to derive a fast parallel algorithm to compute the prefix sums.

  6. Balanced trees continuation + x1 + x2 +…+ x8 x1 + x2 + x3 + x4 x5 + x6 + x7 + x8 + + x1 + x2 x3 + x4 x5 + x6 x7 + x8 + + + + x x2 x3 x4 x5 x6 x7 x8 Illustration of balanced trees for the ‘prefix-sums’ problem. (Each internal node represents the application of the operation ‘+’ to its children during a forward traversal of the tree. Hence, each node v holds the sum of the elements stored in the leaves of the subtree rooted at v. During a backward traversal of the tree, the prefix sums of the data stored in the nodes at a given height are computed)

  7. Techniques - Part 2achapter 2 (Jaja’s book) 2) Pointer Jumping: This technique allows the fast processing of data stored in the form of a set of rooted directed trees. Example 1: Finding the Roots of a Forest Problem Let F be a forest consisting of a set of rooted directed trees. The forest F is specified by an array P of length n such that P(i) = j if j is the parent of i in a tree of F. The problem is to determine the root S(j) of the tree containing the node j, for each j between 1 and n.

  8. Pointer Jumping continuation x9 The technique of pointer jumping consists of updating the successor of each node by that successor’s successor. As the technique is applied repeatedly, the successor of a node is an ancestor that becomes closer and closer to the root of the tree containing that node. After k iterations, the distance between i and S(i) as they appear in the directed tree of F is 2k unless S(i) is a root. Illustration of pointer jumping for the ‘finding the roots of a forest’ problem. x4 x12 x6 x3 x2 x5 Step 1 - 1st iteration Step 2 - 2nd iteration Step 3 - 3rd iteration

  9. Pointer Jumping continuation Algorithm - Finding the roots of a forest Input: A forest of rooted trees, each with a self-loop at its root. Output: For each vertex i, the root S(i) of the tree containing i. for i =1 to n do S[i] = P[i]; while S[i]  S[S[i]] do S[i] = S[S[i]]; Analysis: Time O(log h) time Work O(n*log h) operations Note: h is the maximum height of any tree in the forest, n is the total number of vertices in the forest

  10. Pointer Jumping continuation Techniques - Part 2bchapter 2 (Jaja’s book) Example 2: Parallel Prefix Problem Here it’s assumed that each node i in the forest has a weight W(i). The pointer jumping technique it’s used, in this case, to compute for each node i, the sum of the weights stored in the nodes on the path from the node i to the root of i’s tree. This amounts to generating the prefix sums of several sequences of elements such that each sequence is given by the order of nodes as they appear on each path. Please think of an algorithm for this, that runs in O(log n) time and O(n*log n) work.

  11. Pointer Jumping continuation 0 0 0 7 10 2 0 0 7 11 4 5 6 2 X20 3 Illustration of pointer jumping for the ‘parallel-prefix’ problem. (Above, the weight of element x20 is 17 since it’s the sum of all the weights of the nodes between x20 and the root of its tree)

More Related