4. 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: 1 char a [512], b[512] 3 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 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. let's assume 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 (start address) +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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
4. 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!!
}
9 }
(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 (start address) + 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.
Transcribed Image Text:4. 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!! } 9 } (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 (start address) + 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.
(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.
Transcribed Image Text:(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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education