GATE / CS ARCHIVE

GATE CSE 2008 / QUESTION 73

Cache hits for row-major initialization

Computer Organization & Architecture · Cache Memory · Full GATE CSE 2008 paper

GATE 2008, Q73 2 marks · MCQ
Report issue

Cache Memory

Question 73, 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;
What is the cache hit ratio for the initialization loop? The printed statement does not specify write allocation.

(A) 0%
(B) 25%
(C) 50%
(D) 75%
Question 73, 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;
What is the cache hit ratio for the initialization loop? The printed statement does not specify write allocation.

(A) 0%
(B) 25%
(C) 50%
(D) 75%
Tap to enlarge
Your answer
Answer & solution

Answer: C (assuming write allocation) (no official key was published)

1. Sequential row-major stores touch two adjacent 8-byte doubles in each 16-byte cache line. With the intended write-allocate policy and an initially empty cache, the first store misses and allocates the line, and the second store hits.
2. The hit ratio is therefore 1/2=50%, option C. The array is page-aligned and thus line-aligned.
3. No line is reused after the traversal moves beyond it, so capacity misses do not change this pairing. A no-write-allocate cache would leave every store a miss and yield 0% (A).

Original paper, page 15