23 the ubiquity of caching in modern computer systems

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: there is no spatial locality with respect to sum. 296 1 2 3 4 5 6 7 8 CHAPTER 6. THE MEMORY HIERARCHY int sumvec(int v[N]) { int i, sum = 0; for (i = 0; i < N; i++) sum += v[i]; return sum; } Address Contents Access order 0 Ú¼ 4 Ú½ 8 Ú¾ 12 Ú¿ 16 Ú 20 Ú 24 Ú 28 Ú 1 2 3 4 5 6 7 8 (a) (b) ). Notice how Figure 6.17: (a) A function with good locality. (b) Reference pattern for vector v (Æ the vector elements are accessed in the same order that they are stored in memory. As we see in Figure 6.17(b), the elements of vector v are read sequentially, one after the other, in the order they are stored in memory (we assume for convenience that the array starts at address 0). Thus, with respect to variable v, the function has good spatial locality, but poor temporal locality since each vector element is accessed exactly once. Since the function has either good spatial or temporal locality with respect to each variable in the loop body, we can conclude that the sumvec function enjoys good locality. A function s...
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