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. $10$ $12$ $6$ $8$ CO and Architecture co-and-architecture data-dependency + – Deepak Sharma 1 asked Dec 7, 2015 • edited Aug 8, 2021 by soujanyareddy13 Deepak Sharma 1 6.8k views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments Digvijaysingh Gautam commented Oct 19, 2016 reply Follow Share Ans is 11 ? 0 votes 0 votes KISHALAY DAS commented Oct 19, 2016 reply Follow Share They have given 7 but i m getting 10.could you explain how r u getting 11? 0 votes 0 votes Digvijaysingh Gautam commented Oct 19, 2016 reply Follow Share 1) Consider for I1 between I1 and I2 :- WAW = 1 between I1 and I3 :- no between I1 and I4 :- RAW = 1 between I1 and I5 :- no since ID phase of I5 is after WB of I1 2) Consider for I2 between I2 and I3 = WAR =1 between I2 and I4 = WAR =1, RAW = 1 between I2 and I5 = WAW = 1, RAW = 1 3) Consider for I3 between I3 and I4 = WAR =1 between I3 and I5 = no 4) Consider for I4 between I4 and I5 = WAR =1 So total =9 0 votes 0 votes Please log in or register to add a comment.
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. Arjun answered Dec 4, 2016 • selected May 13, 2021 by Arjun Arjun comment Share Follow See all 13 Comments See all 13 13 Comments reply Kapil commented Dec 4, 2016 reply Follow Share Sir, In WAW , why I1 - I5 ? Here, I2 hides I1, Just like a local vaiable hides a global variable in C, rt ? 0 votes 0 votes Arjun commented Dec 4, 2016 reply Follow Share yes, I checked many references, and these hiding is applicable only for hazards. For dependences we can include all as per definition. 4 votes 4 votes Kapil commented Dec 4, 2016 reply Follow Share Sir, Then should I correct this one https://gateoverflow.in/29896/number-of-war-dependencies ? 1 votes 1 votes Prashant. commented Dec 4, 2016 reply Follow Share Arjun sir Raw dependency can be find using DAC used in compiler isn't? 0 votes 0 votes srestha commented Dec 4, 2016 reply Follow Share thank u, very good point between hazard and dependency 1 votes 1 votes Prashant. commented Dec 6, 2016 reply Follow Share https://gateoverflow.in/3622/gate2006-it-78 Arjun sir according to you this quetion options are wrong . or they want to ask RAW hazard. 0 votes 0 votes Gaurab Ghosh commented Jan 27, 2017 i edited by Gaurab Ghosh Jan 28, 2017 reply Follow Share Arjun sir Why I2-I5 is creating a RAW hazard? If I draw the pipeline stages the ID stage of I5 is coming after WB stage of I2. So there should not be a RAW hazard. Please see this link https://web.cs.iastate.edu/~prabhu/Tutorial/PIPELINE/dataHaz.html Here the last instruction (XOR) is not incurring any hazard. 0 votes 0 votes dragonball commented Apr 21, 2017 reply Follow Share Do U think I1 -> I4 will qualify for RAW dependency as R1 get modified at R2 ? 0 votes 0 votes commenter commenter commented Nov 21, 2019 reply Follow Share So, do we need to include I1-I4 and I1-I5 as RAW dependecies. In some places it is said to be included. In other places it is not. Uff... 0 votes 0 votes `JEET commented Nov 21, 2019 reply Follow Share Depends! 0 votes 0 votes KUSHAGRA गुप्ता commented Dec 21, 2019 reply Follow Share @`JEET Depends on what ? Which answer we should go with @srestha mam or @Arjun sir on RAW dependencies ? 0 votes 0 votes nvs16 commented Sep 20, 2020 reply Follow Share Is the answer 11 or 9(in the accepted answer) ? 0 votes 0 votes Raj_81 commented Oct 4, 2020 reply Follow Share Link not found :( 0 votes 0 votes Please log in or register to add a comment.
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, $I_2- I_4$ $I_2 -I_5$ I1-I4 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, $I_2-I_3$ $I_2-I_4$ $I_3-I_4$ $I_4-I_5$ WAW or Output dependence happens when a WRITE to a register follows another WRITE. Here it happens between $I_1-I_2$ $I_2-I_5$ $I_1-I_5$ Total 11 dependencies srestha answered Dec 7, 2015 • edited Jan 19, 2019 by Arjun srestha comment Share Follow See all 16 Comments See all 16 16 Comments reply Show 13 previous comments Xylene commented Oct 25, 2017 reply Follow Share If the above answer is correct then the answer to this previous year question https://gateoverflow.in/3622/gate2006-it-78 should be wrong. which definition should we follow? @Arjun Sir , Please see this ! 1 votes 1 votes Amit Tiwari 5 commented Jul 30, 2020 reply Follow Share I1-I5 wont be a dependecy if there's a prob b/w I1 I2 doesn't matter there is a prob b/w I1 I5 and if there is no prob b/w I1 I2 there cant be a prob b/w I1 I5 so here is only 1 dependency 0 votes 0 votes Akash 1234Upadhyay commented Feb 6, 2021 reply Follow Share ITS CORRECT 0 votes 0 votes Please log in or register to add a comment.
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. resuscitate answered Jan 3, 2016 resuscitate comment Share Follow See all 3 Comments See all 3 3 Comments reply tiger commented Jan 3, 2016 reply Follow Share can u explain method what need to consider in RAW, WAR, WAW ? 0 votes 0 votes resuscitate commented Jan 3, 2016 reply Follow Share raw-read after write war- write after read waw- write after write just follow the meaning and check them between 2 instructions 0 votes 0 votes asu commented May 16, 2016 reply Follow Share LAST ONE IS THE WAR DEP. 0 votes 0 votes Please log in or register to add a comment.
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 dd answered Aug 29, 2016 dd comment Share Follow See all 8 Comments See all 8 8 Comments reply Show 5 previous comments Arjun commented Aug 29, 2016 reply Follow Share This is not correct. 0 votes 0 votes nimesh kumar commented Aug 30, 2016 reply Follow Share sir please give correct solution. 0 votes 0 votes Arjun commented Aug 30, 2016 reply Follow Share You can see the accepted answer. 0 votes 0 votes Please log in or register to add a comment.