Cache Pipelining
Cache Pipelining
Cache pipelining is a technique that improves cache performance
by breaking down cache access into multiple stages. This allows
subsequent requests to begin the pipeline while earlier requests
are still in progress.
Pipelining works by dividing the transfer of data and instructions
from or to the cache into stages. Each stage is kept busy by one
operation at all times, similar to an assembly line. This technique
overcomes the drawbacks of sequential memory operations,
which can waste time and decrease processor speed\
Benefits of Cache Pipelining
Faster hit times: Pipelining allows one hit to overlap with
another, which speeds up hit times.
Reduced cache access time: Pipelined caches can reduce
cache access time.
Pipelining mode
In this mode, one memory value can be accessed in Cache at the
same time that another memory value is accessed in DRAM. The
pipelining operation suggests that the transfer of data and
instructions from or to the cache is divided into stages. Each
stage is kept busy by one operation all the time.
Write Buffer
The write buffer is used for all writes to a
noncacheable, bufferable region, write-through region,
and write misses to a write-back region. A separate
buffer is incorporated in the DCache for holding write-
back data for cache line evictions or cleaning of dirty
cache lines.
Write Through and Write Back
in Cache
Cache is a technique of storing a copy of data temporarily in rapidly
accessible storage memory. Cache stores most recently used words in
small memory to increase the speed at which data is accessed. It acts
as a buffer between RAM and CPU and thus increases the speed at
which data is available to the processor.
Whenever a Processor wants to write a word, it checks to see if the
address it wants to write the data to, is present in the cache or not. If
the address is present in the cache i.e., Write Hit.
We can update the value in the cache and avoid expensive main
memory access. But this results in Inconsistent Data Problem. As
both cache and main memory have different data, it will cause
problems in two or more devices sharing the main memory (as in a
multiprocessor system).
This is where Write Through and Write Back comes into the picture.
Write Through :
Write Through
In write-through, data is simultaneously updated to cache
and memory. This process is simpler and more reliable. This is
used when there are no frequent writes to the cache(The number
of write operations is less).
It helps in data recovery (In case of a power outage or system
failure). A data write will experience latency (delay) as we have
to write to two locations (both Memory and Cache). It Solves the
inconsistency problem. But it questions the advantage of having
a cache in write operation (As the whole point of using a cache
was to avoid multiple access to the main memory).
Write Back
Write Back
The data is updated only in the cache and updated into the
memory at a later time. Data is updated in the memory only
when the cache line is ready to be replaced (cache line
replacement is done using Belady’s Anomaly, Least Recently
Used Algorithm, FIFO, LIFO, and others depending on the
application).
Write Back is also known as Write Deferred.
Dirty Bit: Each Block in the cache needs a bit to indicate if the
data present in the cache was modified(Dirty) or not
modified(Clean). If it is clean there is no need to write it into the
memory. It is designed to reduce write operation to a memory.
If Cache fails or if the System fails or power outages the
modified data will be lost. Because it’s nearly impossible to
restore data from cache if lost.
Write Allocation and Write
Around.
If write occurs to a location that is not present in the Cache(Write
Miss), we use two options, Write Allocation and Write
Around.
Write Allocation
Write Allocation
In Write Allocation data is loaded from the memory into cache
and then updated. Write allocation works with both Write back
and Write through. But it is generally used with Write Back
because it is unnecessary to bring data from the memory to
cache and then updating the data in both cache and main
memory. Thus Write Through is often used with No write
Allocate.
Write Around
Here data is Directly written/updated to the main
memory without disturbing the cache. It is better
to use this when the data is not immediately used