question archive An application is calculating the number of occurrences of a certain word in a very large number of documents

An application is calculating the number of occurrences of a certain word in a very large number of documents

Subject:Computer SciencePrice: Bought3

An application is calculating the number of occurrences of a certain word in a very large number of documents. A very large number of processors divided the work, searching the different documents. They created a huge array—word_count—of 32-bit integers, every element of which is the number of times the word occurred in some document. In a second phase, the computation is moved to a small SMP server with four processors. Each processor sums up approximately ¼ of the array elements. Later, one processor calculates the total sum.

for (int p= 0; p<=3; p++) // Each iteration of is executed on a separate processor.

{

sum [p] = 0;

for (int i= 0; i&lt;n/4; i++) // n is size of word_count and is divisible by 4

sum[p] = sum[p] + word_count[p+4*i];

}

total_sum = sum[0] +sum[1]+sum[2]+sum[3] //executed only on processor.

a. Assuming each processor has a 32-byte L1 data cache. Identify the cache line sharing (true or

false) that the code exhibits.

b. Rewrite the code to reduce the number of misses to elements of the array word_count.

c. Identify a manual fix you can make to the code to rid it of any false sharing.

 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE