Parallel Computing Spring 2010

Slides:



Advertisements
Similar presentations
Parallel Sorting Sathish Vadhiyar. Sorting  Sorting n keys over p processors  Sort and move the keys to the appropriate processor so that every key.
Advertisements

1 Parallel Parentheses Matching Plus Some Applications.
Chapter 9: Searching, Sorting, and Algorithm Analysis
CS4413 Divide-and-Conquer
D1: Quick Sort. The quick sort is an algorithm that sorts data into a specified order. For a quick sort, select the data item in the middle of the list.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Sorting.
Parallel Sorting Algorithms Comparison Sorts if (A>B) { temp=A; A=B; B=temp; } Potential Speed-up –Optimal Comparison Sort: O(N lg N) –Optimal Parallel.
Advanced Topics in Algorithms and Data Structures Page 1 Parallel merging through partitioning The partitioning strategy consists of: Breaking up the given.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
1 Tuesday, November 14, 2006 “UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever.
Chapter 10 in textbook. Sorting Algorithms
Sorting Algorithms CS 524 – High-Performance Computing.
1 Friday, November 17, 2006 “In the confrontation between the stream and the rock, the stream always wins, not through strength but by perseverance.” -H.
Algorithms and Applications
1 Lecture 11 Sorting Parallel Computing Fall 2008.
Sorting Algorithms: Topic Overview
Sorting Algorithms Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar To accompany the text ``Introduction to Parallel Computing'', Addison Wesley,
CS 584. Sorting n One of the most common operations n Definition: –Arrange an unordered collection of elements into a monotonically increasing or decreasing.
Algorithms for Sorting Things. Why do we need to sort things? Internal Telephone Directory –sorted by department then by name My local video store holds.
CSCI-455/552 Introduction to High Performance Computing Lecture 22.
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.
1 Sorting Algorithms - Rearranging a list of numbers into increasing (strictly non-decreasing) order. ITCS4145/5145, Parallel Programming B. Wilkinson.
Lecture 12: Parallel Sorting Shantanu Dutt ECE Dept. UIC.
Chapter 6 Parallel Sorting Algorithm Sorting Parallel Sorting Bubble Sort Odd-Even (Transposition) Sort Parallel Odd-Even Transposition Sort Related Functions.
1 Parallel Sorting Algorithms. 2 Potential Speedup O(nlogn) optimal sequential sorting algorithm Best we can expect based upon a sequential sorting algorithm.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Outline  introduction  Sorting Networks  Bubble Sort and its Variants 2.
CS453 Lecture 3.  A sequential algorithm is evaluated by its runtime (in general, asymptotic runtime as a function of input size).  The asymptotic runtime.
New Mexico Computer Science For All Sorting Algorithms Maureen Psaila-Dombrowski.
1. 2 Sorting Algorithms - rearranging a list of numbers into increasing (strictly nondecreasing) order.
Review 1 Selection Sort Selection Sort Algorithm Time Complexity Best case Average case Worst case Examples.
1 Searching and Sorting Searching algorithms with simple arrays Sorting algorithms with simple arrays –Selection Sort –Insertion Sort –Bubble Sort –Quick.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Chapter 9 Sorting 1. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step.
Chapter 9 Sorting. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step is.
Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar
1 Ch.19 Divide and Conquer. 2 BIRD’S-EYE VIEW Divide and conquer algorithms Decompose a problem instance into several smaller independent instances May.
Data Structures and Algorithms in Parallel Computing Lecture 8.
Parallel Programming - Sorting David Monismith CS599 Notes are primarily based upon Introduction to Parallel Programming, Second Edition by Grama, Gupta,
Unit-8 Sorting Algorithms Prepared By:-H.M.PATEL.
 2006 Pearson Education, Inc. All rights reserved. 1 Searching and Sorting.
