1. In this question, we consider the relative performance obtained by running a particular program with...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. In this question, we consider the relative performance obtained by running a particular program with various caches installed between the memory and the CPU. Consider the following C function: char a[512], b[512] add_arrays () { register int i; } for (i = 0; i < 511; i =i+1) { a[i+1] = a[i] + b[i]; // Work!! } (The register keyword tells the C compiler to reserve a register for the variable i; let's assume it keeps i in RO. What does this mean for us? The variable i is not stored in main memory- it's stored in the CPU; this mean that it never has to be pulled from main memory into the cache when the CPU accesses it. The char keyword allocates character arrays at fixed locations in memory, using 1 byte per character.) Recall that in C, an array is a contiguous chunk of memory. Therefore, in this code, array a starts at some address (say, 0x00A), and ends at hstart addressi + n-sizeof(char) address, where n is the number of elements and sizeof(char) is the number of bytes a char takes in memory (and in this example, we're using char because it's 1 byte and makes calculating simple!). For the following questions, assume that the memory can read or write 1 byte at a time. (a) Suppose, when the code is actually run, the array a starts at physical memory address 0x0100, and b is right after (that is, adjacent to) a in memory. What are the physical addresses of the first 5 elements of a? The first 5 elements of b? (b) Suppose that the CPU is directly connected to the data memory (no cache is used) and that the access time of the memory is 100ns. How many nanoseconds of the above instruction's execution will be spent waiting for memory? Explain your answer (c) Suppose that a 512-byte fully-associative cache with the following characteristics is inserted between the CPU and the data memory. • A cache hit has an access time of 20 ns. • A cache miss requires 120ns. • A write-through strategy is used, with 120 ns for each data write. • A least-recently-used strategy is used to manage the cache. • The cache is initially empty before the program begins. Does the cache help any? If so, on average, what is the new "memory overhead" (time spent waiting for memory) for this instruction? Explain/show your work. (d) Suppose a 256-byte cache is used. Will the cache be useful? What is the smallest LRU fully-associative cache that would still be useful? Explain your answer. (e) Suppose that we insert a 512-byte direct-mapped cache between the CPU and the data memory. Assume the cache timing specifications of part (c). Assume that arrays a and b are adjacent in data memory. Does this cache help any? What is the average memory overhead now for this instruction? Explain. (f) Suppose we use a 2-way, 256-set (that is, 512-byte) set-associative cache with a block size of 1 byte. The timing specifications are the same as in Part (c). A quasi-LRU replacement strategy is used, replacing the least recently used element within the set. Does this cache help any? What is the average memory overhead now for this instruction? Explain. Question 2: Will a four-way set-associative cache capable of holding 1K data bytes always have a better hit ratio than a direct-mapped cache capable of holding 1K data bytes? Explain. 1. In this question, we consider the relative performance obtained by running a particular program with various caches installed between the memory and the CPU. Consider the following C function: char a[512], b[512] add_arrays () { register int i; } for (i = 0; i < 511; i =i+1) { a[i+1] = a[i] + b[i]; // Work!! } (The register keyword tells the C compiler to reserve a register for the variable i; let's assume it keeps i in RO. What does this mean for us? The variable i is not stored in main memory- it's stored in the CPU; this mean that it never has to be pulled from main memory into the cache when the CPU accesses it. The char keyword allocates character arrays at fixed locations in memory, using 1 byte per character.) Recall that in C, an array is a contiguous chunk of memory. Therefore, in this code, array a starts at some address (say, 0x00A), and ends at hstart addressi + n-sizeof(char) address, where n is the number of elements and sizeof(char) is the number of bytes a char takes in memory (and in this example, we're using char because it's 1 byte and makes calculating simple!). For the following questions, assume that the memory can read or write 1 byte at a time. (a) Suppose, when the code is actually run, the array a starts at physical memory address 0x0100, and b is right after (that is, adjacent to) a in memory. What are the physical addresses of the first 5 elements of a? The first 5 elements of b? (b) Suppose that the CPU is directly connected to the data memory (no cache is used) and that the access time of the memory is 100ns. How many nanoseconds of the above instruction's execution will be spent waiting for memory? Explain your answer (c) Suppose that a 512-byte fully-associative cache with the following characteristics is inserted between the CPU and the data memory. • A cache hit has an access time of 20 ns. • A cache miss requires 120ns. • A write-through strategy is used, with 120 ns for each data write. • A least-recently-used strategy is used to manage the cache. • The cache is initially empty before the program begins. Does the cache help any? If so, on average, what is the new "memory overhead" (time spent waiting for memory) for this instruction? Explain/show your work. (d) Suppose a 256-byte cache is used. Will the cache be useful? What is the smallest LRU fully-associative cache that would still be useful? Explain your answer. (e) Suppose that we insert a 512-byte direct-mapped cache between the CPU and the data memory. Assume the cache timing specifications of part (c). Assume that arrays a and b are adjacent in data memory. Does this cache help any? What is the average memory overhead now for this instruction? Explain. (f) Suppose we use a 2-way, 256-set (that is, 512-byte) set-associative cache with a block size of 1 byte. The timing specifications are the same as in Part (c). A quasi-LRU replacement strategy is used, replacing the least recently used element within the set. Does this cache help any? What is the average memory overhead now for this instruction? Explain. Question 2: Will a four-way set-associative cache capable of holding 1K data bytes always have a better hit ratio than a direct-mapped cache capable of holding 1K data bytes? Explain.
Expert Answer:
Answer rating: 100% (QA)
a Since array a starts at physical memory address 0x0100 the addresses of the first 5 elements of a are 0x0100 element a0 0x0101 element a1 0x0102 element a2 0x0103 element a3 0x0104 element a4 Since ... View the full answer
Related Book For
Computer Networking A Top-Down Approach
ISBN: 978-0136079675
5th edition
Authors: James F. Kurose, Keith W. Ross
Posted Date:
Students also viewed these banking questions
-
In this question we study the recursively defined functions f, g and h given by the following defining equations f(0) = 1 base case 0, f(1) = 0 base case 1, and f(n) = n f(n 1) + f(n 2)^2...
-
In this question we will use the sentences you wrote in Exercise 9.9 to answer a question using a backward-chaining algorithm. a. Draw the proof tree generated by an exhaustive backward-chaining...
-
In this question we consider derivation of the C, statistic for model selection discussed in lectures. Consider fitting the proposed general linear model and write ; for the fitted value at r; and...
-
The unadjusted trial balance of Mesa Inc., at the company's year end of December 31 follows: Additional information and adjustment data: 1. The 12-month insurance policy was purchased and was...
-
The HELP partnership has the following capital balances as of the end of the current year: Lennon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $230,000 McCartney . . . . . . ....
-
For fiscal year 2011, Peets Coffee and Tea (PEET) had a net profit margin of 4.78%, asset turnover of 1.73, and a book equity multiplier of 1.21. a. Use this data to compute Peets ROE using the...
-
The Miller Company purchased a new headquarters building on January 1 at a comme cost of \($40\) million. The building is expected to last 20 years, at which time its residual value is expected to be...
-
A brass rod 100 mm long and 5 mm in diameter extends horizontally from a casting at 200e. The rod is in an air environment with T = 20C and h = 30 W/m2 K. What is the temperature of the rod 25, 50,...
-
Hartford Case Study Questions Case Study Questions for Dunkin' Donuts Park 1. What would have been the benefits if the city stuck to its original plan and only issued bonds to finance the Dillion...
-
TourneSol Canada, Ltd. is a producer of high quality sunflower oil. The company buys raw sunflower seeds directly from large agricultural companies, and refines the seeds into sunflower oil that it...
-
Explain how you would use the concepts of compounding present value future value annuitization andor amortization if you were a Financial Consultant evaluating the needs of a company that has 1000...
-
Bill can finish a report in 2 hours. Maria can finish the same report in 4 hours. How long will it take them to finish the report if they work together?
-
5. A. Please rearrange the light bulks from high temperature to low temperature. 3. B. Why is this the right order? C. If you have a green light bulk, its temperature is between which two lights?
-
What is the TOTAL PRODUCTION COST? Budgeted output for the year 9800 units Standard details for one unit: Direct materials 40 square metres at 5.30 per square metre Direct wages: Bonding department...
-
4. As a scientist who was doing research on a newly found bacteria, you investigated the growth rate of the bacteria hourly. With a, a2, a3, a4 representing the population of the bacteria after the...
-
Discuss the potential risk associated the use of cloud computing in organizational information technology systems. How can these risks be mitigated in principle of management
-
MAINTENANCE PLAN - PROJECT Develop a maintenance plan for an Industrial Facility in the following conditions: 1) Within the idealized installation, equipment that will go through Maintenance must be...
-
Prove the following D,(cos x) = - sin x (Hint: Apply the identity cos(A + B) = cos A cos B sin A sin B)
-
Suppose Host A wants to send a large file to Host B. The path from Host A to Host B has three links, of rates RI =500 kbps, R2 =2 Mbps, and R) = I Mbps. a. Assuming no other traffic in the network,...
-
Figures 7.1 and 7.2 present two schemes for streaming stored media. What are the advantages and disadvantages of each scheme?
-
What are some typical compression ratios (ratio of the number of bits in an uncompressed object to the number of bits in the compressed version of that object) for image and audio applications, and...
-
Eaton Company issued \(\$ 600,000\) of eight percent, 20 -year bonds at 106 on January 1, 2013. Interest is payable semiannually on July 1 and January 1. Through January 1, 2019, Eaton amortized \(\$...
-
Zealand Company sells a motor that carries a 3-month unconditional warranty against product failure. Based on a reliable statistical analysis, Milford knows that between the sale and the end of the...
-
On December 31, 2016, Clarke, Inc. borrowed \(\$ 900,000\) on a seven percent, 10 -year mortgage note payable. The note is to be repaid in equal annual installments of \(\$ 128,140\) (payable on...
Study smarter with the SolutionInn App