We have a 1024 byte cache that is direct mapped. Each line of the cache stores a
ID: 3867314 • Letter: W
Question
We have a 1024 byte cache that is direct mapped. Each line of the cache stores a 64-byte
block. We have the following structure definition:
struct object {
int a; /* uses 4 bytes of memory */
int b; /* uses 4 bytes of memory */
double c; /* uses 8 bytes of memory */
};
(a) For this code block
struct object data[192]; /* starts at memory address 0 */
int sumA = 0, sumB = 0, i; /* these are stored in registers */
double sumC = 0; /* this is stored in a register */
for(i = 0; i < 192; i++)
sumA += data[i].a;
for(i = 0; i < 192; i++)
sumB += data[i].b;
for(i = 0; i < 192; i++)
sumC += data[i].c;
i. Determine the number of times that the cache is read.
ii. What is the cache miss rate?
(b) For this code block
struct object data[192]; /* starts at memory address 0 */
int sumA = 0, sumB = 0, i; /* these are stored in registers */
double sumC = 0; /* this is stored in a register */
for(i = 0; i < 192; i++) {
sumA += data[i].a;
sumB += data[i].b;
sumC += data[i].c;
}
i. Determine the number of times that the cache is read.
ii. What is the cache miss rate?
Explanation / Answer
a.)for each loop the cache is accessed for everytime the loop runs
i.)each loop runs 192 times . 3 loops are there. so 3*192=576 times cache will be accessed.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.