1

I am trying to calculate memory stall cycles per instructions when adding the second level cache.

I have the following given values:

Direct Mapped cache with 128 blocks
16 KB cache
2ns Cache access time
1Ghz Clock Rate
1 CPI
80 clock cycles Miss Penalty
5% Miss rate
1.8 Memory Accesses per instruction
16 bit memory address

L2 Cache
4% Miss Rate
6 clock cycles miss penalty

As I understand it, the way to calculate the Memory stall cycles is by using the following formula:

Memory stall cycles = Memory accesses x Miss rate x Miss penalty

Which can be simplified as:

Memory stall cycles = instructions per program x misses per instructions x miss penalty

What I did was to multiply 1.8 x (.05 +.04) x (80 + 6) = 13.932

Would this be correct or am I missing something?

1 Answer 1

2

First of all, I am not sure about the given parameters for miss penalty for L1 and L2 (L1 being 80 cycles and L2 being 6 cycles).

Anyway using the data as it is:

  1. You issue 1 instruction per clock
  2. There are 1.8 memory instructions in an instruction.
  3. There is a 5% that access can miss L1 and another 4% chance that it can miss L2. You would only access the main memory if you miss in both L1 and L2. That would be .04 * .05 = 0.002 = 0.2% This means per memory access, you are likely to access the main memory 0.2% of the time.
  4. Since you have 1.8 memory accesses per instruction, you are likely to access main memory 0.002 * 1.8 = 0.0036 = 0.36% per instruction.
  5. When you encounter a miss in both L1 and L2, you will get stalled for 80 + 6 = 86 cycles (ignoring any optimizations)
  6. Per instruction, you would only encounter .36% main memory accesses. Hence the memory stall cycles per instruction is .0036 * 86 = 0.3096
Sign up to request clarification or add additional context in comments.

2 Comments

In #3 you are multiplying the miss rates of L1 and L2 caches to get the main memory access?
Yes. Main memory will only be accessed in case of a miss in both L1 and L2. That is 4%(L2) out of 5%(L1). So the % of main memory accesses is the multiplication of those two.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.