Assignment 2
2022
Unique No.: 656913
Due date: 18 July 2022
,Preview…
Question 1
(based on 6.8, p.305; 6.12, p.308) [12]
(Ex0 6.8, p.305): The following program example can be used to sum the array values
of size N
elements in parallel on a system containing N computing cores (there is a separate
processor for
each array element):
For j=1 to log_2(N){
For k=1 to N {
If ((k+1) % pow (2, j) == 0) {
Values[k] + = values[k – pow(2, (j-1))]
}
}
}
This has the effect of summing the elements in the array as a series of partial sums as
shown in
(Figure 6.16, P. 307). After the code has executed, the sums of all elements in the
array is stored
in the last array location. Are there any race conditions in the above code example? If
so, identify
where they occur and illustrate with an example. If not, demonstrate why this
algorithm is free from
race conditions. (6)
Figure 6.16,
, . …continued