Question: Consider the function compute variance listed below, which computes the variance of integer numbers stored in the array data. 1 int data [ N ]

Consider the function compute variance listed below, which computes the variance of
integer numbers stored in the array data.
1 int data[N];
2
3 int compute_variance(){
4 int sum1=0, sum2=0, result;
5 int i;
6
7 for(i=0; i < N; i++){
8 sum1+= data[i];
9}
10 sum1/= N;
11
12 for(i=0; i < N; i++){
13 sum2+= data[i]* data[i];
14}
15 sum2/= N;
16
17 result =(sum2- sum1*sum1);
18
19 return result;
20}
Suppose this program is executing on a 32-bit processor with a direct-mapped cache
with parameters (m, k, n)=(32,3,3). S e e t h e F i g u r e 1 f o r t h e
e x p l a n a t i o n o f m , k , a n d n .
F i g u r e 1
We make the following additional assumptions:
An int is 4 bytes wide.
sum1, sum2, result, and i are all stored in registers.
data is stored in memory starting at address 0x0.
Answer the following questions:
(a) How many blocks will be in the cache? [10 points]
(b) How many bytes-per-block will be in the cache? [10 points]
(c) Consider the case where N is 16. How many cache misses will there be?
This question is solved for you.
(d) Now suppose that N is 32. Based upon the above solution, recompute the number
of cache misses. [30 points]

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 Programming Questions!