Comparison of Sample Sort and Quick Sort

1 / 9
About This Presentation
Title:

Comparison of Sample Sort and Quick Sort

Description:

Internal sort of n/p elements T((n/p) log(n/p)) Splitter selection T(p) Gather operation to accumulate splitters at a single processor T(p2 log p) ... –

Number of Views:74
Avg rating:3.0/5.0
Slides: 10
Provided by: cise8
Category:

less

Transcript and Presenter's Notes

Title: Comparison of Sample Sort and Quick Sort


1
Comparison of Sample Sort and Quick Sort
  • Hima Bindu Kodali
  • Seemi Sadaf

2
Algorithm for Sample Sort
  • Implemented as a Master-Slave algorithm
  • For each slave process,
  • Sort local array using sequential quick sort
  • Generate splitters and send them to the master
    (Processor 0 in this case)
  • Use the splitters returned by the master to
    compute the number of values to be sent to each
    processor and the displacements array
  • Locally sort the received values using quick sort

3
Sample Sort Contd.
  • For the master process,
  • Sort the p(p-1) splitters using quick sort
  • Select boundary conditions for each processor
  • Broadcast the boundary conditions to all other
    processors

4
Sample Sort Isoefficiency Analysis
  • Internal sort of n/p elements T((n/p) log(n/p))
  • Splitter selection T(p)
  • Gather operation to accumulate splitters at a
    single processor T(p2 log p)
  • Selection of global splitters T(p)
  • Local partitioning of data T(p log(n/p))
  • Global redistribution O(n) O(p logp)
  • Tp T(n/p log n/p) T(p2 log p) T(p log n/p)
    T(n/p) O(p log p)
  • Isoefficiency T(p3 log p)

5
MPI routines used in Sample Sort
  • MPI_Gather
  • MPI_Bcast
  • MPI_Alltoallv
  • MPI_Init
  • MPI_Finalize
  • MPI_Comm_rank
  • MPI_Comm_size
  • MPI_Wtime

6
Pending items
  • Calculating the running time

7
Quick Sort
  • The set of elements is distributed equally among
    all processors
  • Each processor sorts its elements using
    sequential quick sort
  • The Master processor selects a random pivot and
    broadcasts it to all other processors
  • Each processor partitions its elements into two
    sub-arrays S containing elements smaller than
    the pivot and L containing elements larger than
    the pivot
  • The set of processors is partitioned into two
    groups, one that sorts the set of elements lesser
    than the pivot and the other that sorts elements
    greater than the pivot
  • Each processor sends its lesser than and greater
    then arrays to the corresponding processors. This
    partitions the processors into two groups.
  • The algorithm proceeds recursively for each group
  • This process continues until a partition is
    assigned to a single processor
  • Each process then sorts its partition locally

8
Quick Sort Isoefficiency Analysis
  • Pivot selection and broadcast T(log p)
  • Local arrangement of array at each processor
    T(n/p)
  • Determination of positions of elements in the
    globally redistributed array T(log p)
  • Global rearrangement T(n/p)
  • Tp T(n/p log n/p) T(n/p log p) T(log2 p)
  • Isoefficiency T(p log2 p)

9
Pending items
  • Completing global redistribution
  • Calculating running time
  • Comparing results with those of sample sort
Write a Comment
User Comments (0)
About PowerShow.com