Presentation is loading. Please wait.

Presentation is loading. Please wait.

Appendix C Practice Problem Set 1

Similar presentations


Presentation on theme: "Appendix C Practice Problem Set 1"— Presentation transcript:

1 Appendix C Practice Problem Set 1

2 Problem 1 1. Identify data dependencies in the code segment below. # of dependencies: ____________? i: R2  R0 + R1 j: R3  R0 * R2 k: R5  R2 – R3 l: R2  R6 – R7

3 Data Dependency # First Instruction (i, j, k) Second Instruction
i: R2  R0 + R1 j: R3  R0 * R2 k: R5  R2 – R3 l: R2  R6 – R7 Data Dependency # First Instruction (i, j, k) Second Instruction Type (RAW, WAR, WAW) Which Register? 1 i j RAW R2 2 3 4 5

4 Data Dependency # First Instruction (i, j, k) Second Instruction
i: R2  R0 + R1 j: R3  R0 * R2 k: R5  R2 – R3 l: R2  R6 – R7 Data Dependency # First Instruction (i, j, k) Second Instruction Type (RAW, WAR, WAW) Which Register? 1 i j RAW R2 2 k 3 4 5

5 Data Dependency # First Instruction (i, j, k) Second Instruction
i: R2  R0 + R1 j: R3  R0 * R2 k: R5  R2 – R3 l: R2  R6 – R7 Data Dependency # First Instruction (i, j, k) Second Instruction Type (RAW, WAR, WAW) Which Register? 1 i j RAW R2 2 k 3 l WAW 4 5

6 Data Dependency # First Instruction (i, j, k) Second Instruction
i: R2  R0 + R1 j: R3  R0 * R2 k: R5  R2 – R3 l: R2  R6 – R7 Data Dependency # First Instruction (i, j, k) Second Instruction Type (RAW, WAR, WAW) Which Register? 1 i j RAW R2 2 k 3 l WAW R3

7 Data Dependency # First Instruction (i, j, k) Second Instruction
i: R2  R0 + R1 j: R3  R0 * R2 k: R5  R2 – R3 l: R2  R6 – R7 Data Dependency # First Instruction (i, j, k) Second Instruction Type (RAW, WAR, WAW) Which Register? 1 i j RAW R2 2 k 3 l WAW R3

8 Data Dependency # First Instruction (i, j, k) Second Instruction
i: R2  R0 + R1 j: R3  R0 * R2 k: R5  R2 – R3 l: R2  R6 – R7 Data Dependency # First Instruction (i, j, k) Second Instruction Type (RAW, WAR, WAW) Which Register? 1 i j RAW R2 2 k 3 l WAW 4 R3 5 WAR 6

9 Problem 2 2. For the given sequence of instructions, fill the table below with the pipeline stages for each instruction. The first row is already filled for you. Assuming no memory latency, how many cycles does it take to execute his piece of code?

10 LW R0, 0(R10) LW R1, 2(R10) ADD R3, R1. R2 SUB R4, R3, R2
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 LW R0, 0(R10) F D E M W LW R1, 2(R10) ADD R3, R1. R2 SUB R4, R3, R2 SW R4, 0(R11) MUL R5, R1, R2 ADD R6, R1, R7 SW R5, 0(R11) SW R6, 0(R11)

11 LW R0, 0(R10) LW R1, 2(R10) ADD R3, R1. R2 SUB R4, R3, R2
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 LW R0, 0(R10) F D E M W LW R1, 2(R10) ADD R3, R1. R2 SUB R4, R3, R2 SW R4, 0(R11) MUL R5, R1, R2 ADD R6, R1, R7 SW R5, 0(R11) SW R6, 0(R11)

12 LW R0, 0(R10) LW R1, 2(R10) ADD R3, R1. R2 SUB R4, R3, R2
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 LW R0, 0(R10) F D E M W LW R1, 2(R10) ADD R3, R1. R2 S SUB R4, R3, R2 SW R4, 0(R11) MUL R5, R1, R2 ADD R6, R1, R7 SW R5, 0(R11) SW R6, 0(R11)

13 LW R0, 0(R10) LW R1, 2(R10) ADD R3, R1. R2 SUB R4, R3, R2
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 LW R0, 0(R10) F D E M W LW R1, 2(R10) ADD R3, R1. R2 S SUB R4, R3, R2 SW R4, 0(R11) MUL R5, R1, R2 ADD R6, R1, R7 SW R5, 0(R11) SW R6, 0(R11)

14 Problem 3 2. Repeat problem 2 but with some independent instruction inserted to reduce stalls.

15 This is the original sequence
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 LW R0, 0(R10) F D E M W LW R1, 2(R10) ADD R3, R1. R2 S SUB R4, R3, R2 SW R4, 0(R11) MUL R5, R1, R2 ADD R6, R1, R7 SW R5, 0(R11) SW R6, 0(R11) This is the original sequence

16 This is the newsequence
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 LW R0, 0(R10) F D E M W LW R1, 2(R10) MUL R5, R1, R2 ADD R6, R1, R3 ADD R3, R1. R2 SW R5, 0(R11) SW R6, 0(R11) SUB R4, R3, R2 S SW R4, 0(R11) This is the newsequence


Download ppt "Appendix C Practice Problem Set 1"

Similar presentations


Ads by Google