Presentation is loading. Please wait.

Presentation is loading. Please wait.

EECS 370 Discussion 1 xkcd.com. EECS 370 Discussion Topics Today: – Caches!! Theory Design Examples 2.

Similar presentations


Presentation on theme: "EECS 370 Discussion 1 xkcd.com. EECS 370 Discussion Topics Today: – Caches!! Theory Design Examples 2."— Presentation transcript:

1 EECS 370 Discussion 1 xkcd.com

2 EECS 370 Discussion Topics Today: – Caches!! Theory Design Examples 2

3 EECS 370 Discussion Memory Hierarchy 3 Cache Main Memory (RAM) Disk (Hard Drive)

4 EECS 370 Discussion Memory Hierarchy Real World Example - Intel i7 4 Cache LevelSizeAccess Time L1 64 kB4 cycles L2 256 kB10 cycles L38192 kB40 cycles RAM8388608 kB200 cycles Disk 1073741824 kB20000000 cycles

5 EECS 370 Discussion Memory Hierarchy Problem: Caches are very tiny, but memory is quite large If memory accesses are totally random, caches are useless Solution: Memory accesses really aren’t random at all! 5

6 EECS 370 Discussion Memory Hierarchy Temporal Locality You are likely to access memory locations multiple times Spatial Locality You are likely to access memory locations near each other 6

7 EECS 370 Discussion Memory Hierarchy Example: int data[10]; int sum = 0; … for (int i=0; i<10; i++) { sum += data[i]; } 7

8 EECS 370 Discussion Memory Hierarchy Real World Example - Intel i7 8 Core0Core1Core2Core3

9 EECS 370 Discussion Cache Design Split Cache – portion your cache into two halves I-Cache: Instruction Cache D-Cache: Data Cache Why would we want to do this? 9

10 EECS 370 Discussion Types of Caches Fully Associative Blocks map to any cache line 10 Cache TagData Memory 0x100010 0x100420 0x100830 0x100C40 0x101050 0x101460 0x101870 0x101C80 0x102090 0x1024100 0x1028110

11 EECS 370 Discussion Types of Caches Direct Mapped Blocks map to one cache line 11 Cache TagData Memory 0x100010 0x100420 0x100830 0x100C40 0x101050 0x101460 0x101870 0x101C80 0x102090 0x1024100 0x1028110

12 EECS 370 Discussion Types of Caches Set Associative Blocks map to any line in a set 12 Cache TagData Memory 0x100010 0x100420 0x100830 0x100C40 0x101050 0x101460 0x101870 0x101C80 0x102090 0x1024100 0x1028110

13 EECS 370 Discussion Types of Caches Set Associative Sets = Cache Lines / Ways 13 Cache TagData Cache TagData Cache TagData Cache TagData 1-Way 2-Way 3-Way 6-Way

14 EECS 370 Discussion Three C’s There are three reasons a cache miss occurs 1)Compulsory – never been loaded before 2)Capacity – evicted due to small cache size 3)Conflict – evicted due to overlap with another block 14

15 EECS 370 Discussion Cache Addressing Addresses split into: 15 TagSet IndexBlock Offset log 2 (Block Size) log 2 (Number of Sets) Remaining Bits

16 EECS 370 Discussion Cache Writing Policy For Writes Only On misses: Write Allocate – add to cache No Write Allocate – don’t add to cache On hits: Write Through – always write to memory Write Back – only write to cache 16

17 EECS 370 Discussion Caches Cache Examples 17

18 EECS 370 Discussion Block size = 1 Word, Address = 16 bits 2-way Set Associative 18 Cache TagData Memory 0x100010 0x100420 0x100830 0x100C40 0x101050 0x101460 0x101870 0x101C80 0x102090 0x1024100 0x1028110 0x102C120

19 EECS 370 Discussion Caches Cache Examples Options: – Type of Cache – Cache Size – Block Size – Address Bits – Write Policy 19


Download ppt "EECS 370 Discussion 1 xkcd.com. EECS 370 Discussion Topics Today: – Caches!! Theory Design Examples 2."

Similar presentations


Ads by Google