parallel sorting algorithms

Upload: shyam536

Post on 17-Oct-2015

35 views

Category:

Documents


4 download

DESCRIPTION

This presentation covers parallel sorting algorithms such as Odd-Even Transposition sort, Rank sort and Bitonic sort.

TRANSCRIPT

  • PARALLEL SORTING ALGORITHMS ON MULTI-CORE PROCESSOR

    Ankit jain

  • Contents*IntroductionParallelismTypes of parallelismSorting techniquesExample (Analysis)ConclusionReferences

  • Why do we need sorting ?Sorting makes it possible to search a particular data element in a collection quickly by applying the binary search technique.

    Sorting is the most important operations for many commercial applications, especially database management systems.

    *

  • Sequential sorting algorithms*Bubble sortInsertion sortSelection sort

    Merge sortHeap sortQuick sortO(n2)O(nlog(n))

  • Parallelism *Parallelism is a concept of computing task simultaneously at a time.Types of parallelismInstruction level parallelismData level parallelismTask level parallelism

  • Instruction level parallelism*Instruction-level parallelism (ILP) is a measure of how many of the operations in a computer program can be performed simultaneously. The potential overlap among instructions is called instruction level parallelismConsider the following program: 1. e = a + b 2. f = c + d 3. m = e * fint a=2,b=3,c=4,d=7e=a+bf=c+dm=e*f

  • Data level parallelism:*It focuses on distributing the data across different parallel computing nodes.The program below expressed in pseudo code. if CPU = "a lower_limit := 1 upper_limit := round(d.length/2) else if CPU = "b" lower_limit := round(d.length/2) + 1 upper_limit := d.length for i from lower_limit to upper_limit by 1 foo(d[i])

  • Task level parallelism:*Task level parallelism focuses on distributing execution processes (threads) across different parallel computing nodes. In a multiprocessor system, task parallelism is achieved when each processor executes a different thread (or process) on the same or different dataThe pseudo code below illustrates task parallelism: if CPU="a" then do task "A else if CPU="b" then do task "B end if... end program

  • Parallel sorting algorithm*Odd Even transposition sortRank sortBitonic sort

  • Odd-Even transposition sort*Odd even transposition algorithm is a parallel sorting which is a development of the sequential bubble sort algorithm.It is designed for linear array computer networks.The algorithm performs n/2 iterations each of which has 2 phases phase1: odd-even exchange phase2: even-odd exchange

  • *Odd-Even Transposition Sort example(p=n)time complexity: Tpar = (n) (for P=n) P1 P2 P3 P4 P5 P6 P7 P8

  • Odd Even sort algorithm*for j=1...[ N/2] do sequentially begin for i=1,3,..,2[ N/2]-1 do in_parallel if xi > xi+1 then swap(xi,xi+1); for i=2,4,..,2[ (N-1)/2] do in_parallel if xi > xi+1 then swap(xi,xi+1); end

  • Parallel Rank sort*Number of elements that are smaller than each selected element is counted. This count provides the position of the selected number, its rank in the sorted list. First a[0] is read and compared with each of the other numbers, a[1] a[n-1], recording the number of elements less than a[0].The number a[0] is copied into the final sorted list b[0] b[n-1], at location b[rank]. Actions repeated with the other numbers.Overall sequential time complexity of rank sort: Tseq = O(n2)

  • Parallel rank sort example (p=n)*5 1 3 7 9p2p3p4p5p1Rank=2Rank=0Rank=1Rank=3Rank=41 3 5 7 9Unsorted list Sorted list

  • Parallel Rank Sort (P=n)*One number is assigned to each processor . Pi finds the final index of a[i] in O(n) steps. forall (i = 0; i < n; i++) { /* for each no. in parallel*/ rank = 0; for (j = 0; j < n; j++) /* count number less than it */ if (a[i] > a[j]) rank++; b[rank] = a[i]; /* copy no. into correct place */}Parallel time complexity, O(n), as good as any sorting algorithm so far. time complexity: Tpar = O(n) (for P=n)

  • Bitonic sorting*A bitonic sequence is composed of two subsequences, one is increasing and the other decreasing.example: 2 5 7 12 32 26 14 9 increasing decreasing

  • Bitonic sort example*257123226149Step 1: 257932261412Step 2: 257914123226257912142632Step 3: Sorted :

  • *19161542319818161942159311881516194231189815169831181942161542191831989815161918314289151618193142Step 1:Step 4:Step 5:Step 6:Step 3:Step 2:Unsorted list -> bitonic sequence -> sorted list

    Ankit jain

  • Bitonic sort example*94375281943182574319278531948752183745921432132485795789abcd

  • Number of steps (P=n)*The solution of this recurrence equation is T(n) =log(n)+log(n)-1+log(n)-2+...+1 =log(n)(log(n)+1)/2 =[(log2 n)+(log(n)]/2 time complexity = O(log2 n)

  • Conclusion *By using the parallelism time complexity for sorting has been reduced from O(n2) to O(log2n).From the above three methods described bitonic sort method is more appropriate because time complexity of bitonic sort is less compare to other two methods. Parallelism is not used in most of the sorting problems because it requires high processing speeds and high power consumption.

  • References *Analysis of Fast Parallel Sorting Algorithms for GPU Architectures by fiaz.khan ,omar.khan,bartolomeo.montrucchio.Minimizing Communication in the Bitonic Sort by Jae-Dong Lee and Kenneth E. Batcher.fast parallel sorting algorithms on gpus byBilal Jan, Bartolomeo Montrucchio, Carlo Ragusa, Fiaz Gul Khan and Omar Khan

    *****