GATE | GATE CS 2008 | Question 72

Consider the data given in above question. Which of the following array elements 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]


Answer: (B)

Explanation: Total number of elements in array = 210 * 210 = 220
Each block in cache can contain 2 elements as double is 8 bytes and size of each block = 16 bytes.
Total number of elements that can be present in cache = Total number of blocks * 2 = 2 * 211 * 2 = 213

For having same cache index the 11 set bits for the element should be same as Arr[0][0], in other words, the element should map to same address as Arr[0][0],

Mapping of the should be as follows:




Set No ............................... Block1................................ Block2

00000000000.....................Arr[0][0] Arr[0][1]..................Arr[4][0] Arr[4][1]
00000000001.....................Arr[0][2] Arr[0][3]
.
.
.
01111111111....................Arr[2][1022] Arr[2][1023]
10000000000....................Arr[3][0] Arr[3][1]
.
.
.
11111111111.....................Arr[3][1022] Arr[3][1023]

So, index of Arr[0][0] is same as Arr[4][0].
 
Thus, B is the correct choice.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.