typedef struct {    short data[4];} MatrixElement; void copy_matrix(MatrixElement m1[], MatrixElement m2[], int ROWS, int COLS) {    int i, j, k;    for (i = 0; i < ROWS; i++) {        for (j = 0; j < COLS; j++) {            for (k = 0; k < 4; k++) {                m1[i*COLS+j].data[k] = m2[i*COLS+j].data[k];            }        }    }} void copy_matrix_transpose(MatrixElement m1[], MatrixElement m2[], int ROWS, int COLS) {    int i, j, k;    for (i = 0; i < ROWS; i++) {        for (j = 0; j < COLS; j++) {            for (k = 0; k < 4; k++) {                m1[i*COLS+j].data[k] = m2[j*ROWS+i].data[k];            }        }    }}   You can assume the following conditions: The matrix m1 is allocated at memory address 0, and matrix m2 immediately follows it. Indices i, j, and k are kept in registers. ROWS and COLS are constants. The cache is initially empty before the function call. The cache is write-back (i.e., only writes back to memory when a line is evicted) and write-allocate (i.e., it always allocates a line for the write). The cache uses a least-recently-used replacement policy. sizeof(short) == 2. Given a direct-mapped cache of size 128 bytes with a 16-byte block size, answer the following: A. What is the cache miss rate of copy_matrix if ROWS = 4 and COLS = 8? Miss rate = _____________ % B. What is the cache miss rate of copy_matrix if ROWS = 3 and COLS = 8? Miss rate = _____________ % Considering a 2-way set associated cache of the same size and block size, answer the following: C. What is the cache miss rate of copy_matrix if ROWS = 4 and COLS = 8? Miss rate = _____________ % D. What is the cache miss rate of copy_matrix_transpose if ROWS = 8 and COLS = 8? Miss rate for accessing m1 = _____________ % Miss rate for accessing m2 = _____________ %

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

typedef struct {
    short data[4];
} MatrixElement;

void copy_matrix(MatrixElement m1[], MatrixElement m2[], int ROWS, int COLS) {
    int i, j, k;
    for (i = 0; i < ROWS; i++) {
        for (j = 0; j < COLS; j++) {
            for (k = 0; k < 4; k++) {
                m1[i*COLS+j].data[k] = m2[i*COLS+j].data[k];
            }
        }
    }
}

void copy_matrix_transpose(MatrixElement m1[], MatrixElement m2[], int ROWS, int COLS) {
    int i, j, k;
    for (i = 0; i < ROWS; i++) {
        for (j = 0; j < COLS; j++) {
            for (k = 0; k < 4; k++) {
                m1[i*COLS+j].data[k] = m2[j*ROWS+i].data[k];
            }
        }
    }
}

 

You can assume the following conditions:

  • The matrix m1 is allocated at memory address 0, and matrix m2 immediately follows it.
  • Indices i, j, and k are kept in registers.
  • ROWS and COLS are constants.
  • The cache is initially empty before the function call.
  • The cache is write-back (i.e., only writes back to memory when a line is evicted) and write-allocate (i.e., it always allocates a line for the write).
  • The cache uses a least-recently-used replacement policy.
  • sizeof(short) == 2.

Given a direct-mapped cache of size 128 bytes with a 16-byte block size, answer the following: A. What is the cache miss rate of copy_matrix if ROWS = 4 and COLS = 8? Miss rate = _____________ %

B. What is the cache miss rate of copy_matrix if ROWS = 3 and COLS = 8? Miss rate = _____________ %

Considering a 2-way set associated cache of the same size and block size, answer the following: C. What is the cache miss rate of copy_matrix if ROWS = 4 and COLS = 8? Miss rate = _____________ %

D. What is the cache miss rate of copy_matrix_transpose if ROWS = 8 and COLS = 8? Miss rate for accessing m1 = _____________ % Miss rate for accessing m2 = _____________ %

 
 
 
 
Expert Solution
steps

Step by step

Solved in 1 steps

Blurred answer
Knowledge Booster
Array
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