Question
You are designing meal plan software for a small universitys residence hall, Gopher Hall. It has 4 floors with 8 rooms on each floor. The
You are designing meal plan software for a small universitys residence hall, Gopher Hall. It has 4 floors with 8 rooms on each floor. The software will run on a machine with a 256-byte direct-mapped data cache with 32-byte blocks. You are implementing a prototype of your software that records the meal expenses (Breakfast, Lunch, and Dinner) for each student in the dormitory each day. The C structures you are using are:
struct meal_expense {
float meals[3];
int student_ID;
}
struct meal_expense Gopher_Hall [4][8];
int i, j, k;
You have to decide between two alternative implementations of the routine that initialized the array Gopher_Hall. You want to choose the one with the better cache performance. You can assume:
sizeof(int) = 4
Gopher_Hall begins at memory address 0x0
The cache is initially empty
The only memory accesses are to the entries of the array Gopher_Hall
Variables i, j, k are stored in registers
Parts (a)-(c) below refer to the following code:
for (i=0; i<4; i++) {
for (j=0; j<8; j++) {
Gopher_Hall[i][j].student_ID = 0;
}
}
for (i=0; i<4; i++) {
for (j=0; j<8; j++) {
for (k=0; k<3; k++) {
Gopher_Hall[i][j].meals[k] = 0;
}
}
}
What is the total number of misses in the first loop
What is the total number of misses in the second loop?
What is the overall miss rate for writes to Gopher_Hall?
What is the cache miss rate in the following code? Show your work.
for (i=0; i<4; i++) {
for (j=0; j<8; j++) {
for (k=0; k<3; k++) {
Gopher_Hall[i][j].meals[k] = 0;
}
Gopher_Hall[i][j].student_ID = 0;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started