Similar questions 5 more →
Cache Memory
![Question 72, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
for(j=0;j<1024;j++) ARR[i][j]=0.0;
Which element has the same cache index as ARR[0][0]?
(A) ARR[0][4]
(B) ARR[4][0]
(C) ARR[0][5]
(D) ARR[5][0]](../../assets/questions/CS-2008-Q72-1.webp)
![Question 72, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
for(j=0;j<1024;j++) ARR[i][j]=0.0;
Which element has the same cache index as ARR[0][0]?
(A) ARR[0][4]
(B) ARR[4][0]
(C) ARR[0][5]
(D) ARR[5][0]](../../assets/questions/CS-2008-Q72-2.webp)
Your answer
Answer & solution
Answer: B (no official key was published)
1. The index repeats every 2048 sets×16 bytes=32768 bytes. A row contains 1024 doubles×8 bytes=8192 bytes.
2. ARR[4][0] is 4×8192=32768 bytes after ARR[0][0], so it has the same set index, option B. ARR[0][4] and ARR[0][5] are only 32 and 40 bytes later; ARR[5][0] is 40960 bytes later, changing the index.