250 likes | 373 Views
The fastest and most expensive memory on a computer system that is used to store collections of data.Uses very short time to access recently and frequently used data. This helps improve computing performance by decreasing data access time.With the speeds of modern CPUs ever increasing, accessin
E N D
1. Cache MemoryBy Ed Martinez
2. The fastest and most expensive memory on a computer system that is used to store collections of data.
Uses very short time to access recently and frequently used data. This helps improve computing performance by decreasing data access time.
With the speeds of modern CPUs ever increasing, accessing main memory has become a major performance bottleneck. Effective use of cache can help to minimize this problem. What is Cache Memory?
3. Cache Levels Cache are referred to in levels, such as L1 or L2.
The level describes the connection or physical proximity of the cache to the CPU.
Traditionally, L1 cache, usually the smaller of the two, is located on the processor and runs at the same speed as the processor. L2 cache is outside, but near the processor and runs at the speed of the motherboard or FSB.
Recent designs have begun to integrate L2 cache onto the processor card or into the CPU chip itself, like L1 cache. This speeds access to the larger L2 cache, which improves the computer’s performance.
4. CPU Roadmap
5. Cache Memory This photo shows level 2 cache memory on the Processor board, beside the CPU
6. Cache Mapping Associative
Direct
Set Associative
7. Associative Mapping Sometimes known as fully associative mapping, any block of memory can be mapped to any line in the cache.
The block number is appended to the line as a tag.
There is a bit to indicate whether the line is valid or not.
Difficult and expensive to implement.
8. Direct Mapping Each block in main memory can be loaded to only one line in cache.
Each cache line contains a tag to identify the block of main memory in the cache.
This is easy to implement, but inflexible.
9. Set-Associative Mapping Blocks can be mapped to a subset of the lines in cache.
A block can be mapped to either 2 or 4 lines in cache, usually referred to as “Two-way” or “Four-way”.
LRU is the most popular replacement policy used with this mapping process.
More flexible than direct mapping, but easier to implement than associative mapping.
10. Why use a cache replacement policy? Cache is small compared to available system memory
Cache maintains copies of recently referenced data items to speed access time
Once full it must use a replacement policy to decide how to handle additional data items
The replacement policy can either ignore the new data or decide which of the old data items to remove to make room
11. Cache Replacement Policy (cont) Two main issues in determining which policy to use:
Increase the hit ratio by keeping the items that are referenced most frequently
Policy should be inexpensive to implement
12. Cache Replacement Policies FIFO
LRU
Random
13. FIFO Replacement FIFO (First in, first out) – the oldest data item in the cache frame is replaced.
Easy to implement and has fast operation.
Since it maintains no reference statistics, depending on the sequence of the data you may be constantly removing and replacing the same block of memory.
14. LRU Replacement Least Recently Used – The item that was accessed least recently is replaced with the new data item.
Easy to implement, follows the idea that items which have been recently used are likely to be used again.
Keeps a list of data items that are currently in the cache. Referenced data items are moved to the front of the list
Data items at the back of the list are removed as space is needed
Primary drawback is that it requires time to analyze the reference statistics to determine which item to remove. Also requires additional cache space to maintain the statistics
15. Random Replacement Random – a randomly generated address determines which data item in the cache frame to replace.
Has no need to store statistics, so it doesn’t waste time analyzing anything.
Performance is close to that of the other policies, and the implementation is fairly simple.
16. Cache Replacement Policies Lets assume a computer system has an associative, a direct-mapped, or a two-way set-associative cache of 8 bytes.
The CPU accesses the following locations in order (the subscript is the low-order 3 bits of its address in physical memory ):
A0 B0 C2 A0 D1 B0 E4 F5 A0 C2 D1 B0 G3 C2 H7 I6 A0 B0
17. Associative Cache(FIFO Replacement Policy)
18. Direct mapped Cache
19. Two-way set associative cache(LRU Replacement Policy)
20. Replacement with 2 byte line size
Now lets consider data lines of two bytes. The data pairs that make up the lines are:
A and J; B and D; C and G; E and F; and I and H.
21. Associative Cache with 2 byte line size (FIFO Replacement Policy)
22. Direct-mapped Cachewith line size of 2 bytes
23. Two-way set Associative Cachewith line size of 2 bytes
24. Cache Performance Primary reason for including cache memory in a computer is to improve system performance by reducing the time needed to access data in memory.
The cache hit ratio – hits/(hits + misses).
A well-designed cache will have a hit ratio close to 1.
Cache hits outnumber the misses by far. When more data is retrieved from the faster cache memory rather than from main memory system performance is improved.
25. Cache Performance (cont)
26. References Carpielli, John D, Computer Systems Organization & Architecture
Comer, Douglas E, Essentials of Computer Architecture
http://www.kids-online.net/learn/click/details/micropro.html
http://www.oit.edu/faculty/conek_images/documents/Ch6_ECOA.ppt