implementation of parallel radix sort using mpi · what is radix sort? it is a non-comparison based...
TRANSCRIPT
![Page 1: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/1.jpg)
Implementation of Parallel Radix Sort using MPI
CSE 633: Parallel Algorithms Dr. Russ Miller
![Page 2: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/2.jpg)
What is Radix Sort?It is a non-comparison based sort, best suited for sorting Integers
Comes under stable sorting algorithm
!Two types of radix sort, LSD and MSD
Uses counting sort
![Page 3: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/3.jpg)
An ExampleLet n be the number of integers If i is the largest integer, let k be the number of digits in i.
For integers from 1 to 9999, i = 9999 and k = 4
Example set of integers: !10, 5, 6, 24, 14, 3 !n = 6, i = 24, k = 2
![Page 4: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/4.jpg)
Example (Cont.)Input: 10, 05, 06, 24, 14, 03
1. Sort by units place !10, 03, 24, 14, 05, 06
Note: If two numbers are same, preserve the initial order. (Stable sort)
2. Sort by tens place !03, 05, 06, 10, 14, 24
![Page 5: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/5.jpg)
AnalysisIt takes O(n) time to sort by units place It takes another O(n) to sort by tens place
Total Sorting time: O(kn)!In the example k = 2, therefore running time is O(kn)
What if i (Largest integer) is unknown? Do an iteration over the data to find the largest Integer
![Page 6: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/6.jpg)
Parallel ImplementationStep 1: If the data is initially present in a single processor, distribute it to all other processors
Step 2: Convert the numbers to base 2 (Binary)
In base 10, we proceeded from Least Significant Digit to Most Significant Digit
For parallel implementation we choose a group of g bits
![Page 7: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/7.jpg)
Parallel Implementation (Step 2)If p = Number of processors !Then we choose g such that, !
2g = p!!
g = log2 P
For example, !if p = 4, then g = 2. We take 2 bits at a time !00, 01, 10, 11
![Page 8: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/8.jpg)
Parallel ImplementationStep 3: Do an interprocess communication such that !All numbers ending in bits 00 are sent to Processor P0 All numbers ending in bits 01 are sent to Processor P1 and so on…
Step 4: Perform counting sort locally on these processors
Step 5: Calculate the global prefix-sum of the number of integers in each processor
Step 6: Using the index calculated in previous step put back the integers in a temporary array and this serves as input to next iteration.
![Page 9: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/9.jpg)
Charts
![Page 10: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/10.jpg)
100 1000 10000 100000 1000000 10000000
Serial: Run time
![Page 11: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/11.jpg)
100 1000 10,000 100,000 1,000,000 10,000,000
Serial: Speed of Processing
Number of Integers————————Run Time
![Page 12: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/12.jpg)
Tim
e in
milli
sec
onds
0.00
40.00
80.00
120.00
160.00
200.00
4 8 16 32 64 128 256
1000 10,000 100,000 1,000,000 10,000,000
Parallel: Run Time
Number of Processors
![Page 13: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/13.jpg)
Num
ber o
f Int
eger
s / R
un T
ime
0.00
18,000,000.00
36,000,000.00
54,000,000.00
72,000,000.00
90,000,000.00
4 8 16 32 64 128 256
1000 10000 100000 1000000 10000000
Parallel: Speed of Processing
Number of Processors
![Page 14: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/14.jpg)
1,000 10,000 100,000 1,000,000 10,000,000
Parallel: Speed of Processing
![Page 15: Implementation of Parallel Radix Sort using MPI · What is Radix Sort? It is a non-comparison based sort, best suited for sorting Integers Comes under stable sorting algorithm! Two](https://reader033.vdocuments.us/reader033/viewer/2022052519/5f16a66fc16c215071428938/html5/thumbnails/15.jpg)
Thank You!