edited by
6,520 views
10 votes
10 votes

Consider the following instructions.

$I_1:R_1=100$

$I_2:R_1=R_2+R_4$

$I_3:R_2=R_4+25$

$I_4:R_4=R_1+R_3$

$I_5:R_1=R_1+30$

Calculate sum of ($\text{WAR, RAW and WAW}$) dependencies the above instructions.

  1. $10$
  2. $12$
  3. $6$
  4. $8$
edited by

7 Answers

Best answer
20 votes
20 votes
WAW dependence:
1. I1-I2
2. I2-I5
3. I1-I5

RAW dependence:
1. I2-I4
2. I2-I5

3. I1-I4
4. I1-I5

The dependences 3 and 4 are special in the sense that they never cause a hazard. So, if hazards are asked never include them. For dependences as per definition we can include them.

WAR dependence:
1. I2-I3
2. I2-I4
3. I3-I4
4. I4-I5

Totally 11.
selected by
24 votes
24 votes

RAW or Flow (TRUE) dependence happens when a READ to a register follows a WRITE to the same. Here, RAW is there between,

  1. $I_2- I_4$
  2. $I_2 -I_5$
  3. I1-I4
  4. I1-I5

The dependences 3 and 4 are special in the sense that they never cause a hazard. So, if hazards are asked never include them. For dependences as per definition we can include them.

For finding RAW dependence we have to see all register usages, and the just preceding write to the same (need not be adjacent instructions).

WAR or anti dependence happens when a WRITE follows a READ from a register. Here, it happens between,

  1. $I_2-I_3$
  2. $I_2-I_4$
  3. $I_3-I_4$
  4. $I_4-I_5$

WAW or Output dependence happens when a WRITE to a register follows another WRITE. Here it happens between

  1. $I_1-I_2$
  2. $I_2-I_5$
  3. $I_1-I_5$

Total 11 dependencies 

edited by
1 votes
1 votes
yeah,bro..and wrong answer is given by madeeasy.

WAW - 3    I1I2 , I1I5, I2I5

RAW -  4   I1I4 , I1I5 , I2I4, I2I5

WAW -  4  I2I3 , I2I4 , I3I4, I4I5

total = 11..

It will be the right answer.
1 votes
1 votes

Assume I and J are two instrucitons and J follows I in the given question.

For RAW : (check only adjacent instructions I and J )

  • check for commom registers between input registers of instruction J and and output reguster of instruction I
  • So, no of RAW dependencies :  0

For WAR : (check all previous instructions (I's) before instruction J)

  • check for commom registers between output register of instruction J and input registers of instriction I
  • So, WAR dependencies : 
    • I3 - I2  (R2)
    • I4 - I3  (R4)
    • I4 - I2  (R4)
    • I5 - I4  (R1)
  •  Total WAR = 4

 For WAW : (check all previous instructions (I's) before instruction J)

  • check for commom registers between output register of instruction J and output registers of instriction I
    • I2 - I1 (R1)
    • I5 - I2 (R1)
    • I5 - I1 (R1)
  • So, Total WAW = 3 

Related questions

2 votes
2 votes
1 answer
3
Mk Utkarsh asked Oct 23, 2018
2,183 views
Consider the below instructions executed on a 5 stage(IF,ID,EX,MA,WB) RISC pipeline with operand forwarding.I1: ADD R0,R1,R2 (R0=R1+R2)I2: SUB R3,R0,R2I3:MUL R4,R3,R0I4:D...
3 votes
3 votes
1 answer
4
Rajesh R asked Oct 26, 2017
559 views
Number of WAR dependencies possibleR1 <- R3 + R2R3 <- R3 + R5R3 <- R2 + R3Is it 2 or 3?