
(This is not a course in distributed algorithm, just trying to give you a glimse into this area)
(As you can see, this is the end of the semester and we don't have time to study parallel and distributed algorithms at length, this is ment to make you aware of a new type of thinking about solving problems).
a_{0}, a_{1}, a_{2}, ...., a_{N1} 

PartialSum[0] = a[0]; for (i = 1; i < N; i++) PartialSum[i] = PartialSum[i1] + a[i]; 
The run time complexity is N
The goal is to compute ALL the partial sums:
(I used array notation a[i] in the figures for a_{i})
What happens is the following:
Resulting state:
What happens is the following:
Resulting state:
What happens is the following:
Resulting state:
OK, how can we formulate this as an compuetr algorithm ?
// k = loop index // k runs: 1, 2, 4, 8, .... etc !!! for (k = 1; k < N; k = 2*k) { // Check if I am a processor that needs to send data if ( i + k < N ) send a[i] to processor (i+k); // Check if I am a processor that needs to receive data if ( i >= k ) { recevive message x; a[i] = a[i] + x; } } 