GATE Computer ScienceVery hardGATE CSE

A 4 KB direct-mapped cache has 32-byte lines. The loop "for i = 0..127: sum += A[i] + B[i]" reads 4-byte integers, A starting at address 0 and B starting at address 4112 (= 4096 + 16), A[i] read before B[i]. Counting hits over all 256 reads (cache initially empty), how many hits occur?

  1. A. 96
  2. B. 0
  3. C. 128
  4. D. 192

Correct answer: A. 96

B is offset by half a line from a 4 KB multiple: for i mod 8 < 4, A[i] and B[i] map to the same set and evict each other, otherwise they use different sets; simulation gives 96 hits (if B started at 4096 every access would miss: 0 hits).

More Computer Organization and Architecture questions

Exams that ask this topic