in CO and Architecture
625 views
5 votes
5 votes
R4 <- R1 + R4

R4 <- R2 + R4

R4 <- R3 + R5

Number of WAR and WAW dependencies?
in CO and Architecture
625 views

1 Answer

3 votes
3 votes

Let us name the given instructions as I1 , I2 and I3..

There are three different types of dependencies which are RAW , WAR and WAW hazards..

For RAW dependency to happen between Ii and Ij instructions ( i being earlier than j ) , then Ij should read the same data item as written by Ii..

So as clear from above , R4 data is written by I2 which is written by I1..Hence there is RAW dependency between I1 - I2..RAW dependencies are also known true dependencies or flow dependencies , the reason being they happen for instructions which occur in-order..So there is no scope of out of order dependencies..

For WAR dependency to happen Ii - Ij with Ii being earlier than Ij in the code , Ij should write some item and the same should be read by Ii..But this happens when instruction occurs out of order i.e. Ij occurs before Ii..Such dependencies are also known as anti dependencies..

For example , here R4 is written by I3 and read by I2 and I1..

Hence the concerned WAR dependencies are : I3 - I2 and I3 - I1..Similarly I2 writes R4 which is read by I1..Hence I2 - I1 will be WAR dependency as well..

Now coming to WAW dependency , this is also an example of dependency which occurs in case of out of order execution of instructions..This happens when two instructions write to same data item..

As here all instructions write to data item R4 only , hence all of I2 - I1 , I3 - I2 and I3 - I1 will be WAW dependencies here. WAW dependencies are also known as output dependencies..

2 Comments

Are you sure that I3-I1 will cause WAR dependency? Because I2 modifies R4 in between right ?
0
0
@Habibkhan
0
0

Related questions