


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



CS433g: Computer System Organization – Fall 2005 Practice Set 4 - Solution
Problem 1
Consider the following format for predicated MIPS instructions:
(pT) ADD R1, R2, R
where the ADD instruction is predicated on the predicate register pT. Assume a set of 1-bit predicate registers that are set by a compare instruction of the form:
CMP.ne pT, pF = R8, R
The example above uses a not equal (.ne) comparison relation to match the code fragment above. (You can assume the availability of any comparison relation with two operands; i.e. .le for less than or equal to and .gt for greater than.) The above compare sets the 1-bit predicate registers as follows:
pT = (R8 != R0) pF = !(R8!= R0)
So pT is true if R8 is not equal to R0, and pF is the complement of pT.
SUB R1, R13, R BNEZ R1, L ADDI R2, R2, # SW 0(R7), R J L
L1: MULT.D F0, F0, F ADD.D F0, F4, F S.D 0(R8), F L2: ...
Solution:
(a) RAW dependency due to R1 between SUB and CMPI. (b) RAW dependency due to pF between CMPI and ADDI. (c) RAW dependency due to pF between CMPI and SW. (d) RAW dependency due to R2 between ADDI and SW. (e) RAW dependency due to pT between CMPI and MULT.D. (f) RAW dependency due to pT between CMPI and ADD.D. (g) RAW dependency due to pT between CMPI and S.D. (h) RAW dependency due to F0 between MULT.D and S.D. (i) RAW dependency due to F0 between ADD.D and S.D. (j) WAW dependency due to F0 between MULT.D and ADD.D. (k) WAR dependency due to F0 between MULT.D and ADD.D.
Problem 2
Consider the following code excerpt from a larger set of instructions:
. . . loop: SW 7(R1), R2 (1) ADD R1, R1, #8 (2) LW R2, 7(R1) (3) ADD R4, R2, R1 (4) SD 200(R7), F2 (5) BEZ R4, loop (6) SW 7(R4), R5 (7) . . .
List all data dependences between the above instructions that a compiler would find. Assume that this code fragment is a portion of a larger piece of code, but the instructions that are not shown do not create additional data dependences.
part, disregard any instructions that come in between the two dependent instructions.
Solution :
Data dependences: Potentially between 1 and 5 for 7(R1) and 200(R7) Potentially between 1 and 7 for 7(R1) and 7(R4) Between 2 and 3 for R Between 2 and 4 for R Between 3 and 4 for R Between 4 and 6 for R Between 4 and 7 for R
... ;intervening instructions recover: L.D F2,0(R1) ADD.D F4,F0,F JUMP back ;return to original path ... ... null:...