edited by
15,676 views
61 votes
61 votes

Consider a machine with a $2$-way set associative data cache of size $64$ Kbytes and block size $16$ bytes. The cache is managed using $32$ bit virtual addresses and the page size is $4$ Kbytes. A program to be run on this machine begins as follows:

double ARR[1024][1024];
int i, j;
/*Initialize array ARR to 0.0 */
for(i = 0; i < 1024; i++)
    for(j = 0; j < 1024; j++)
        ARR[i][j] = 0.0;


The size of double is $8$ bytes. Array $\text{ARR}$ is located in memory starting at the beginning of virtual page $\textsf{0xFF000}$ and stored in row major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by the program are those to array $\text{ARR}$.

Which of the following array elements have the same cache index as $\text{ARR[0][0]}$?

  1. $\text{ARR[0][4]}$
  2. $\text{ARR[4][0]}$
  3. $\text{ARR[0][5]}$
  4. $\text{ARR[5][0]}$
edited by

6 Answers

0 votes
0 votes

#sets=2^11

block size=16 bytes

element size=8 byte

#elements in one block=2

each set contain=2 blocks                                                                       set 0::  A[0][0] | A[0][1]  

#elements in one set=4 elements                                                                          A[0][2] | A[0][3]

total no.of elements covered in 2^11 sets = 2^11*4=2^13 ELEMENTS           set 1::  A[0][4] | A[0][5]

A[0][0]..........................A[0][1023]=2^10 ELEMENTS                                          A[0][6] | A[0][7]

A[1][0]..........................A[1][1023]=2^10 ELEMENTS                        

A[2][0]..........................A[2][1023]=2^10 ELEMENTS            

A[3][0]..........................A[3][1023]=2^10 ELEMENTS                      

TOTAL ELEMENTS COVERED FROM A[0][0] ............................A[3][1023]=2^10 + 2^10 + 2^10 +2^10 = 2^12 elements ..

TOTAL sets  COVERED FROM A[0][0] ............................A[3][1023] = (total  elements covered)/(no.of elements in one set)=                                                                                               (2^12)/4= 2^10 sets covered...

  NOW we have 2^11 sets and only 2^10 covered how a[4][0] is the answer ..............................

 

MY QUESTION IS --------------

 IS AM I PREDTENDING IT LIKE DIRECT MAPPING?????

HELP ME @Arjun SIR

Answer:

Related questions