A line is a container in a cache that stores a block

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: om in the cache to hold the blocks for both x[i] and y[i], each reference results in a conflict miss because the blocks map to the same cache set. It is not unusual for this kind of thrashing to result in a slowdown by a factor of 2 or 3. And be aware that even though our example is extremely simple, the problem is real for larger and more realistic direct-mapped caches. Luckily, thrashing is easy for programmers to fix once they recognize what is going on. One easy solution is to put bytes of padding at the end of each array. For example, instead of defining x to be float x[8], we define it to be float x[12]. Assuming y starts immediately after x in memory, we have the following mapping of array elements to sets: Element x[0] x[1] x[2] x[3] x[4] x[5] x[6] x[7] Address 0 4 8 12 16 20 24 28 Set index 0 0 0 0 1 1 1 1 Element y[0] y[1] y[2] y[3] y[4] y[5] y[6] y[7] Address 48 52 56 60 64 68 72 76 Set index 1 1 1 1 0 0 0 0 With the padding at the end of x, x[i] and y[i] now map to different sets, which eliminates the th...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online