I was just solving an exercise when the answer of this suprised me : We have a memory hierarchy built with 2 levels of caches and a main memory, the access time of the L1 is 1 cycle, for L2 it's 10 and the main memory can be accessed in 100 cycles. We are then asked to calculate the AMAT of this memory. The miss rate of L1 is 0.05, this of L2 is 0.2.

I had never learned the formula AMAT = t_cache + MR_caches(t_MM + MR_MM*t_VM) so I computed a solution only with my little brain and for me it was logical that, first 95% of the data are accessed in 1 cycle, we get 0.95. Then out of these 5% left, 80% are accessed in 10 cycles, we get 0.05 * 0.8 * 10. Finally 20% of these 5% are accessed in 100 cycles, which give us 0.05 * 0.2 * 100, it's like probabilities.

What am I doing wrong ? I got an AMAT of 2.35 but the formula tells me it's 2.5.

  • $\begingroup$ You should accept the answer or indicate what is the matter with it. $\endgroup$ Nov 8 '20 at 18:39

Judging from the formula for AMAT, here is what happens:

  • An attempt is made to access the data via the L1 cache. This takes 1 cycle, whether the data is there or not.
  • If the data is not in the L1 cache, then an attempt is made to access it via the L2 cache. This takes 10 cycles, whether the data is found there or not.
  • Finally, if the data is neither the L1 nor the L2 cache, then it is retrieved from main memory using 100 cycles.

In your case, data is found in the L1 cache with probability 0.95, not in the L1 cache but in the L2 cache with probability 0.04, and in neither caches with probability 0.01. In the first case, the access time is 1 cycle, in the second it is 11 cycles, and in the third it is 111 cycles. In total, the average access time is $$ (0.95 \times 1) + (0.04 \times 11) + (0.01 \times 111) = 0.95 + 0.44 + 1.11 = 2.50 \text{ cycles}. $$

  • $\begingroup$ Of course, that's obvious now, thank you some much ! $\endgroup$
    – Kent
    Jul 27 '18 at 11:03
  • $\begingroup$ If you like the answer, you can upvote and accept it. $\endgroup$ Jul 27 '18 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.