edited by
464 views
7 votes
7 votes

In a C program, an array is declared as $\text{double arr[8192]}$. The starting address of the array is $\textsf{0x}00000000$. This program is run on a computer that has a $4$-way set associative cache of size $32$ Kbytes, with block size of $64$ Bytes. If the program accesses the elements of the array one by one in order from first element to last and then one more time in reverse order from the last element to the first element, total number of cache misses will be _______

(Assume that the data cache is initially empty and that no other data or instruction accesses are to be considered.)

  1. $2048$
  2. $1536$
  3. $256$
  4. $1024$
edited by

1 Answer

Best answer
7 votes
7 votes
Number of array elements in a block = $\frac{64}{8}=8$
    
Number of cache blocks = $\frac{2^{15}}{2^6}=512$
    
Number of cache blocks needed for the array = $\frac{2^{13}}{2^3}=1024$
    
So, after every $512$ block accesses, we will need to replace the cache lines from cache.
    
During the forward access, we will have $1024$ compulsory misses as all $1024$ block accesses are their first accesses.
    
During the reverse access, the first $512$ block accesses will be a hit in the case.
    
Remaining $1024 - 512 = 512$ block accesses will cause a miss.
    
So, total number of cache misses $ = 1024 + 512 = 1536$
selected by
Answer:

Related questions

10 votes
10 votes
1 answer
1
gatecse asked Aug 3, 2020
826 views
Consider a CPU with an average CPI of $1.4$ when all memory accesses hit on the cache.Assume an instruction mix$$\begin{array}{|c | c|}\hline\text{ALU }& 45\%\\\text{LOAD...
3 votes
3 votes
1 answer
3