CSCI-455/552 Introduction to High Performance Computing Lecture 21.
Sorting: Parallel Compare Exchange Operation A parallel compare-exchange operation. Processes P i and P j send their elements to each other. Process P.
Sorting  Selection Sort  Bubble Sort  Insertion Sort  Merge Sort (chap. 14)  Quick Sort (chap. 14)  Heap Sort (chap. 9)
Find!! # of comparison and exchange will be represented by Big-O notation!
Divide and Conquer Algorithms Sathish Vadhiyar. Introduction  One of the important parallel algorithm models  The idea is to decompose the problem into.
Searching and Sorting Searching algorithms with simple arrays
Recursion COMP T1 #6.
Sort Algorithm.
Sorting Mr. Jacobs.
Lecture 3: Parallel Algorithm Design
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Odd-Even Sort Implementation Dr. Xiao Qin.
Introduction to Search Algorithms
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Parallel Odd-Even Sort Algorithm Dr. Xiao.
Sorting Quiz questions
Parallel Sorting Algorithms
Algorithm Design Methods
Lecture 22: Parallel Algorithms
Sorting Chapter 13 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved
Quicksort and Mergesort
Sorting Algorithms Ellysa N. Kosinaya.
Pipelined Computations
Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, 2012 slides5.ppt Oct 24, 2013.
Parallel Sorting Algorithms
Parallel Sorting Algorithms
Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, 2012 slides5.ppt March 20, 2014.
Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson slides5.ppt August 17, 2014.
Analysis of Algorithms
Sorting Algorithms - Rearranging a list of numbers into increasing (strictly non-decreasing) order. Sorting number is important in applications as it can.
Parallel Sorting Algorithms
Presentation transcript:

Parallel Computing Spring 2010 Sorting Parallel Computing Spring 2010

Sorting Algorithm Rearranging a list of numbers into increasing (strictly nondecreasing) order.

Potential Speedup O(nlogn) optimal for any sequential sorting algorithm without using special properties of the numbers. Best we can expect based upon a sequential sorting algorithm using n processors is Optimal parallel time complexity = O(n logn)/n= O(logn) Has been obtained but the constant hidden in the order notation extremely large.

Compare-and-Exchange Sorting Algorithms: Compare and Exchange Form the basis of several, if not most, classical sequential sorting algorithms. Two numbers, say A and B, are compared. If A > B, A and B are exchanged, i.e.: if (A > B) { temp = A; A = B; B = temp; }

Message Passing Method For P1 to send A to P2 and P2 to send B to P1. Then both processes perform compare operations. P1 keeps the larger of A and B and P2 keeps the smaller of A and B:

Merging Two Sublists

Bubble Sort First, largest number moved to the end of list by a series ofcompares and exchanges, starting at the opposite end. Actions repeated with subsequent numbers, stopping just before the previously positioned number. In this way, the larger numbers move (“bubble”) toward one end,

Bubble Sort

Time Complexity Number of compare and exchange operations Indicates a time complexity of O(n^2) given that a single compare-and-exchange operation has a constant complexity, O(1).

Parallel Bubble Sort Iteration could start before previous iteration finished if doesnot overtake previous bubbling action:

Odd-Even (Transposition) Sort Variation of bubble sort. Operates in two alternating phases, even phase and odd phase. Even phase Even-numbered processes exchange numbers with their right neighbor. Odd phase Odd-numbered processes exchange numbers with their right neighbor.

Sequential Odd-Even Transposition Sort

Parallel Odd-Even Transposition Sort Sorting eight numbers

Parallel Odd-Even Transposition Sort Consider the one item per processor case. There are n iterations; in each iteration, each processor does one compare-exchange –which can all be done in parallel. The parallel run time of this formulation is Θ(n). This is cost optimal with respect to the base serial algorithm but not the optimal serial algorithm.

Parallel Odd-Even Transposition Sort

Parallel Odd-Even Transposition Sort Consider a block of n/p elements per processor. The first step is a local sort. In each subsequent step, the compare exchange operation is replaced by the compare split operation. There are p phases with each phase performing Θ(n/p) compares and Θ(n/p) communication. The parallel run time of the formulation is The parallel formulation is cost-optimal for p= O(logn).

End Thank you!