200 likes | 329 Views
CSL718 : Memory Hierarchy. Cache Memories - continued 13th Feb, 2006. Cache Policies. Placement/Mapping Direct, Associative, Set associative, Sector mapped Read Sequential / Concurrent, Simple / Forward Load Block load / Load forward / Wrap around Fetch
E N D
CSL718 : Memory Hierarchy Cache Memories - continued 13th Feb, 2006 Anshul Kumar, CSE IITD
Cache Policies • Placement/Mapping • Direct, Associative, Set associative, Sector mapped • Read • Sequential / Concurrent, Simple / Forward • Load • Block load / Load forward / Wrap around • Fetch • Demand fetch, Software pre-fetch, Hardware pre-fetch • Replacement • LRU / LFU / FIFO / Random Anshul Kumar, CSE IITD
Fetch Policies • Demand fetching • fetch only when required (miss) • Hardware prefetching • automatically prefetch next block • Software prefetching • programmer decides to prefetch questions: • how much ahead (prefetch distance) • how often Anshul Kumar, CSE IITD
Software Control of Cache Software visible cache • mode selection (WT, WB etc) • block flush • block invalidate • block prefetch Anshul Kumar, CSE IITD
Replacement Policies • Least Recently Used (LRU) • Least Frequently Used (LFU) • First In First Out (FIFO) • Random Anshul Kumar, CSE IITD
Write Policies • Write Hit • Write Back • Write Through • Write Miss • Write Back • Write Through • With Write Allocate • With No Write Allocate Anshul Kumar, CSE IITD
Write Policies Write Through (WT) Write Back (WB) • Write into memory now • Consistence maintained • Reduced block traffic • Word traffic introduced • Better for smaller cache/ higher miss rate • Write into memory later • No consistence • Higher block traffic • No word traffic • Better for larger cache/ low miss rate Anshul Kumar, CSE IITD
Looking deeper : Write Hit Write in cache+mem Write in cache only Write in mem only Write Through (WT) Write Back (WB) Does not make sense Anshul Kumar, CSE IITD
Write Through Write Allocate (WTWA) Write Through No Write Allocate (WTNWA) Looking deeper : Write Miss Allocate missing block and write in cache yes no yes Write in mem Write Back (WB) Does not make sense no Anshul Kumar, CSE IITD
Write Policies :Common combinations Write Miss WB WTWA WTNWA WB Write Hit WT Anshul Kumar, CSE IITD
Write Policies: Timings • Timings as seen on the bus • depends on the amount of data transferred (number of blocks and/or words) • Timings as seen by the CPU • can be minimized by using a buffer Anshul Kumar, CSE IITD
Write Policies :Bus times in Write Hit Write Miss WB WTWA WTNWA 0 0 0 WB Write Hit Tw Tw Tw WT Anshul Kumar, CSE IITD
Write Policies :Bus times in Read Miss Write Miss WB WTWA WTNWA Tb + Tb + Tb + WB Tb (1-Pc) Tb (1-Pc) Tb (1-Pc) Write Hit Tb + Tb Tb WT Tb (1-Pc) Anshul Kumar, CSE IITD
Write Policies :Bus times in Write Miss Write Miss WB WTWA WTNWA Tb + Tb + WB Tw Tw Tb (1-Pc) Tb (1-Pc) Write Hit Tb + Tb + Tw Tw WT Tb (1-Pc) Anshul Kumar, CSE IITD
Analyzing Write Policies:CPU time Policy Read Read Write Write hit miss hit miss Hit:WB, Miss: WB 1 Tb + i 1 1 Hit:WB, Miss: WTWA 1 Tb + i 1 1 Hit:WB, Miss: WTNWA 1 Tb + i 1 1 Hit:WT, Miss: WB 1 Tb + i 1 1 Hit:WT, Miss: WTWA 1 Tb + i 1 1 Hit:WT, Miss: WTNWA 1 Tb + i 1 1 i depends on read policy
Analyzing Write Policies:Bus time Policy Read Read Write Write hit miss hit miss Hit:WB, Miss: WB 0 Tb (2-Pc) 0 Tb(2-Pc) Hit:WB, Miss: WTWA 0 Tb (2-Pc) 0 Tb(2-Pc)+Tw Hit:WB, Miss: WTNWA 0 Tb (2-Pc) 0 Tw Hit:WT, Miss: WB 0 Tb (2-Pc) Tw Tb(2-Pc) Hit:WT, Miss: WTWA 0 Tb Tw Tb+Tw Hit:WT, Miss: WTNWA 0 Tb Tw Tw Anshul Kumar, CSE IITD
More Choices for Write Miss-WT Fetch on Write yes no Fetch on Write Write Validate yes Tb + Tw Tw Write Allocate Write Around Does not make sense no Anshul Kumar, CSE IITD
More Choices for Write Miss-WT Fetch on Write Direct mapped cache Write before hit yes no Fetch on Write Write Validate no yes Rewrite (cache) Rewrite (cache) yes Write Allocate Write Around no Does not make sense no Write invalidate yes Anshul Kumar, CSE IITD
Write Miss-WT Choices(no write before hit) Write Allocate, Fetch on Write • Allocate a block in cache • Fetch contents from mem • Write word in cache • Write word in mem No Write Allocate, No Fetch on Write • Write word in mem only Write Allocate, No Fetch on Write • Allocate a block in cache, mark all invalid • Write word in cache, mark it valid • Write word in mem Anshul Kumar, CSE IITD
Write Miss-WT Choices(write before hit) Write Allocate, Fetch on Write • Allocate a block in cache • Fetch contents from mem • Re-write word in cache • Write word in mem No Write Allocate, No Fetch on Write • Invalidate word in cache, write in mem Write Allocate, No Fetch on Write • Allocate a block in cache, mark all invalid • Re-write word in cache, mark it valid • Write word in mem Anshul Kumar, CSE IITD