Hardware Secrets
Home | Camera | Case | CE | Cooling | CPU | Input | Memory | Mobile | Motherboard | Networking | Power | Storage | Video | Other
Content
Articles
First Look
Gabriel's Blog
News
Reviews
Tutorials
Main Menu
About Us
Awarded Products
Compare Prices
Datasheets
Dictionary
Download
Drivers
Forums
Links
Manufacturer Finder
Newsletter
On The Web
RSS Feed
Test Your Skills
Twitter
Newsletter
Subscribe today!
Search




Recommended
The Winn L. Rosch Hardware Bible, 6th Edition (2 Vol. Set)
The Winn L. Rosch Hardware Bible, 6th Edition (2 Vol. Set), by Winn L Rosch (Que), starting at $3.32
Home » CPU
How The Memory Cache Works
Author: Gabriel Torres
Type: Tutorials Last Updated: September 12, 2007
Page: 8 of 9
Real-time pricing for AMD ADX630WFGIBOX.
AMD Processor Athlon II X4 630 2.8GHz 2MB L2 Cache Box ADX630WFGIBOX
PC Connection: $122.00 CircuitCity: $114.99
Amazon: $99.99 TigerDirect: $114.99

n-Way Set Associative Cache

On this configuration the memory cache is divided in several blocks (sets) containing “n” lines each.

So on a 4-way set associative cache the memory cache will have 2,048 blocks containing four lines each (8,192 lines / 4), on a 2-way set associative cache the memory cache will have 4,096 blocks containing 2 lines each and on a 16-way set associative cache the memory cache will have 512 blocks containing 16 lines each. Here we are continuing our example of a 512 KB L2 memory cache divided into 8,192 64-byte lines. Depending on the CPU the number of blocks will be different, of course.

n-way set associative cache
Figure 7: 512 KB L2 memory cache configured as 4-way set associative.

Then the main RAM memory is divided in the same number of blocks available in the memory cache. Keeping the 512 KB 4-way set associative example, the main RAM would be divided into 2,048 blocks, the same number of blocks available inside the memory cache. Each memory block is linked to a set of lines inside the cache, just like in the direct mapped cache. With 1 GB RAM, the memory would be divided into 2,048 blocks with 512 KB each, see Figure 8.

n-way set associative cache
click to enlarge
Figure 8: 512 KB L2 memory cache configured as 4-way set associative.

As you see the mapping is very similar to what happens with the direct mapped cache, the difference is that for each memory block there is now more than one line available on the memory cache. Each line can hold the contents from any address inside the mapped block. On a 4-way set associative cache each set on the memory cache can hold up to four lines from the same memory block.

With this approach the problems presented by the direct mapped cache are gone (both the collision problem and the loop problem we describe on the previous page). At the same time, the set associative cache is easier to implement than the full associative cache, since its control logic is simpler. Because of that this is nowadays the most common cache configuration, even though it provides a lower performance compared to the full associative one.

Of course we still have a limited number of available slots inside each memory cache set for each memory block – four on a 4-way configuration. After these four slots are taken, the cache controller will have to free one of them to store the next instruction loaded from the same memory block.

When we increase the number of ways a set associative memory cache has – for example, from 4-way to 8-way configuration –, we have more slots available on each set, but if we keep the same amount of cache memory the size of each memory block is also increased. Continuing our example, moving from 4-way to 8-way would make our 1 GB RAM memory to be divided into 1,024 1 MB blocks. So this move would increase the number of available slots on each set, but now each set would be in charge of a bigger memory block.

There is a lot of academic discussion regarding what is the perfect balance between the number of sets and the memory block size and there is no definitive answer – Intel and AMD use different configurations, as you will see on next page.

So what happens if we have a bigger memory cache? Keeping the above example, if we increased the L2 memory cache from 512 KB to 1 MB (the only way to do that would be by replacing the CPU), what would happen is that we would have 16,384 64-byte lines in our memory cache, what would give us 4,096 sets with four lines each. Our 1 GB RAM memory would be divided into 4,096 256 KB blocks. So basically what happens is that the size of each memory block is lowered, increasing the chance of the requested data to be inside the memory cache – in other words, increasing the cache size lowers the cache miss rate.

However, increasing the memory cache isn’t something that guarantees increase in performance. Increasing the size of the memory cache assures that more data will be cached, but the question is whether the CPU is using this extra data or not. For example, suppose a single-core CPU with 4 MB L2 cache. If the CPU is using heavily 1 MB but not so heavily the other 3 MB (i.e. the most accessed instructions are taking up 1 MB and on the other 3 MB the CPU cached instructions are not being called so much), chance is that this CPU will have a similar performance of an identical CPU but with 2 MB or even 1 MB L2 cache.

