Question
Consider a direct mapped cahce of size 64K with block size of 16 bytes. Furthermore, the cache is write-back and write-allocate. You will calculate the
Consider a direct mapped cahce of size 64K with block size of 16 bytes. Furthermore, the cache is write-back and write-allocate. You will calculate the miss rate for the following code using this cache. Remember that sizeof(int) == 4. Assume that the cache starts empty and that local variables and computations take place completely within the registers and do not spill onto the stack.
A. Now consider the following code to copy one matrix to another. Assume that the src matrix starts at address 0 and that the dest matrix immediately follows it.
void copy_matrix(int dest[ROWS][COLS], int src[ROWS][COLS])
{
int i, j;
for (i=0; i < ROWS; i++) {
for (j=0; j < COLS; j++ {
dest[i][j] = src[i][j];
}
}
}
1. What is the cache miss rate if ROWS = 128 and COLS = 128?
2. What is the cache miss rate if ROWS = 128 and COLS = 192?
3. What is the cache miss rate if ROWS = 128 and COLS = 256?
B. Now consider the following two implementations of a horizontal flip and copy of the matrix. Again assume that the src matrix starts at address 0 and that the dest matrix follows immediately after it.
void copy_n_flip_matrix1(int dest[ROWS][COLS], int src[ROWS][COLS])
{
int i, j;
for (i=0; i < ROWS: i++) {
for (j=0; j < COLS; j++) {
dest[i][COLS - 1 - j] = src[i][j];
}
}
}
1. What is the cache miss rate if ROWS = 128 and COLS = 128?
2. What is the cache miss rate if ROWS = 128 and COLS = 192?
void copy_n_flip_matrix2(int dest[ROWS][COLS], int src[ROWS][COLS])
{
int i, j;
for (j=0; j < COLS: j++) {
for (i=0; i < ROWS; i++) {
dest[i][COLS - 1 - j] = src[i][j];
}
}
}
1. What is the cache miss rate if ROWS = 128 and COLS = 128?
2. What is the cache miss rate if ROWS = 192 and COLS = 128?
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