Write back cache formula with write allocate polic

2019-07-30 23:41发布

问题:

If we consider an hierarchical single level write back cache with write allocate policy, then the formula for average access time during write operation is given by :-

Twrite = (H)(Tc) + (1-H)(Tc + Tm + (x*Tm)).

Where,

H= hit ratio of cache.

Tc=access time of cache.

Tm= access time of memory.

x= fraction of cache blocks which are dirty.

The above formula is given in this site https://gateoverflow.in/14480/formula-write-back-write-through-access-time-parallel-serial?show=14502#a14502

However, I think that formula is not entirely correct. According to me, during a write miss in case of write allocate,we first find a block to replace in the cache and if its dirty, we update the main memory. Now we bring the required cache block which contains the word into the cache and then update the cache. This is what I read in hamacher and patterson book.

So shouldn't the formula be

Twrite = (H)(Tc) + (1-H)(Tc + Tm + (x*Tm) + Tc). ?

Here I have added the extra Tc time at the end which is required to update the word in the cache once the block has been brought from main memory. First Tc is the time we add in case of miss because its hierarchical cache

回答1:

I suggest you check the write allocate policy again. There is a really good paper on Write miss polocies by Norman P. Jouppi.

As the name suggests, write allocate, allocates an entry in the cache in case of a write miss. If the line that is allocated for the write miss is dirty, we need to update the main memory with the contents of the dirty cache line. So the amount of time spent on updating the main memory for dirty cache lines would be

x * Tm

After you've updated the main memory with the contents of the dirty cacheline, you can use it to store the data for the write miss. Therefore we need to access the cache. So our new time would be

Tc + (x * Tm) 

However we would only do this, when there is a cache miss. Therefore the whole thing needs to be multiplied by the miss rate.

(1-H)(Tc + (x * Tm))

Above formula covers the case when it is a miss. When it is a hit, we just need to access the cache. That would be Tc times the hit rate

Tc * H

Adding them all gives us the average access time:

(Tc * H) + (1-H)(Tc + (x * Tm))