Reputation: 1594
How does one calculate the effect of L1 and L2 cache's on the overall CPI of the processor given base CPI, miss rate % of L1 and L2 caches and access times of L1, L2, and the memory
To find the CPI of L1 cache you would use:
CPI = BaseCPI + (% of L1 Miss x Memory Access Time)
So I imagine that for L2 it would be something like:
CPI = BaseCPI + (% of L1 Miss x L2 Access Time) + ( % which I am confused about x Memory Access time)
How would one go about finding that second percentage?
I know that is has to do with the miss rate % of L2 but is it necessary to multiply by L1 Miss Rate % since L2 Miss will only happen after an L1 miss?
Upvotes: 1
Views: 5166
Reputation: 1665
I think you are not taking into account the Average Number of Memory Accesses per Instruction (AMAPI).
For example, if there are 30% of load/store instructions, this number would be 1.3 (one access to fetch the instruction and 0.3 due to memory access instructions)
So
CPI = BaseCPI + (AMAT - ideal memory access time) x AMAPI
Being AMAT the Average Memory Access Time. For a two-level hierarcchy:
AMAT = L1_hit_latency + L1_miss_rate x (L2_hit_latency + L2_miss_rate x Main_Memory_latency)
Upvotes: 0
Reputation: 19746
Yes, the miss rate of the L2 means the % of misses out of total L2 accesses. Total L2 accesses are the total number of memory accesses * miss rate of the L1.
So, your calculation should be -
CPI = BaseCPI + (% of L1 Miss x L2 Access Time) + ( %L1 miss rate x % L2 miss rate x Memory Access time)
or more conveniently:
CPI = BaseCPI + (% of L1 Miss x (L2 Access Time + (%L2 miss rate x Memory Access time)))
That's also not very accurate - you didn't specify the rate of memory operations, the above is assuming that every instruction is going to lookup the caches, which is a bit exaggerated. If you have a rate of loads/stores in the program you'll have to factor it in as well.
By the way, in the real world you also need to add the following to the total L2 accesses:
But these are usually ignored in simple calculations as this (and you don't know the % of modified lines, so you can't deduce how many writebacks you'll have anyway).
One more note - it's not really The CPI of the cache
, the cache itself doesn't perform instructions or cares about their timing. The proper term would be - The effect of the cache (or any other feature) on the overall CPI of the processor
.
Upvotes: 1