Question: 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

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 log2(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 1 below. After the code has executed, the sum 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!