Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a) Examine the code given below to compute the average of an array: total 0 for

ID: 3738301 • Letter: A

Question

a) Examine the code given below to compute the average of an array: total 0 for (j=0; j ? k; j++) sub total - 0 /* Nested loops to avoid overflow * sub total + A[j*N j ; total +- sub total/N; averagetotal/k; When designing a cache to run this application, given a constant cache capacity and associativity, will you want a larger or smaller block size? Why? b) examine the MODIFIED code given below: total 0; sub total - O; * Nested loops to avoid overflow * or (j=0; Sub total +-A[ *N + i] ; total +sub total/k; average total/N; = Generally, how will the size of the array and the cache capacity impact the choice of block size for good performance? Why?

Explanation / Answer

A) in this code we are calculating total of N for k times and then finally average. so if we take fixed cache size (say 32KB) and fixed associativity(say 256B). block with smaller size will be preferred because there will be more element for referring in near future and a set can store only 4 block since it is 4 way associative(assumed) so we require more number of sets.

cache lines= 32KB/256B = 27 set =27/22 =25 if block would have 512B then sets=24.

B)

Bigger size array require good cache size and most important smaller block size if it is set associative mapping. rest explaination has been explanned in in A).

Thanks!!!!!!! for boubt feel free to ask.