Direction: Consider a machine with a 2-way set associative data cache of size 64 kbyte and block size 16 byte. The cache is managed using 32 bit virtual addresses and the page size is 4 kbyte. 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 byte. Array ARR is located in memory starting at the beginning of virtual page 0 × FF000 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 ARR.
-
Which of the following array elements has the same cache index as ARR [0] [0] ?
-
- ARR [0] [4]
- ARR [4] [0]
- ARR [0] [5]
- ARR [5] [0]
- ARR [0] [4]
Correct Option: B
The array element ARR [4] [0] has the same cache index as ARR [0] [0] since it is given that page size is of 4 kbyte and 1 row contains 1024 elements, i.e., 210 locations.