4
Thanks to: Tejinder Kaur (35, MCS '09)  Solving a problem on multiple processors.  S(n) is sequential time to solve a problem.  T(n,p) is the parallel time to solve a problem on p processors.  W(n) is the work done by a parallel algorithm. W(n)=T(n,p) p  A parallel algorithm is optimal if the work done is best of known sequential algorithm. i.e. if W(n)=S(n)  Speed up is how much time is gained by using more processors. speed up = S(n)/T(n,p)

5
Thanks to: Tejinder Kaur (35, MCS '09) Take a problem of computing sum of numbers. Sequential time = Θ(n) We have 2 processors p1 and p2 and the numbers are 2,3,4,5,1,11,13,10,7,8 Initially all the numbers are with p1 and it sends half of them to p2. Both p1 and p2 compute sums and send the sums s1 and s2 to each other. So both have the final sum. p1 p2 2,3,4,5,1 11,13,10,7,8 (s1+s2) (s1+s2) Communication time= Θ(1) Computation time= Θ(n/2) T(n,2)= Θ(n/2) W(n)= n/2 2 =n Hence this algorithm is optimal. Speed up = n/ n = 2 2

7
Thanks to: Tejinder Kaur (35, MCS '09) SHARED MEMORY MODEL  All the processors are reading and writing to the same memory.  There is no communication between them.  Can not write at same time but can read at same time. Shared memory Shared memory p1 p2 p3 pn

8
Thanks to: Tejinder Kaur (35, MCS '09) Models for concurrency in shared memory model EREW(Exclusive read exclusive write) CREW(Concurrent read exclusive write) CRCW(Concurrent read Concurrent Write) The weakest is EREW. CREW is Better than EREW but weaker than CRCW. If we go from CRCW to CREW there is a slowdown of factor of log(n).

9
CRCW Model wrt searching Made By : Deepika Kamboj ( Roll No.7, MSc '11 ) CRCW Common All processors should write same value Arbitrary Processors can write different values but Any one value gets written Priority Processors can write different values but the processor given the highest priority gets to write its value

27
Thanks to: Tejinder Kaur (35, MCS '09) Height of this tree is log n. Each step is taking constant time. Hence this algo takes O(log n) time. W(n)= n log n= nlogn. Speed up=n/log n. This algorithm is not optimal as half of the processors are idle in first step and number of idle processors is increasing in further steps. What if we use n/log n processors.

28
Thanks to: Tejinder Kaur (35, MCS '09) As the number of processors is n/log n.Each processor will get log n values. s1 s2 sm Take m=n/log n Each processor has n/log n values so sm sums will be generated.

29
Thanks to: Tejinder Kaur (35, MCS '09) The height is log m. So it will take log m time <= log n So T(n,p) <= 2logn = O(log n) W(n)= n=O(S(n)) As sequential time is O(n). Hence this algorithm is optimal.