





































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






































2
4
5
7
8
10 procedure bubbleSort( A : vector) n := length( A ) do swapped := false n := n - 1 for each i in 0 to n - 1 if A[i] > A[i + 1] swap(A[i], A[i + 1]); swapped := true while (swapped) end procedure procedure oddEvenSort( A : vector) n := length( A ) do swapped := false for each i in 0 to n - 1 by 2 in parallel if A[i] > A[i + 1] swap(A[i], A[i + 1]); swapped := true for each i in 1 to n - 1 by 2 in parallel if A[i] > A[i + 1] swap(A[i], A[i + 1]); swapped := true while (swapped) end procedure
“parallel bubble sort”
11
13
- Fraction of time a processor performs useful work
14
16
- Cost of parallel system =^ pTP —sum of the work time for each processor — AKA work or processor-time product - Parallel system is^ cost-optimal^ if —O(solving a problem on a parallel computer) = O(serial) - Since^ E^ =^ TS /^ pTP , for cost optimal systems^ E^ =^ O (1)
17
Problem revisited: add n numbers
- Is it cost-optimal on a parallel system using^ n^ PEs? - As before,^ TP =^ log^ n^ for^ p^ =^ n - Cost of this system =^ p^ TP =^ Θ( n^ log^ n ) - Serial runtime =^ Θ( n ) - Algorithm is not cost optimal - E =^ Θ (n / (n log n)) =^ Θ (1 / log n)
19
20