Newest Viewed Downloaded

Sequential Quicksort17 4 22 11 63 65 14 Recursively apply quicksort to high list

Parallel Programming in C with MPI and OpenMP Michael J. Quinn

Chapter 14 Sorting

Outline

Sorting problem Sequential quicksort Parallel quicksort Hyperquicksort Parallel sorting by regular sampling

Sorting Problem

Permute: unordered sequence  ordered sequence Typically key (value being sorted) is part of record with additional values (satellite data) Most parallel sorts designed for theoretical parallel models: not practical Our focus: internal sorts based on comparison of keys

Sequential Quicksort

17 14 65 4 22 63 11 Unordered list of values

Sequential Quicksort

17 14 65 4 22 63 11 Choose pivot value

Sequential Quicksort

17 14 65 4 22 63 11 Low list ( 17) High list (> 17)

Sequential Quicksort

17 4 65 11 22 63 14 Recursively apply quicksort to low list

Sequential Quicksort

17 4 22 11 63 65 14 Recursively apply quicksort to high list

Sequential Quicksort

17 4 22 11 63 65 14 Sorted list of values

Attributes of Sequential Quicksort

Average-case time complexity: (n log n) Worst-case time complexity: (n2) Occurs when low, high lists maximally unbalanced at every partitioning step Can make worst-case less probable by using sampling to choose pivot value Example: “Median of 3” technique

Quicksort Good Starting Point for Parallel Algorithm

Speed Generally recognized as fastest sort in average case Preferable to base parallel algorithm on fastest sequential algorithm Natural concurrency Recursive sorts of low, high lists can be done in parallel

Definitions of “Sorted”

Definition 1: Sorted list held in memory of a single processor Definition 2: Portion of list in every processor’s memory is sorted Value of last element on Pi’s list is less than or equal to value of first element on Pi+1’s list We adopt Definition 2: Allows problem size to scale with number of processors

Parallel Quicksort

75, 91, 15, 64, 21, 8, 88, 54 50, 12, 47, 72, 65, 54, 66, 22 83, 66, 67, 0, 70, 98, 99, 82 20, 40, 89, 47, 19, 61, 86, 85 P0 P1 P2 P3

Parallel Quicksort

75, 91, 15, 64, 21, 8, 88, 54 50, 12, 47, 72, 65, 54, 66, 22 83, 66, 67, 0, 70, 98, 99, 82 20, 40, 89, 47, 19, 61, 86, 85 P0 P1 P2 P3 Process P0 chooses and broadcasts randomly chosen pivot value

Parallel Quicksort

75, 91, 15, 64, 21, 8, 88, 54 50, 12, 47, 72, 65, 54, 66, 22 83, 66, 67, 0, 70, 98, 99, 82 20, 40, 89, 47, 19, 61, 86, 85 P0 P1 P2 P3 Exchange “lower half” and “upper half” values”

Parallel Quicksort

75, 15, 64, 21, 8, 54, 66, 67, 0, 70 50, 12, 47, 72, 65, 54, 66, 22, 20, 40, 47, 19, 61 83, 98, 99, 82, 91, 88 89, 86, 85 P0 P1 P2 P3 After exchange step Lower “half” Upper “half”

Parallel Quicksort

75, 15, 64, 21, 8, 54, 66, 67, 0, 70 50, 12, 47, 72, 65, 54, 66, 22, 20, 40, 47, 19, 61 83, 98, 99, 82, 91, 88 89, 86, 85 P0 P1 P2 P3 Processes P0 and P2 choose and broadcast randomly chosen pivots Lower “half” Upper “half”

Parallel Quicksort

75, 15, 64, 21, 8, 54, 66, 67, 0, 70 50, 12, 47, 72, 65, 54, 66, 22, 20, 40, 47, 19, 61 83, 98, 99, 82, 91, 88 89, 86, 85 P0 P1 P2 P3 Exchange values Lower “half” Upper “half”

Parallel Quicksort

15, 21, 8, 0, 12, 20, 19 50, 47, 72, 65, 54, 66, 22, 40, 47, 61, 75, 64, 54, 66, 67, 70 83, 82, 91, 88, 89, 86, 85 98, 99 P0 P1 P2 P3 Exchange values Lower “half” of lower “half” Lower “half” of upper “half” Upper “half” of lower “half” Upper “half” of upper “half”

Showing 1 - 20 of 50 items Details

Name: 
Chapter14
Author: 
Michael J. Quinn
Company: 
Oregon State University
Description: 
Sequential Quicksort17 4 22 11 63 65 14 Recursively apply quicksort to high list
Tags: 
quicksort | log | parallel | process | half | values | list | algorithm
Created: 
12/21/2001 12:01:37 AM
Slides: 
50
Views: 
0
Downloads: 
0
Rating: 
0


> Comment



Share this presentation
|

Comments

Share this presentation:

|
Sitemap