Parallel List Ranking Advanced Algorithms & Data Structures Lecture Theme 17 Prof. Dr. Th. Ottmann Summer Semester 2006.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

Introduction to Algorithms
Unit-iv.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Introduction to Programming
Reductions Complexity ©D.Moshkovitz.
Graph Algorithms - 3 Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 13Feb 12, 2014Carnegie Mellon University.
Lecture 11: Algorithms and Time Complexity I Discrete Mathematical Structures: Theory and Applications.
Comp 122, Spring 2004 Order Statistics. order - 2 Lin / Devi Comp 122 Order Statistic i th order statistic: i th smallest element of a set of n elements.
CS16: Introduction to Data Structures & Algorithms
General algorithmic techniques: Balanced binary tree technique Doubling technique: List Ranking Problem Divide and concur Lecture 6.
Chapter 17 Linked Lists.
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.
Data Structures: A Pseudocode Approach with C
Parallel Algorithms.
Data Structures Using C++
List Ranking on GPUs Sathish Vadhiyar. List Ranking on GPUs Linked list prefix computations – computations of prefix sum on the elements contained in.
FIFO Queues CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Chapter 1 Object Oriented Programming 1. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
ABC Technology Project
9.5 Counting Subsets of a Set: Combinations
1 Designing Hash Tables Sections 5.3, 5.4, Designing a hash table 1.Hash function: establishing a key with an indexed location in a hash table.
1 Evaluations in information retrieval. 2 Evaluations in information retrieval: summary The following gives an overview of approaches that are applied.
David Luebke 1 8/25/2014 CS 332: Algorithms Red-Black Trees.
Squares and Square Root WALK. Solve each problem REVIEW:
YO-YO Leader Election Lijie Wang
The x- and y-Intercepts
Addition 1’s to 20.
CS 240 Computer Programming 1
25 seconds left…...
Section 5: More Parallel Algorithms
Week 1.
We will resume in: 25 Minutes.
Advanced Sorting Methods: Shellsort Shellsort is an extension of insertion sort, which gains speed by allowing exchanges of elements that are far apart.
1 Unit 1 Kinematics Chapter 1 Day
Introduction to Recursion and Recursive Algorithms
Foundations of Data Structures Practical Session #11 Sort properties, Quicksort algorithm.
Advanced Topics in Algorithms and Data Structures
Lecture 3: Parallel Algorithm Design
1 Parallel Parentheses Matching Plus Some Applications.
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.
Advanced Topics in Algorithms and Data Structures 1 Lecture 4 : Accelerated Cascading and Parallel List Ranking We will first discuss a technique called.
Accelerated Cascading Advanced Algorithms & Data Structures Lecture Theme 16 Prof. Dr. Th. Ottmann Summer Semester 2006.
Parallel Merging Advanced Algorithms & Data Structures Lecture Theme 15 Prof. Dr. Th. Ottmann Summer Semester 2006.
Models of Parallel Computation Advanced Algorithms & Data Structures Lecture Theme 12 Prof. Dr. Th. Ottmann Summer Semester 2006.
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.
Fall 2008Paradigms for Parallel Algorithms1 Paradigms for Parallel Algorithms.
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.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
1 PRAM Algorithms Sums Prefix Sums by Doubling List Ranking.
Data Structures and Algorithms Searching Algorithms M. B. Fayek CUFE 2006.
Lecture 3: Parallel Algorithm Design
Unit –VIII PRAM Algorithms.
Presentation transcript:

Parallel List Ranking Advanced Algorithms & Data Structures Lecture Theme 17 Prof. Dr. Th. Ottmann Summer Semester 2006

2 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.

3 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.

4 Sequential list ranking algorithm 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.

5 A simple parallel 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

6 Initialization phase of the 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).

7 Iteration phase 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

8 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. Exercise : Modify the algorithm to run on the EREW PRAM with the same time and processor complexities.

9 Discussion of the 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. 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.

10 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. 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.

11 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 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.

12 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. 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.

13 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. 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

14 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. 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.

15 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. 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.

16 Preserving the information 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.

17 Preserving the information

18 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 )

19 Preserving the information The predecessor and successor pointers are updated The ranks of nodes which are immediately before a removed node are updated.

20 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.

21 Putting back a node A removed node can be reinserted in O (1) time

22 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. 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.