computer architecture cache model john morris

6
Computer Architecture Cache Model John Morris Electrical & Computer Enginering/ Computer Science, The University of Auckland Iolanthe II drifts off Waiheke Island

Upload: alika-hays

Post on 01-Jan-2016

25 views

Category:

Documents


0 download

DESCRIPTION

Computer Architecture Cache Model John Morris Electrical & Computer Enginering/ Computer Science, The University of Auckland. Iolanthe II drifts off Waiheke Island. 32. Cache Model. Cache size: 64 kbytes = 2 16 bytes Word size: 4 = 2 2 bytes = 32 bits Direct mapped cache - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Computer Architecture Cache Model John Morris

Computer Architecture

Cache Model

John MorrisElectrical & Computer Enginering/Computer Science, The University of Auckland

Iolanthe II drifts off Waiheke Island

Page 2: Computer Architecture Cache Model John Morris

Cache Model

• Cache size: 64 kbytes = 216 bytes• Word size: 4 = 22 bytes = 32 bits• Direct mapped cache• Number of lines = 216/22 = 214 = 16384• 2 bits: byte within a word• 14 bits: address of line• 32-14-2 = 16 bits: tag

32

216 14

Page 3: Computer Architecture Cache Model John Morris

Cache Model

• Cache size: 64 kbytes = 216 bytes• Word size: 4 bytes = 32 bits• Line size: 32 = 25 bytes• Set associative cache

• Number of ways = 8• Number of lines = 216/25 = 211 = 2048• Number of sets = 211/23 = 28 = 256• 5 bits: byte within a line• 8 bits: address of set• 32-8-5 = 19 bits: tag

32

519 8

Page 4: Computer Architecture Cache Model John Morris

Cache - Conflicts

• Conflicts• Two addresses

separated by 2k+m

will hit the same cache location

p-k-m mk

p bits

tag cache address byte address

Addresses in which these k bitsare the same will map to the same

cache line

Page 5: Computer Architecture Cache Model John Morris

Cache Model

• Cache size: 64 kbytes = 216 bytes• Word size: 4 bytes = 32 bits• Line size: 32 = 25 bytes• Set associative cache

• Number of ways = 8• Number of lines = 216/25 = 211 = 2048• Number of sets = 211/23 = 28 = 256• 5 bits: byte within a line• 8 bits: address of set• 32-8-5 = 19 bits: tag

32

519 8

Step size for conflicts28+5 = 8192 bytes

Page 6: Computer Architecture Cache Model John Morris

Cache Model – Performance pitfalls

• n-way set associative cachetolerates n conflicts at steps of 2k+m bytes through memory

• Avoid data structures with elements of this sizeeg matrices with rows of 2k+m bytes

Example: matrices with float (4 byte) elements

28+5 / 4 = 2048 elements 2048 element arrays may show poor

performance and are best avoided

Similarly 1024 element arrays of doubles (8 bytes) may process slowly

Using cache onprevious slide:Step size for conflicts28+5 = 8192 bytes