parallel sortingliacs.leidenuniv.nl/~wijshoffhag/ppi2017_2018/lecture_10.pdf · (sequential)...
TRANSCRIPT
![Page 1: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/1.jpg)
ParallelSorting
![Page 2: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/2.jpg)
Ajungle
•
![Page 3: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/3.jpg)
Illustration
https://www.youtube.com/watch?v=kPRA0W1kECg
![Page 4: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/4.jpg)
(Sequential)Sorting
• BubbleSort,InsertionSort– O(n2)
• MergeSort,HeapSort,QuickSort– O(nlogn)– QuickSort bestonaverage
• Optimal Parallel Timecomplexity– O(nlogn)/P– IfP=NthenO(logn)
![Page 5: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/5.jpg)
InsertionSortInsertion_Sort (A)
for i from 1 to |A| - 1j = iwhile j > 0 and A[j-1] > A[j]
swap A[j] and A[j-1]j = j – 1
Return ( A )
Inherentlysequentialsohardtoparallelize!!!!è Onlythroughpipelining canspeedupberealized
![Page 6: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/6.jpg)
PipelinedInsertionSort•
Tpipelined =2n,withnprocessors,somaximalspeedup=n/4– 3/4(wortcasesequentialtime=(n-1)(n-2)/2=n2/2-3n/2+2/2)
![Page 7: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/7.jpg)
ParallelMergeSortMerge_Sort (A)
n = |A|halfway = floor(n/2)
DOINPARALLELMerge_Sort (A[1]… A[halfway])Merge_Sort (A[halfway+1]… A[n])
j = 1; current = 1for i from 1 to halfway
while j ≤ n-halfway and A[halfway + j] < A[i]X[current] = A[halfway + j]j = j + 1; current = current+1
X[current] = A[i]current = current+1
Return ( X )
halfway halfway + j ni
A
![Page 8: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/8.jpg)
Inapicture
•
![Page 9: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/9.jpg)
NotesMergeSort
• Collectssortedlistontooneprocessor,mergingasitemscometogether
• Mapswelltotree structure,sortinglocallyonleaves,thenmergingupthetree
• Asitemsapproachrootoftree,processorsaredropped,limitingparallelism
• O(n),ifP=n(1+2+4+…+n/2+n)=n(1+1/2+1/4…)=n.2
![Page 10: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/10.jpg)
ParallelQuickSortQuickSort (A)
if |A| == 1 then return Ai = rand_int (|A|)p = A[i]DOINPARALLEL
L = QuickSort({a A|a < p})E = {a A|a = p}G = QuickSort({a A|a > p})
Return ( L || E || G )
∈
∈
∈
∈
![Page 11: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/11.jpg)
IfweassumethatthepivotsarechosensuchthatLandGareaboutequalinsize,then
Sequential:T(n)=2T(n/2)+O(n)=O(nlogn)Infactitcanbeproventhatthisalwaysholds!
Forparallelexecution thechoiceofi iscrucialforloadbalance.Evenmoreimportantlywewouldliketochoosemultiplepivots(p-1)atthesametime,sothateachtimewegetppartitions whichcanbeexecutedinparallel.
![Page 12: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/12.jpg)
Ppartitions• Foragivenp(numberofpivots)ands(oversamplingrate),firstselectatrandomp*scandidatepivots
for i from 1 to p*s
Cand[i] = rand_int (|A|)
• Sort thelistofcandidatepivots:Cand[i]• ChooseCand[s],Cand[2*s]…Cand[(p-1)*s]Findagoodvaluefortheoversamplingrate:s>1,
è sshouldnotleadtoverylongsortingtimes
![Page 13: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/13.jpg)
ParallelRadixSortInsteadofcomparingvalues:COMPAREDIGITS
Radix_Sort (A, b) # Assumebinaryrepresentationsofkeysfor i from 0 to b-1
FLAGS = { (a>>i) mod 2 | a A } NOTFLAGS = { 1-FLAGS[a] | a A }R_0 = SCAN (NOTFLAGS)s_0 = SUM (NOTFLAGS)R_1 = SCAN (FLAGS)R = {if FLAGS[j] == 0
then R_0[j]else R_1[j] + s_0| j [0…|A|-1}
A = A sorted by RReturn ( A )
∈∈
∈
(a>>i) mod 2: rightshift i times,soe.g.01101>>2 mod2 =00011 mod 2 = 1
So(a>>i) mod 2 equalsthe(i+1)th rightmostbitofa
![Page 14: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/14.jpg)
LSD/MSDRadixSort
Insteadof(a>>i) mod 2
onecanalsoimplementsRadixSortwith:(a<<i) div 2^(b-1)
ThefirstimplementationiscalledleastsignificantdigitRadixSortorLSDRadixSortThelatteronisMSDRadixSort
![Page 15: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/15.jpg)
NotesRadixSort
ØSequentialtimecomplexity:T(n)=O(b.n),
biterations,eachiterationO(n)ØNotethatb≈logn,soatotalofO(nlogn)ØInsteadofsingledigitsablockofrdigitscanbetakeneachtime,resultinginb/r iterations
![Page 16: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/16.jpg)
Illustration(LSDRadixSort)
•
![Page 17: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/17.jpg)
SortingofeachselecteddigitinRadixSort,withPrefixSumBasedSorting
Eachelementi oftheprefixsumarrayhastheSUMofallelementswhichindexissmallerthani
![Page 18: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/18.jpg)
Whatistherelationshipwithsorting?
•
ØAllbitswhichareequalto0areflaggedwitha1ØComputePrefixSumofthisflagarrayØ Storeallflagged(1)entriesofx[k]inthelocationindicatedbytheprefixsum
![Page 19: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/19.jpg)
Secondstage
•
ØAllbitswhichareequalto1 areflaggedwitha1ØComputePrefixSumofthisflagarrayØ Storeallflagged(1)entriesofx[k]inthenextlocationsindicatedbytheprefixsum
![Page 20: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/20.jpg)
Whataboutparallelexecution?
• Computationallythesortingalgorithmisreducedtocomputingtheprefixsumarraysforeachbitranking.
• However,computingtheseprefixsumarraysseemstobeinherentlysequential.Ornot?
![Page 21: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/21.jpg)
ParallelExecutionofPrefixSums
Prefix_Sum (X) # X a n-bit array
for index from 0 to log nDOINPARALLELforallkif k >= 2^index thenX[k] = X[k]+X[k-2^index]
X >> 1 #Shift all entries to the rightReturn ( X )
![Page 22: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/22.jpg)
IllustrationofparallelPrefixSums
•
![Page 23: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/23.jpg)
ImprovingCachePerformanceØ Theparallelprefixsumalgorithmrequiresthewholearraytobe
fetchedateachiterationØ BadcacheperformanceØ ThroughTilingTechniquestheXarraycanbecutintoslices(tiles)Ø Onceeverynumberofiterationsre-tile!!Ø ACUDAimplementationoftheoverallalg.canbefoundon
https://github.com/debdattabasu/amp-radix-sort
2index
X
P2
P1
P3
![Page 24: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/24.jpg)
Bitonic Sorting
Basedonbitonic sequences:
A[1],A[2],….,A[n-1],A[n]isbitonic,iffthereisaj andk suchthat• A[1]…A[j]ismonotonicincreasing,• A[j]…A[k]ismonotonicdecreasing,• A[k]…A[n]A[1]!!ismonotonicincreasing
ORviseversa
![Page 25: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/25.jpg)
A“better”definitionofBitonic Sequence
Abitonic sequence isasequencewithA[1]<=A[2]<=….<=A[k]>=…>= A[n-1]>=A[n]
forsomek(1<=k<=n),oracircularshiftofsuchasequence.
![Page 26: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/26.jpg)
Inapicture
Bitonic:
NotBitonic
Ifrotated:TwoPeaks
![Page 27: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/27.jpg)
A[1]>=A[2]>=….>=A[k]<=…<=A[n-1]<=A[n]leadstothesamedefinition
![Page 28: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/28.jpg)
Bitonic “Merge”Bitonic_Merge (A) # A is a bitonic sequence
n = |A|if n == 1 then return Ahalf_n = floor(n/2)for i from 1 to half_n
c[i] = min(A[i],A[i+half_n])d[i] = max(A[i],A[i+half_n])
DOINPARALLELBitonic_Merge (c[1]…c[half_n])Bitonic_Merge (d[1]…d[half_n])
Return ( )
![Page 29: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/29.jpg)
NotesBitonic Merge
• Eachc andd sequenceisabitonic sequenceagain
• Foralli: c[i] <= d[i]• Attheendwesortedbitonic sequencesoflength1,henceasortedsequence
![Page 30: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/30.jpg)
Bitonic Mergealwaysyieldsbitonic sequences
•
![Page 31: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/31.jpg)
Bitonic MergeNetwork•
![Page 32: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/32.jpg)
Bitonic MergeNetwork(2)•
![Page 33: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/33.jpg)
Bitonic MergeNetwork(3)
•
![Page 34: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/34.jpg)
ParallelBitonic Sort
Bitonic_Sort (A)
n = |A|
if n == 1 then return Afor i from 0 to log(n)
DOINPARALLELforallk=m.2^i,k<nBitonic_Merge (A[k]…A[k+2^i-1])*
Return ( )
*Foroddvaluesofm,interchangeminandmax
![Page 35: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/35.jpg)
NotesBitonic Sort
• Eachiterationcreateslongerandlongerbitonic sequences
• Inthelastiterationthewholesequenceisbitonic andthefinalbitonic mergecreatesasortedlist
![Page 36: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/36.jpg)
Bitonic SortNetwork
•
four bitonic lists of length 2 constituting 2 bitonic lists of length 4
2 Bitonic Merge Networks
4 Bitonic Merge Networks
![Page 37: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/37.jpg)
Whyalternatingmax/min?NotethatatthestartofeachBitonic MergeNetworkwehavetwoBitonic SequenceswhichconstitutesOneBitonicSequence!!!
Ifoneofthesesequencesis(monotonic)increasingandtheotheris(monotonic)decreasingthenthisisalwaysthecase.Ifbothareincreasingordecreasingthisisnotnecessarilythecase,i.e.
isnotbitonic
![Page 38: Parallel Sortingliacs.leidenuniv.nl/~wijshoffhag/PPI2017_2018/Lecture_10.pdf · (Sequential) Sorting •Bubble Sort, Insertion Sort –O ( n2 ) •Merge Sort, Heap Sort, QuickSort](https://reader034.vdocuments.us/reader034/viewer/2022042712/5f9c92d8f368161c3536b7bd/html5/thumbnails/38.jpg)
NotesBitonic SortNetwork• Assumen=2^k• Thebitonic mergestageshave1,2,3,…,kstepseach,sotimetosortis
T(n) =1+2+…+k=k(k-1)/2=O(k2)=O(log2 n)
• Eachsteprequiresn/2processors,sothetotalnumberofprocessorsisO((n/2) log2 n)
• Thenetworkcanhandledmultiplepipelined listproducingasortedlisteachtimestep