<<

Data Storage

•Disks • Hard disk (HDD) • Solid state drive (SSD)

•Random Access Memory • Dynamic RAM (DRAM) • Static RAM (SRAM)

•Registers • %rax, %rbx, ...

Sean Barker 1

The CPU-Memory Gap

100,000,000.0

10,000,000.0 Disk 1,000,000.0

100,000.0 SSD Disk seek time 10,000.0 SSD access time 1,000.0 DRAM access time

Time (ns) Time 100.0 DRAM SRAM access time CPU cycle time 10.0 Effective CPU cycle time 1.0

0.1 CPU

0.0 1985 1990 1995 2000 2003 2005 2010 2015 Year

Sean Barker 2 Caching

Smaller, faster, more expensive 8 4 9 10 14 3 memory caches a subset of the blocks

Data is copied in -sized 10 4 transfer units

Larger, slower, cheaper memory Memory 0 1 2 3 viewed as par@@oned into “blocks” 4 5 6 7 8 9 10 11 12 13 14 15

Sean Barker 3

Cache Hit

Request: 14

Cache 8 9 14 3

Memory 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Sean Barker 4 Cache Miss

Request: 12

Cache 8 12 9 14 3

12 Request: 12

Memory 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Sean Barker 5

Locality

¢ Temporal locality:

¢ Spa0al locality:

Sean Barker 6 Locality Example (1)

sum = 0; for (i = 0; i < n; i++) sum += a[i]; return sum;

Sean Barker 7

Locality Example (2)

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 8 Locality Example (3)

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 9

The The Memory Hierarchy

Smaller On 1 cycle to access CPU Chip Registers Faster Storage Costlier instrs can L1, L2 per directly Cache(s) ~10’s of cycles to access access (SRAM)

Main memory ~100 cycles to access (DRAM) Larger Slower Flash SSD / Local network ~100 M cycles to access Cheaper Local secondary storage (disk) per byte slower Remote secondary storage than local (tapes, Web servers / ) disk to access

Sean Barker 10