
Concept explainers
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 = _____________ %

Step by stepSolved in 1 steps

- Just the default matrix (2D vector)arrow_forwardJAVA CODE PLEASE Functions with 2D Arrays Quiz by CodeChum Admin Write a program that asks the user for the row and column size of a 2D array and asks the user for the elements. Write the total of the sum of each row multiplied with the row number. Example: 1 2 3 -> (1+2+3) * 1 = 6 4 5 6 -> (4+5+6) * 2 = 30 7 8 9 -> (7+8+9) * 3 = 72 total: 108 Input 1. One line containing an integer for the number of rows 2. One line containing an integer for the number of columns 3. Multiple lines containing an integer for every element of the array for each line Output Row·size:·3 Column·size:·3 R1C1:·1 R1C2:·2 R1C3:·3 R2C1:·4 R2C2:·5 R2C3:·6 R3C1:·7 R3C2:·8 R3C3:·9 1·2·3 4·5·6 7·8·9arrow_forwardStudent* func () { unique ptr arr[] make_unique ("CSC340") }; // #1 Insert Code int main () ( // #2 Insert Code [ #1 Insert Code]: Write code to keep all the object(s) which element(s) of array arr owns alive outside of the scope of func. [#2 Insert Code]: Write code to have a weak_ptr monitor the object which survived; Then test if it has any owner; Then properly destroy it; Then test again if has any owner; Then destroy the Control Block.arrow_forward
- C++arrow_forwarddef large_matrix(matrix: list[list[int]]) -> int:"""Returns the area of the rectangle in the area of a rectangle is defined by number of 1's that it contains.The matrix will only contain the integers 1 and 0.>>> case = [[1, 0, 1, 0, 0],... [1, 0, 1, 1, 1],... [1, 1, 1, 1, 1],... [1, 0, 0, 1, 0]]>>> largest_in_matrix(case1)6"" You must use this helper code: def large_position(matrix: list[list[int]], row: int, col: int) -> int: a = rowb = colmax = 0temp = 0rows = len(matrix)column = len(matrix[a])while a < rows and matrix[a][col] == 1:temp = 0while b < column and matrix[a][b] == 1:temp = temp + 1b = b + 1column = ba = a + 1if (a != row+1):temp2 = temp * (a - row)else:temp2 = tempif max < temp2:max = temp2b = colreturn max """ remember: Please do this on python you should not use any of the following: dictionaries or dictionary methods try-except break and continue statements recursion map / filter import""'arrow_forwardWhat are arrays' biggest advantages? Maximum array dimensions? Structures vary from regular variable types: Demonstrate a complex data structure.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





