Sean Barker
Data Storage
•Disks• Hard disk (HDD)• Solid state drive (SSD)
•Random Access Memory• Dynamic RAM (DRAM)• Static RAM (SRAM)
•Registers• %rax, %rbx, ...
1
Sean Barker
The CPU-Memory Gap
2
0.0
0.1
1.0
10.0
100.0
1,000.0
10,000.0
100,000.0
1,000,000.0
10,000,000.0
100,000,000.0
1985 1990 1995 2000 2003 2005 2010 2015
Tim
e (n
s)
Year
Disk seek time
SSD access time
DRAM access time
SRAM access time
CPU cycle time
Effective CPU cycle time
DRAM
CPU
SSD
Disk
Sean Barker
Caching
3
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
8 9 14 3Cache
MemoryLarger,slower,cheapermemoryviewedaspar@@onedinto“blocks”
Dataiscopiedinblock-sizedtransferunits
Smaller,faster,moreexpensivememorycachesasubsetof
theblocks
4
4
4
10
10
10
Sean Barker
Cache Hit
4
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
8 9 14 3Cache
Memory
Request:14
14
Sean Barker
Cache Miss
5
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
8 9 14 3Cache
Memory
Request:12
Request:12
12
12
12
Sean Barker
Locality
6
¢ Temporallocality:
¢ Spa0allocality:
Sean Barker
Locality Example (1)
7
sum = 0; for (i = 0; i < n; i++)
sum += a[i]; return sum;
Sean Barker
Locality Example (2)
8
int sum_array_rows(int a[M][N]) { int i, j, sum = 0; for (i = 0; i < M; i++) for (j = 0; j < N; j++) sum += a[i][j]; return sum; }
Sean Barker
Locality Example (3)
9
int sum_array_cols(int a[M][N]) { int i, j, sum = 0; for (j = 0; j < N; j++) for (i = 0; i < M; i++) sum += a[i][j]; return sum; }
Sean Barker
The Memory Hierarchy
10
The Memory Hierarchy
Local secondary storage (disk)
Larger Slower Cheaper per byte
Remote secondary storage (tapes, Web servers / Internet)
~100 M cycles to access
On Chip
Storage
Smaller Faster Costlier per byte
Main memory (DRAM)
~100 cycles to access
CPU instrs
can directly access
slower than local disk to access
Registers 1 cycle to access
Cache(s) (SRAM)
~10’s of cycles to access
Flash SSD / Local network
L1, L2