1 / 24

Chapter 6 The Memory Hierarchy

Chapter 6 The Memory Hierarchy. Jin Lu 11210240054@fudan.edu.cn. Problem 6.1 (p.460). In a DRAM array r : the number of rows c : the number of columns b r : the number of bits needed to address the rows b c : the number of bits needed to address the columns

melia
Download Presentation

Chapter 6 The Memory Hierarchy

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 6 The Memory Hierarchy Jin Lu 11210240054@fudan.edu.cn

  2. Problem 6.1 (p.460) In a DRAM array r : the number of rows c : the number of columns br: the number of bits needed to address the rows bc: the number of bits needed to address the columns Target : minimizing max(br, bc) Organization r c br bc max(br, bc) 16*1 16*4 128*8 512*4 1024*4 4 4 2 2 2 4 4 2 2 2 16 8 4 3 4 32 16 5 4 5 32 32 5 5 5

  3. Problem 6.2 (p.468) • What is the capacity of a disk with 2 platters, 10,000 cylinders, an average of 400 sectors per track, and 512 bytes per sector. 10000 * 400 * 512 * (2 * 2) = 8.192 (GB)

  4. Problem 6.3 (p.471) Tavg rotation = 1/2 * Tmax rotation =1/2*(60 secs/15000 RPM) * 1000 ms/sec Tavg transfer = (60 secs/15000 RPM) * 1/500 sectors/track * 1000 ms/sec • Estimate the average time (in ms) to access a sector on the following disk: Parameter Value Rotational rate15,000 RPM Tavg seek8 ms Average #sectors/track500 Taccess = Tavg seek + Tavg rotation + Tavg transfer

  5. Problem 6.4 (p.481) • Permute the loops the following function so that it scans the three-dimensional array a with a stride-1 reference pattern. int sumarray3d(int a[N][N][N]){ int i,j,k,sum = 0; for(i = 0; i < N; i++) //k for(j = 0; j < N; j++) //i for(k = 0; k < N; k++) //j sum += a[k][i][j]; }

  6. Problem 6.5 (p.482) • The three functions in Figure 6.20(next page) perform the same operation with varying degrees of spatial locality. Rank-order the functions with respect to the spatial locality enjoyed by each. Explain how you arrived at your ranking.

  7. Problem 6.6 (p.490) • The table gives the parameters for a number of different caches. For each cache, determine the number of cache sets(S), tag bits(t), set index bits(s), and block offset bits(b). Cache m C B E S t s b 1. 32 1024 4 1 2. 32 1024 8 4 3. 32 1024 32 32

  8. Problem 6.7 (p.496) • In the previous dotprod example, what fraction of the total references to x and y will be hits once we have padded array x? float dotprod(float x[8], float y[8]){ float sum = 0.0; int i; for(i = 0; i < 8; i++) sum += x[i] * y[i]; return sum; } Cache info: B=16bytes S=2 E=1 float x[12];?

  9. Problem 6.8 (p.496) • In general, if the high-orders bits of an address are used as the set index, contiguous chunks of memory blocks are mapped to the same cache set. • A. How many blocks are in each of these contiguous array chunks? • B. What is the maximum number of array blocks that are stored in the cache at any point in time? 2t cache info: (S, E, B, m) = (512, 1, 32, 32) codes: int array[4096]; for(i = 0; i < 4096; i++) sum+=array[i]; 1

  10. Problem 6.9 (p.501) Assume: • The memory is byte addressable. • Memory accesses are to 1-byte words(not to 4-byte words). • Addresses are 13 bits wide. • The cache is 2-way set associative (E=2), with a 4-byte block size (B=4) and 8 sets (S=8). The format of an address(one bit per box). CO The cache block offerset CI The cache set index CT The cache tag Please label the diagram with CX:

  11. Problem 6.10 (p.502) • Suppose a program running on the machine in Problem 6.9 references the 1-byte word at address 0x0E34. • A. Address format(one bit per box): • B. Memory reference: CO CI CT hit? return? 0x0 0x5 0x71 Y 0xB

  12. Problem 6.11 (p.502) • Repeat Problem 6.10 for memory address 0x0DD5.

  13. Problem 6.12 (p.502) • Repeat Problem 6.10 for memory address 0x1FE4.

  14. Problem 6.13 (p.502) • For the cache in Problem 6.9, list all of the hex memory addresses that will hit in Set 3. 0 0110 0100 11xx

  15. Problem 6.14 (p.509) Properties: • sizeof(int) == 4. • src starts at address 0, and dst follows. • There is a single L1 d-cache that is direct-mapped, write-through, and write-allocate, with a block size of 8 bytes. • The cache has a total size of 16 data bytes and the cache is initially empty. • Accesses to the src and dst arrays are the only sources of read and write misses, respectively. typedef int array[2][2]; void transpose1(array dst, array src){ int i, j; for(i = 0; i < 2; i++) for(j = 0; j < 2; j++) dst[j][i] = src[i][j]; } • A. Fill the following tables: • B. Repeat for a cache with 32 data bytes.

  16. Problem 6.15a (p.510) • The heart of the recent hit game SimAquarium is a tight loop that calculates the average position of 256 algae. You are evaluating its cache performance on a machine with a 1024-byte direct-mapped d-cache with 16-byte blocks(B=16). You are given the following definitions: struct algae_position{ int x; int y; }; struct algae_position grid[16][16]; int total_x = 0, total_y = 0; int i, j; Assume: • sizeof(int) == 4; • grid begins at memory address 0; • The cache is initially empty; • The only memory accesses are to the entries of the array grid. Variables i, j, total_x, and total_y are stored in registers.

  17. Problem 6.15b (p.510) Determine the cache performance for the following code: for(i = 0; i < 16; i++) for(j = 0; j < 16; j++) total_x += grid[i][j].x; for(i = 0; i < 16; i++) for(j = 0; j < 16; j++) total_y += grid[i][j].y; • A. What is the total number of reads? • B. What is the total number of reads that miss in the cache? • C. What is the miss rate? 512 256 0.5

  18. Problem 6.16 (p.511) Given the assumptions of Problem 6.15. for(i = 0; i < 16; i++) for(j = 0; j < 16; j++){ total_x += grid[j][i].x; total_y += grid[j][i].y; } • A. What is the total number of reads? • B. What is the total number of reads that miss in the cache? • C. What is the miss rate? • D. What would the miss rate be if the cache were twice as big? 512 256 0.5 0.25

  19. Problem 6.17 (p.511) Given the assumptions of Problem 6.15. for(i = 0; i < 16; i++) for(j = 0; j < 16; j++){ total_x += grid[i][j].x; total_y += grid[i][j].y; } • A. What is the total number of reads? • B. What is the total number of reads that miss in the cache? • C. What is the miss rate? • D. What would the miss rate be if the cache were twice as big? 512 128 0.25 0.25

  20. Problem 6.18 (p.516) • The memory mountain in Figure 6.42 has two axes: stride and working set size. Which axis corresponds to spatial locality? And temporal locality?

  21. Problem 6.19 (p.516) • Using the memory mountain in Figure 6.42, estimate the time, in CPU cycles, to read a 4-byte word from: A. The on-chip L1 d-cache. B. The off-chip L2 cache. C. Main memory.(Assume that the read throughput at (size = 16M, stride=16) is 80MB/s.)

  22. Thank you!

More Related