SPMD Code After Strip Mining
for k := 1 to n do
if (k-1 = Pindex)
then
Bk[1 : n] = 1B[1:n]
broadcast(Bk[1 : n])
else
receive(Bk[1 : n])
endif
for j = 1 to n do
for i = 1 to nrows do
1C[i,j] = 1C[i,j] + 1A(i,k) ∗ Bk[j]
endfor
endfor
endfor |
Sequential and Parallel Loops
Sequential Loop: The second iteration does not start until the first iteration is complete.
Forall Loop: This is a parallel loop corresponding to an array assignment. Each of the statements is executed completely for all the values of the index variable before the next statement is started.
Forall i= 1, n
S1
S2 
Sm
Endall |
is equivalent to |
S1(1:n)
S2(1:n)

Sm(1:n) |
Dopar Loop: This is a parallel loop corresponding to parallel processors. Each iteration of the loop is executed in parallel by a different processor.
- The code within each iteration executes sequentially
- Initial state seen by each processor is same as the state before the loop
- Any variable update done by a processor can not be seen by any other processor
- If two iteration change the same variable, the result is non-deterministic merge
|