# AMAT calculation

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.

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

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}.$$