Pages (9): « 1 2 3 4 5 6 7 [8] 9 »
Print Version | Send to Friend | | Bookmark Article | Comments (0)

Related Content
  • Inside Intel Nehalem Microarchitecture
  • Core 2 Duo, Core 2 Quad, Phenom X3 and Phenom X4: Which One is the Best USD 200 CPU?
  • Everything You Need to Know About the CPU C-States Power Saving Modes
  • Inside Atom Architecture
  • All Atom Models

  • Recommended Deal.
    StarTech FAN478StarTech FAN478

    Pentium 4 Heatsink And Fan for P4 Pga478 Electronics FAN478 StarTech Pga478

    Amazon: $14.97 J & R: $14.99
    CameraWorld: $13.35 CompUPlus: $11.99

    RSSLatest News
    A-Data Intros 8 GB DDR3 Memory Kit
    March 17, 2010 - 3:40 PM PST
    Intel Launches Xeon 5600 Series and Core i7-980X Processor
    March 16, 2010 - 3:46 PM PST
    Intel Launches 40 GB X25-V SSD Drive
    March 15, 2010 - 1:43 PM PST
    Arctic Cooling Intros Cooler for Radeon HD 5970 and HD 5870
    March 12, 2010 - 12:19 PM PST
    OCZ Announces 32 GB Onyx SSD Unit
    March 10, 2010 - 4:08 PM PST
    MSI Launches X-Slim X360 Laptop
    March 9, 2010 - 4:15 PM PST
    Spire Launches TherMax Eclipse II CPU Cooler
    March 8, 2010 - 2:59 PM PST
    Sparkle Gives 3D Glasses with GeForce GT 240 Video Cards
    March 5, 2010 - 12:28 PM PST
    Corsair Launches Force SSD Drive
    March 4, 2010 - 8:17 AM PST
    Kingston Announces HyperX LoVo DDR3 Memory Kits
    March 3, 2010 - 9:07 PM PST
    .:: More News ::.

    RSSLatest Content
    All Core i5 Models
    Mionix Naos 5000 Mouse Review
    Arctic Cooling E361-WM Earphones Review
    Don’t Let Your IT Projects Become Vaporware
    OCZ Z Series 850 W Power Supply Review
    HIS Radeon HD 5570 Fan Video Card Review
    Core i7-980X CPU Review
    Gelid Tranquillo CPU Cooler Review
    How to Discover Your Power Supply Real Manufacturer
    OCZ Z Series 1000 W Power Supply Review
    Amacrox Free Earth 85PLUS 650 W Power Supply Review
    ECS A890GXM-A Motherboard
    ASUS M4A89GTD PRO/USB3 Motherboard Review
    PC Power Supply Protections: They Won’t Always Protect You
    Huntkey Balance King 4500 450 W Power Supply Review

    Our Most Popular Articles
    Maximum CPU Temperature
    1,152,881 views
    How to Find Out Your Motherboard Manufacturer and Model
    815,359 views
    nVidia Chips Comparison Table
    741,917 views
    Connecting Two PCs Using a USB-USB Cable
    670,783 views
    How To Correctly Apply Thermal Grease
    623,898 views
    AMD ATI Chips Comparison Table
    608,932 views
    ATI Radeon X1300 Pro Review
    506,291 views
    ATI Radeon X1600 XT Review
    493,981 views
    How To Perform a BIOS Upgrade
    442,460 views
    Understanding RAM Timings
    380,454 views

    Latest Threads in Our Forums
    Custom PC Help
    by thebigman101
    A-Data Intros 8 GB DDR3 Memory Kit
    by Hardware Secrets Team
    Epson WorkForce 610 All-in-One Printer
    by Hardware Secrets Team
    Mionix Naos 5000 Mouse Review
    by Mescalamba
    All Core i5 Models
    by Hardware Secrets Team
    Gpu Fans.....
    by Cold_Reborn
    Intel Launches Xeon 5600 Series and Core i7-980X Processor
    by Hardware Secrets Team
    Arctic Cooling E361-WM Earphones Review
    by Hardware Secrets Team
    All CPU Sockets
    by Gabriel Torres
    need to adjust psu voltages
    by dooleys1972
    .:: Visit Our Forums ::.


    © 2004-10, Hardware Secrets, LLC. All rights reserved.
    Advertising | Legal Information | Privacy Policy
    All times are Pacific Standard Time (PST, GMT -08:00)