Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.92 KB | None | 0 0
  1. Temporal Locality : Keep most recently accessed data items closer to the processor
  2. Spatial Locality : Move blocks consisting of contiguous words closer to the processsor.
  3.  
  4. Hit Rate : the fraction of memory accesses found in a level of the memory hierarchy.
  5. Hit Time : Time to access that level which consist of time to access the block + Time to determine hit/miss
  6. Miss Rate : the fraction of memory accesses not found in a level of the memory hierarchy (1 - Hit Rate)
  7. Miss Penalty : Time to replace a block in that level with the corresponding block from a lower level.
  8.  
  9. Register <-> Memory : by compiler
  10. Cache <-> Main Memory : by cache controller hardware
  11. Main Memory <-> Disk : by operating system (virtual memory) ; virtual to physical address mapping assisted by the hardware (TLB) ; by the programmer (files)
  12.  
  13. Direct Mapped Cache : Location determined by address.
  14. Index - Use low-order address bits
  15. Tag - High-order address bits
  16. Valid Bit - 1 if present, 0 otherwise. Initially 0
  17.  
  18. Sources of Cache Misses
  19. Compulsory : First access to a block (first reference); Solution: increase block size (increases miss penalty; very large blocks could increase miss rate)
  20. Capacity : Cache cannot contain all blocks accessed by the programa Solution: increase cache size ( may increase accesss time)
  21. Conflict (collision) : Multiple memory locations mapped to the same cache location
  22. Solution : Increase cache size or increase associativity (both may increase access time)
  23.  
  24. Write Policies
  25. Write-Through : On data-write hit , update the block in cache and also updates memory.
  26. But makes writes take longer, solution is to use write buffer that holds data waiting to be written to memory so the cpu can continue immediately (only stalls on write if write buffer is already full)
  27. Write-Back : On data-write hit, only update the block in cache but keep track of whether each block is dirty. When a dirty block is replaced, write it back to memory.
  28.  
  29. Write Miss :
  30. No Write Allocate : write directly to write buffer. (used with Write Through)
  31. Write Allocate : check for hit and then write, pipeline writes via a delayed write buffer to cache. (used with Write Back)
  32.  
  33. Loading Policies
  34. Blocking : the requested word is only sent to the processor after the whole block has been loaded into cache
  35. Non Blocking : Early Restart : fetch the words in normal order, but as soon as the requested word of the block arrives, send it to the processor and let the processor continue execution.
  36. Critical Word First : Request the missed word first from memory and send it to the processor as soon as it arrives; let the processor continue execution while filling the rest of the words in the block.
  37.  
  38. CPU Time = IC * CPIstall (accesses per programa * miss rate * miss penalty) * CC
  39. Average Memory access time = Hit time + Miss rate * Miss Penalty
  40.  
  41. Replacement Policy
  42.  
  43. Direct Mapped : no choice
  44. Set Associative : prefer non-valid entry, if there is one, otherwise choose among entries in the set.
  45. Least Recently Used : Choose the one unused for the longest time. Only manageable till 4-way
  46. Random : Approximately the same performance as LRU for high associativity
  47.  
  48. Out of order CPUs can execute instructionss during cache miss, pending store stays in load/store unit (dependent instructions wait in reservation stations) and independente instructions continue.
  49.  
  50. Victim Cache, When replacing a block from the cache, keep it temporarily in the victim buffer so that in the subsequenent cache miss, the contentss of the buffer are checked to see if they have the desired data before accessing the lower level memory. (Small cache, Fully associative, particurly efficient for small direct mapped caches)
  51.  
  52. Multilevel Caches ;
  53. Primary Cache L1 : Focus on minimal hit time
  54. Level-2 Cache : Focus on low miss rate to avoid main memory access , hit time has less overall impact.
  55. Results : L-1 cache usually smaller than a single cache, L-1 block size smaller than L-2 block size
  56.  
  57. taccess = thitL1 + pmissL1 * tpenaltyL1
  58. tpenaltyL1 = thitL2 + pmissL2 * tpenaltyL2
  59. taccess = thitL1 + pmissL1 * (thitL2 + pmissL2 * tpenaltyL2)
  60.  
  61. Improving Cache Performance :
  62. 1. Reduce the hit time in the cache : smaller cache, direct mapped cache, smaller blocks.
  63. 2. Reduce Miss rate : bigger cache, larger blocks, increase associativity, victim cache.
  64. 3. Reduce the miss penalty : smaller blocks, use a write buffer to hold dirty blocks being replaced so don't have to wait for the write to complete before reading.
  65. Check write buffer (and/or victim cache) on read miss; For large block fetch critical word first ; Use multiple cache levels ; faster backing store/improved memory bandwidth (wider buses, memory interleaving, DDR SDRAMs)
  66.  
  67. Virtual Memory :
  68. Use main memory as a "cache" for secondary memory (disk)
  69. Each program share main memory but each is compiled into its own address space - a virtual address space.
  70. CPU and OS translate virtual addresses to physical addresses.
  71. - VM "block" is called a page
  72. - VM "miss" is called a page fault
  73.  
  74. Page Tables : To reduce page fault rate, prefer least-recently used replacement. Reference bit (aka use bit) in PTE, is set to 1 on access to page (used recently) , periodically cleared to 0 by OS (has not been used recently).
  75. Write blocks at once, use write-back (only write to cache on hit and keep track of dirty blocks) with dirty bit on PTE set when page is written
  76.  
  77. Page Table Dimension
  78. First get page offset by calculating log2(page size in bytes)
  79. Then, calculate Physical Page Number (PPN) size by subtracting page offset from total number of bits allocated for physical address.
  80. Now you can calculate Page Table Entry (PTE) size by adding valid bit, protection bit, etc. to the calculated PPN.
  81. One last piece of information we need is the number of page entries in the page table. We can get this by subtracting page offset from the total number of bits we have for the virtual page number;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement