in CO and Architecture edited by
236 views
1 vote
1 vote

A CPU has a $32$ KB direct-mapped cache with $128$byte block size. $’A’$ is a two dimensional array of size $512 \times 512$ with elements that occupy $8$bytes each.

for (j=0; j<512; j++)
{
    for (i=0; i<512; i++)
    {
        x +=A[j] [i];
    }
}

The number of cache misses in row major order is:

  1. $2^{11}$
  2. $2^{14}$
  3. $2^{18}$
  4. $2^{15}$
in CO and Architecture edited by
by
236 views

1 comment

#plz explain???
1
1

1 Answer

3 votes
3 votes
Best answer

 Number of lines in cache = 32 kB/28  

=> ( 25 * 210 )  / 28  = 27
No.of elements in one block= 128/ 8 = 27 / 23 =  24.
when 1st element is referred, we bring block number 0 of main memory to line number 0.we not only bring 1st element but also 24 elements(as we bring the whole block)... so when 1st element is referred, gives a miss.

next 24-1 elements gives hit.
miss rate 1/24.
no.of misses= (1/24) * number of references.
number of references = 512 * 512 (as each element is accessed once)
(1/24) * 218 = 214 misses.. option B .

selected by

3 Comments

Correct answer is 2^14 and not in option.

No.of elements in one block= 25

Its 2^4 as 128/8 =16 elements each block

1
1
Thanks @rahul sharma , corrected my mistake .
0
0
You have written,

Number of lines in cache = $32 KB/2^8=2^7$

I think it should be $32K/2^7=2^8$ as Block size is $128$ bytes and not $256$ bytes.
0
0
Answer:

Related questions