Question: ( 4 ) 3 M decides to make Post - its by printing yellow squares on white pieces of paper. As part of the printing

(4)3M decides to make Post-its by printing yellow squares on white pieces of
paper. As part of the printing process, they need to set the CMYK (cyan,
magenta, yellow, black) value for every point in the square. 3M hires you
to determine the efficiency of the following algorithms on a machine with a
2,048-byte direct-mapped data cache with 32-byte blocks. You are given the
following definitions:
1 struct point color {
2 int c;
3 int m;
4 int y;
5 int k;
};
6 struct point color square[16][16];
7 int i, j;
Assume the two functions are executed under the following conditions:
sizeof(int)=4
square begins at memory address 0.
The cache is initially empty.
The only memory accesses are to the entries of the array square. Vari-
ables i and j are stored in registers.
A.[1+4+1]
1 for (i =0; i <16; i++){
2 for (j =0; j <16; j++){
3 square[i][j].c =0;
4 square[i][j].m =0;
5 square[i][j].y =1;
6 square[i][j].k =0;
7}
8}
(a) What is the total number of writes? Explain.
(b) What is the total number of writes that miss in the cache? Explain.
(c) What is the miss rate? Explain.
4
B.[1+4+1]
1 for (i =0; i <16; i++){
2 for (j =0; j <16; j++){
3 square[i][j].y =1;
4}
5}
6 for (i =0; i <16; i++){
7 for (j =0; j <16; j++){
8 square[i][j].c =0;
9 square[i][j].m =0;
10 square[i][j].k =0;
11}
12}
(a) What is the total number of writes? Explain.
(b) What is the total number of writes that miss in the cache? Explain.
(c) What is the miss rate? Explain

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!