Advanced Topics in Algorithms and Data Structures 1 Two parallel list ranking algorithms An O (log n ) time and O ( n log n ) work list ranking algorithm.

Slides:



Advertisements
Similar presentations
General algorithmic techniques: Balanced binary tree technique Doubling technique: List Ranking Problem Divide and concur Lecture 6.
Advertisements

Parallel List Ranking Advanced Algorithms & Data Structures Lecture Theme 17 Prof. Dr. Th. Ottmann Summer Semester 2006.
List Ranking and Parallel Prefix
Linked List Ranking Parallel Algorithms 1. Work Analysis – Pointer Jumping Number of Steps: Tp = O(Log N) Number of Processors: N Work = O(N log N) T1.
1 Parallel Algorithms (chap. 30, 1 st edition) Parallel: perform more than one operation at a time. PRAM model: Parallel Random Access Model. p0p0 p1p1.
Parallel Algorithms.
List Ranking on GPUs Sathish Vadhiyar. List Ranking on GPUs Linked list prefix computations – computations of prefix sum on the elements contained in.
Algorithms (and Datastructures) Lecture 3 MAS 714 part 2 Hartmut Klauck.
Advanced Topics in Algorithms and Data Structures
Optimizing Compilers for Modern Architectures Allen and Kennedy, Chapter 13 Compiling Array Assignments.
BackTracking Algorithms
Lecture 3: Parallel Algorithm Design
Chapter 4: Trees Part II - AVL Tree
1 Parallel Parentheses Matching Plus Some Applications.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,
Numerical Algorithms Matrix multiplication
Advanced Topics in Algorithms and Data Structures Lecture pg 1 Recursion.
Advanced Topics in Algorithms and Data Structures 1 Rooting a tree For doing any tree computation, we need to know the parent p ( v ) for each node v.
Advanced Topics in Algorithms and Data Structures Classification of the PRAM model In the PRAM model, processors communicate by reading from and writing.
PRAM Models Advanced Algorithms & Data Structures Lecture Theme 13 Prof. Dr. Th. Ottmann Summer Semester 2006.
Advanced Topics in Algorithms and Data Structures Lecture 6.1 – pg 1 An overview of lecture 6 A parallel search algorithm A parallel merging algorithm.
Parallel Prefix Computation Advanced Algorithms & Data Structures Lecture Theme 14 Prof. Dr. Th. Ottmann Summer Semester 2006.
Advanced Topics in Algorithms and Data Structures Page 1 Parallel merging through partitioning The partitioning strategy consists of: Breaking up the given.
FALL 2004CENG 351 Data Management and File Structures1 External Sorting Reference: Chapter 8.
Advanced Topics in Algorithms and Data Structures 1 Lecture 4 : Accelerated Cascading and Parallel List Ranking We will first discuss a technique called.
CS 536 Spring Global Optimizations Lecture 23.
Accelerated Cascading Advanced Algorithms & Data Structures Lecture Theme 16 Prof. Dr. Th. Ottmann Summer Semester 2006.
Program Design and Development
FALL 2006CENG 351 Data Management and File Structures1 External Sorting.
Parallel Merging Advanced Algorithms & Data Structures Lecture Theme 15 Prof. Dr. Th. Ottmann Summer Semester 2006.
Fall 2008Array Manipulation Algorithms1. Fall 2008Array Manipulation Algorithms2 Searching Let A = (a 1, a 2, …, a n ) be a sorted array of data such.
Computer Programming Sorting and Sorting Algorithms 1.
Prof. Fateman CS 164 Lecture 221 Global Optimization Lecture 22.
Advanced Topics in Algorithms and Data Structures Page 1 An overview of lecture 3 A simple parallel algorithm for computing parallel prefix. A parallel.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
1 Shortest Path Algorithms. 2 Routing Algorithms Shortest path routing What is a shortest path? –Minimum number of hops? –Minimum distance? There is a.
Fall 2008Paradigms for Parallel Algorithms1 Paradigms for Parallel Algorithms.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
1 Lecture 2: Parallel computational models. 2  Turing machine  RAM (Figure )  Logic circuit model RAM (Random Access Machine) Operations supposed to.
Computer Science and Engineering Parallel and Distributed Processing CSE 8380 February 8, 2005 Session 8.
1 Parallel Sorting Algorithms. 2 Potential Speedup O(nlogn) optimal sequential sorting algorithm Best we can expect based upon a sequential sorting algorithm.
1 PRAM Algorithms Sums Prefix Sums by Doubling List Ranking.
CSC 211 Data Structures Lecture 13
Review 1 Selection Sort Selection Sort Algorithm Time Complexity Best case Average case Worst case Examples.
UNIT 5.  The related activities of sorting, searching and merging are central to many computer applications.  Sorting and merging provide us with a.
Vertex Coloring Distributed Algorithms for Multi-Agent Networks
Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar
Fall 2008Simple Parallel Algorithms1. Fall 2008Simple Parallel Algorithms2 Scalar Product of Two Vectors Let a = (a 1, a 2, …, a n ); b = (b 1, b 2, …,
Data Structures and Algorithms Searching Algorithms M. B. Fayek CUFE 2006.
1 Chapter 6 Heapsort. 2 About this lecture Introduce Heap – Shape Property and Heap Property – Heap Operations Heapsort: Use Heap to Sort Fixing heap.
3/12/2013Computer Engg, IIT(BHU)1 PRAM ALGORITHMS-3.
Unit-8 Sorting Algorithms Prepared By:-H.M.PATEL.
1 Distributed Vertex Coloring. 2 Vertex Coloring: each vertex is assigned a color.
1 A simple parallel algorithm Adding n numbers in parallel.
PERFORMANCE EVALUATIONS
Auburn University
Lecture 3: Parallel Algorithm Design
Parallel Algorithms (chap. 30, 1st edition)
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Parallel Odd-Even Sort Algorithm Dr. Xiao.
Lecture 2: Parallel computational models
Red-Black Trees Motivations
Lecture 9 Algorithm Analysis
Lecture 9 Algorithm Analysis
Lecture 9 Algorithm Analysis
Linked List and Selection Sort
Unit –VIII PRAM Algorithms.
CENG 351 Data Management and File Structures
Parallel Sorting Algorithms
CS203 Lecture 15.
Presentation transcript:

Advanced Topics in Algorithms and Data Structures 1 Two parallel list ranking algorithms An O (log n ) time and O ( n log n ) work list ranking algorithm. An O (log n loglog n ) time and O ( n ) work list ranking algorithm.

Advanced Topics in Algorithms and Data Structures 2 List ranking Input: A linked list L of n elements. L is given in an array S such that the entry S ( i ) contains the index of the node which is the successor of the node i in L. Output: The distance of each node i from the end of the list.

Advanced Topics in Algorithms and Data Structures 3 List ranking List ranking can be solved in O ( n ) time sequentially for a list of length n. Exercise : Design an algorithm. Hence, a work-optimal parallel algorithm should do only O ( n ) work.

Advanced Topics in Algorithms and Data Structures 4 A simple list ranking algorithm Output: For each 1  i  n, the distance R ( i ) of node i from the end of the list. begin for 1  i  n do in parallel if S ( i )  0 then R ( i ) := 1 else R ( i ) := 0 endfor while S ( i )  0 and S ( S ( i ))  0 do Set R ( i ) := R ( i ) + R ( S ( i )) Set S ( i ) := S ( S ( i )) end

Advanced Topics in Algorithms and Data Structures 5 A simple list ranking algorithm At the start of an iteration of the while loop, R ( i ) counts the nodes in a sublist starting at i (a subset of nodes which are adjacent in the list).

Advanced Topics in Algorithms and Data Structures 6 A simple list ranking algorithm After the iteration, R ( i ) counts the nodes in a sublist of double the size. When the while loop terminates, R ( i ) counts all the nodes starting from i and until the end of the list

Advanced Topics in Algorithms and Data Structures 7 Complexity and model The algorithm terminates after O (log n ) iterations of the while loop. The work complexity is O ( n log n ) since we allocate one processor for each node. We need the CREW PRAM model since several nodes may try to read the same successor ( S ) values.

Advanced Topics in Algorithms and Data Structures 8 Complexity and model Exercise : Modify the algorithm to run on the EREW PRAM with the same time and processor complexities.

Advanced Topics in Algorithms and Data Structures 9 The strategy for an optimal algorithm Our aim is to modify the simple algorithm so that it does optimal O ( n ) work. The best algorithm would be the one which does O ( n ) work and takes O (log n ) time. There is an algorithm meeting these criteria, however the algorithm and its analysis are very involved.

Advanced Topics in Algorithms and Data Structures 10 The strategy for an optimal algorithm We will study an algorithm which does O ( n ) work and takes O (log n loglog n ) time. However, in future we will use the optimal algorithm for designing other algorithms.

Advanced Topics in Algorithms and Data Structures 11 The strategy for an optimal algorithm 1.Shrink the initial list L by removing some of the nodes. The modified list should have O ( n / log n ) nodes. 2.Apply the pointer jumping technique (the suboptimal algorithm) on the list with O ( n / log n ) nodes.

Advanced Topics in Algorithms and Data Structures 12 The strategy for an optimal algorithm 3.Restore the original list and rank all the nodes removed in Step 1. The important step is Step1. We need to choose a subset I of nodes for removal.

Advanced Topics in Algorithms and Data Structures 13 Independent sets Definition A set I of nodes is independent if whenever i  I, S ( i )  I. The blue nodes form an independent set in this list

Advanced Topics in Algorithms and Data Structures 14 Independent sets The main task is to pick an independent set correctly. We pick an independent set by first coloring the nodes of the list by two colors.

Advanced Topics in Algorithms and Data Structures 15 2-coloring the nodes of a list Definition: A k -coloring of a graph G is a mapping: c : V   0,1,…, k - 1  such that c ( i )  c ( j ) if  i, j   E. It is very easy to design an O ( n ) time sequential algorithm for 2-coloring the nodes of a linked list.

Advanced Topics in Algorithms and Data Structures 16 2-coloring the nodes of a list We will assume the following result: Theorem: A linked list with n nodes can be 2-colored in O (log n ) time and O ( n ) work.

Advanced Topics in Algorithms and Data Structures 17 Independent sets When we 2-color the nodes of a list, alternate nodes get the same color. Hence, we can remove the nodes of the same color to reduce the size of the original list from n to n /2.

Advanced Topics in Algorithms and Data Structures 18 Independent sets However, we need a list of size to run our pointer jumping algorithm for list ranking. If we repeat the process loglog n time, we will reduce the size of the list to i.e., to.

Advanced Topics in Algorithms and Data Structures 19 Preserving the information When we reduce the size of the list to, we have lost a lot of information because the removed nodes are no longer present in the list. Hence, we have to put back the removed nodes in their original positions to correctly compute the ranks of all the nodes in the list.

Advanced Topics in Algorithms and Data Structures 20 Preserving the information Note that we have removed the nodes in O (log log n ) iterations. So, we have to replace the nodes also in O (log log n ) iterations.

Advanced Topics in Algorithms and Data Structures 21 Preserving the information The magenta nodes are removed through 2-coloring. The number of a node is shown in black. The initial rank of each node is shown below the node in the figure.

Advanced Topics in Algorithms and Data Structures 22 Preserving the information The modified rank of an existing yellow node is shown in the second figure. The modified rank is with respect to the next existing node in the list.

Advanced Topics in Algorithms and Data Structures 23 Preserving the information For our list: P is the array which holds the predecessor indices. S is the array which holds the successor indices. i is the number of the removed node. U is the array where we store information for the removed nodes. This information is used later to restore the removed nodes.

Advanced Topics in Algorithms and Data Structures 24 Preserving the information

Advanced Topics in Algorithms and Data Structures 25 Preserving the information The code executed for removing the nodes in the independent set I : for all i  I pardo Set U ( i ) := ( i, S ( i ), P ( i )) Set R ( P ( i )) := R ( P ( i )) + R ( i ) Set S ( P ( i )) := S ( i ) Set P ( S ( i )) := P ( i )

Advanced Topics in Algorithms and Data Structures 26 Preserving the information The predecessor and successor pointers are updated The ranks of nodes which are immediately before a removed node are updated.

Advanced Topics in Algorithms and Data Structures 27 Preserving the information The array P and S can be compacted in O ( n ) work and O (log n ) time after each phase of removal of nodes. This is done through a parallel prefix computation. Recall that we have to do the removal of nodes for loglog n phases to reduce the number of nodes to. We can keep a separate U array for each phase.

Advanced Topics in Algorithms and Data Structures 28 Putting back a node A removed node can be reinserted in O (1) time

Advanced Topics in Algorithms and Data Structures 29 Complexity 2-coloring in each stage can be done in O(log n) time and O(n) work. The compaction of the P and S arrays is done through a parallel prefix computation in O(log n) time and O(n) work. There are in all O(log log n) stages in which we have to remove nodes. Each stage takes O(log n) time due to the 2-coloring and parallel prefix computations.

Advanced Topics in Algorithms and Data Structures 30 Complexity At the end, we do one list ranking for a list of size O(n/log n). This takes O(n) work and O(log n) time. So, the overall complexity is O(n) work and O(log n loglog n) time.