title: How to calculate effective CPI for a 3 level cache
body: <p>I am hopelessly stuck on a homework problem, and I would love some help understanding it better.  Here is what I was given:</p>
  
  <ol>
  <li>CPU base CPI = 2, clock rate = 2GHz</li>
  <li>Primary Cache, Miss Rate/Instruction = 7%</li>
  <li>L-2 Cache access time = 15ns</li>
  <li>L-2 Cache, Local Miss Rate/Instruction = 30%</li>
  <li>L-3 Cache access time = 30ns </li>
  <li>L-3 Cache, Global Miss Rate/Instruction = 3%, Main memory access time = 150ns</li>
  </ol>
  
  <hr>
  
  <p>What is the effective <em>CPI</em>?</p>
  
  <p>It is my understanding that I need to calculate the miss penalty for each cache level.  </p>
  
  <ul>
  <li>L1 miss penalty = Access time of L2 = 15ns / (1ns/2cc) = 30 clock cycles</li>
  <li>L2 miss penalty = Access time of L3 = 30ns / (1ns/2cc) = 60 clock cycles</li>
  <li>L3 miss penalty = Access time of MM = 150ns / (1ns/2cc) = 300 clock cycles</li>
  </ul>
  
  <p>Now I need to calculate the effective <em>CPI</em>.  This is where I am a bit confused.</p>
  
  <p>I believe the <em>formula</em> should be:</p>
  
  <blockquote>
    <p>CPI = BaseCPI + (%L1 MR/Instr * L1 Miss Penalty) + (%L1 MR/Instr *
    %L2 MR/Instr * L2 Miss Penalty) + (%Global MR/Instr * L3 Miss Penalty)</p>
  </blockquote>
  
  <p>If I do this, I get </p>
  
  <blockquote>
    <p>CPI = 2.0 + (0.07 * 30) + (0.07 * 0.3 * 60) + (0.03 * 300) = 14.36</p>
  </blockquote>
  
  <hr>
  
  <p>After emailing my instructor because no one in the class understood the 1-2 minute explanation of global and local, I was told that my answer is close, but wrong. If anyone could provide some insight, or even point me towards a good tutorial, I would be grateful.  I can understand how to figure out effective <em>CPI</em> for 1 and 2 level caches. Making the jump to 3 confuses me. </p>