Input. A (large) array float[] values
Task. Modify values
so that the values are increasing.
Scale. values.length = 1_048_576
($= 2^{20}$)
Baseline. Arrays.sort(values)
include java.util.Arrays
General Strategy:
Question 1. How to divide sorting problem?
Question 2. How might parallelism help?
Idea. (merge sort)
left
and right
sub-arraysleft
and right
left
and rightExample. Sort [4, 2, 3, 1]
Question. What can be performed in parallel?
left
and right
sub-arraysleft
and right
left
and rightIdea. (quick sort)
pivot
from arrayleft
and right
sub-arrays
left
are <= pivot
, values in right
are >
left
and right
Example. Sort [4, 2, 3, 1]
Question. What can be performed in parallel?
pivot
from arrayleft
and right
sub-arrays
left
are <= pivot
, values in right
are >
left
and right
Merge sort: split, sub-sort, merge
Quick sort: partition, sort
Merge Sort?
Quick Sort?
Question. How to merge
two sorted arrays?
Question. Can we improve performance of merge
operation with SIMD instructions?
Question. How to partition
an array given a pivot
?
Question. Can we improve performance of partition
with SIMD instructions?