1. Recall the example involving cache reads of a two-dimensional array (p. 24). How do a larger matrix and a larger cache affect the performance of the two pairs of nested loops? What happens if MAX = 8 and the cache can store four lines? How many misses occur in the reads of A in the first pair of nested loops? How many misses occur in the second pair?
Added by Benjamin J.
Step 1
A two-dimensional array is typically stored in a row-major order, meaning that elements of each row are stored in contiguous memory locations. The cache is organized into lines (or blocks), and each line can hold a certain number of bytes of data. Show more…
Show all steps
Your feedback will help us improve your experience
Sri K and 59 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
int x = 0, y = 0; // The compiler puts x in r1 and y in r2. int i; // The compiler put i in r3. int A[4096]; // A is in memory at address 0x10000 ... for (i = 0; i < 1024; i++) { x += A[i]; } for (i = 0; i < 1024; i++) { y += A[i + 2048]; } Assume that the system has an 8192-byte, direct-mapped data cache with 32-byte blocks. Assuming that the cache starts out empty, what is the series of data cache hits and misses for this snippet of code? Assume that ints are 32-bits. (3 points) Assume that an iteration of a loop in which the load hits takes 10 cycles but that an iteration of a loop in which the load misses takes 200 cycles. What is the execution time of this snippet with the aforementioned cache? (3 points) Repeat part (I.) except assume that the cache is 2-way set associative with an LRU replacement policy and 32-byte sets (8-byte blocks). (3 points) Repeat part (II.) using the cache described in part (III.). Is the direct-mapped or the set-associative cache better? (3 points)
Sri K.
Akash M.
2. A 2-way set associative cache system consists of 8 blocks. The main memory has 2048 blocks of 16 bytes each (byte addressable). The access time of the cache is 20 ns, and the time required to fill a cache block is 600 ns. Note that the method Load Through is used. Initially, the cache is empty. Assume that the least recently used (LRU) replacement algorithm is used. (a) Show the format of the memory address. (b) The computer will execute a program that loops 20 times from locations (addresses) 15 to 129. Complete Table 2 for the program executed for the first loop. (c) Compute the cache hit rate and the effective memory access time when running the program mentioned in Part (b).
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD