Reputation: 41
I have seen the average memory access time often quoted as:
AMAT = (L1 cache hit time + L1 miss rate*(L2 hit time + L2 miss rate*(memory access time)))
Is there any reason why the hit times are not multiplied by the hit rate? And only the miss times are multiplied by the miss rates?
Upvotes: 4
Views: 2558
Reputation: 7534
Homework?
In most caches, all requests go to the L1 cache, and then, only after they have been determined to be a miss, go to the L2. And so on.
Or:
In 100 accesses
Time spent in L1 hits = L1 cache hit time * L1 cache hit rate
Time spent in L1 misses that go to memory = L1 cache miss rate * ( L1 cache hit time + time to go to memory)
Total time = Thit * Phit*100 + Pmuss*100 * (Thit + Tmiss)
= Thit * (1-Pmiss)*100 + Pmiss*100 (Thit+Tmiss)
= Thit * ( 1-Pmiss+Pmiss ) * 100 + Pmiss*100*Tmiss
= 100* (Thit + Pmiss*Tmiss)
and so on if you have an L2.
I.e. they cancel out.
Now, there ARE cache systems, or at least there have been, where accesses were sent to both the cache and memory at the same time. In such systems
Tavg = Phit*Thit + Pmiss*Tmiss.
but these are not common. They tend to waste power, since you have started an L2 or main memory access that you probably won't need.
I call the former a look-through cache, and the latter a lookaside cache.
(I have since learned that some of my coworkers call this latter case, where an access is sent to both cache and memory at the same time, a "speculative cache miss access to memory". Which is not an unreasonable use of the term "speculation", but which can also be confused with "speculative cache misses" as produced, e.g., by a machine with branch prediction. Consider two cases: (1) a machine with no branch prediction, no speculative execution. On such a machine, the instruction, the memory reference, is not speculative, so we are just speculating as to whether to send this access just to cache or also to memory. (2) a machine with branch prediction or other forms of speculative execution. On such a machine, the actual memory operation is speculative. The two can be combined: a speculative instruction, which we do not yet know is actually going to execute, can produce a memory access that may or may not be speculatively sent to memory before it is determined to be a cache miss.)
Upvotes: 2
Reputation: 713
That's because whether the cache is hited or not, this time that look up the data in cache has already spent.
AMAT=HitTime * (1-MissRate) + MissRate * (HitTime + MissPenalty)
=HitTime + MissRate * MissPenalty
Upvotes: 3