GATE / CS ARCHIVE

GATE CSE 1998 / QUESTION 18

Cache loop hit ratio

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

GATE 1998, Q18 5 marks · Descriptive
Report issue

Cache Memory

Question 18, GATE 1998: A cache has l sets, block size b, k blocks per set, cache/main-memory times tc,tm. A loop of size nb executes 100 times, with n=km and 1<m≤l. Find hit ratio and discuss l=1.
Tap to enlarge
Answer & solution

Answer: Under cold, aligned contiguous block-level accesses: 99%; l=1 contradicts 1<m≤l. (no official key was published)

The loop contains n blocks and total cache capacity is kl blocks. Assume contiguous aligned loop blocks, ordinary block-number modulo-l indexing, no competing data/code, an initially empty cache and one counted access per loop block per pass. Since n≤kl, each set receives at most ceil(n/l)≤k loop blocks. Thus no loop block must evict another after the first pass.

The first traversal incurs n compulsory misses. The remaining 99 traversals hit on all n blocks. Out of 100n block references, 99n hit, so H=0.99. Neither tc nor tm affects this count; they would enter effective access-time calculations instead.

If b denotes b separately referenced words/instructions per block, the denominator changes: there are 100nb references, still n misses, giving H=1−1/(100b). If b is bytes while instructions have unspecified lengths, that word-reference formula cannot be asserted numerically. The definition of an access must be explicit.

The separate request l=1 is incompatible with the earlier constraint 1<m≤l. If it means keep m>1 while replacing the cache by one fully associative k-block set, then n=km>k. Under LRU and repeated cyclic scanning, every block-level access misses: by the time a block is revisited, at least k distinct blocks have intervened. H=0 at block granularity, or 1−1/b for b consecutive word references per block. This is conditional on LRU; an unspecified replacement policy can produce a different ratio. If the intended comparison instead keeps the entire loop fitting, its warmed-up behavior remains 99%. The source does not resolve these alternatives.

Original paper, page 7