Module 2: Virtual Memory and Caches
  Lecture 3: Virtual Memory and Caches
 


2-way Set Associative

Set Associative Cache

  • When you need to evict a line in a particular set you run a replacement policy
    • LRU is a good choice: keeps the most recently used lines (favors temporal locality)
    • Thus you reduce the number of conflict misses
  • Two extremes of set size: direct-mapped (1-way) and fully associative (all lines are in a single set)
    • Example: 32 KB cache, 2-way set associative, line size of 64 bytes: number of indices or number of sets=32*1024/(2*64)=256 and hence index is 8 bits wide
    • Example: Same size and line size, but fully associative: number of sets is 1, within the set there are 32*1024/64 or 512 lines; you need 512 tag comparisons for each access