60 likes | 150 Views
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
E N D
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 = 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 16 14 2
32 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 19 5 8
Cache - Conflicts • Conflicts • Two addresses separated by 2k+mwill hit the same cache location p bits p-k-m k m cache address tag byte address Addresses in which these k bitsare the same will map to the samecache line
32 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 Step size for conflicts 28+5 = 8192 bytes 19 5 8
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 size eg 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 conflicts 28+5 = 8192 bytes