• retagged by
33,218 views
63 63 votes

Consider the following code sequence having five instructions from $I_1 \text{ to } I_5$. Each of these instructions has the following format. 

OP Ri, Rj, Rk

Where operation OP is performed on contents of registers Rj and Rk and the result is stored in register Ri.

$I_1$: ADD R1, R2, R3

$I_2$: MUL R7, R1, R3

$I_3$: SUB R4, R1, R5

$I_4$: ADD R3, R2, R4

$I_5$: MUL R7, R8, R9

Consider the following three statements.

S1: There is an anti-dependence between instructions $I_2 \text{ and } I_5$

S2: There is an anti-dependence between instructions $I_2 \text{ and } I_4$

S3: Within an instruction pipeline an anti-dependence always creates one or more stalls

Which one of the above statements is/are correct?

  1. Only S1 is true
  2. Only S2 is true
  3. Only S1 and S3 are true
  4. Only S2 and S3 are true

6 Answers

Best answer
79 79 votes

Answer should be (B).

Anti-dependence can be overcome in pipeline using register renaming. So, "always" in S3 makes it false. Also, if $I2$ is completed before $I4$ (execution stage of MUL), then also there won't be any stall.

• edited by
21 21 votes
Anti Dependence =============== Write After Read Dependencies

S1      I2: MUL R7, R1, R3

           I5: MUL R7, R8, R9

in this there is Write After Write dependencies Also called Output Dependencies

So, s1 is false

 

S2  I2: MUL R7, R1, R3

      I4: ADD R3, R2, R4

there is case in which R3 is written First By I4

and  then after R3 is read by I2  which is wrong thats why it is Write after Read Dependencies

so, S2 is True

S3 is wrong Because  Anti-dependence can be overcome in pipeline using register renaming.
• edited by
5 5 votes

In S3 its asked : Within an instruction pipeline an anti-dependence always creates one or more stalls.

Here it is not asked wether can we avoid it or not ? So according to me its true but is heavily dependent on how the instruction cycle is designed for different instructions and what's the order of instructions (whether the re-ordering has been done or not) :

One reason : Different instructions having different instruction cycle.

For eg:

  1 2 3 4 5 6
SW r1,0(r2) IF ID EX MEM1 MEM2 WB
ADD r2,r4,r3   IF ID EX WB  

 

In this situation there’s a WAR data hazard, and for it to even happen we’re using different instruction cycle for different instructions, dividing memory phases into two cycles and then also we are using split register file. So WAR and WAW are dependent on how the pipeline is designed and different instructions have different cycle.

 

Another reason : Out of order execution :

 

 

Therefore, S3 is wrong because anti-dependence only creates stalls when different instructions have different instruction cycle or out of order execution is being applied and not ‘always’ .

S1 is output dependency .

S2 is anti dependency.

Answer – B

 

• edited by
0 0 votes

Alternative Name For Each Dependancy :-

1. RAW -> True Dependancy 

2. WAW, WAR }-> false Dependancy 

3. WAR -> Anti Depndancy 

4. WAW -> OutPut Dependancy 

Each of alternative Name have story behind it eigther You can Mug up or Watch Go Classes @deepak Poonia @GO Classes Lectures to really understand story

 

0 0 votes

S1: Anti-dependence between I₂ and I₅

  • I₂ reads R1 and R3, writes R7.

  • I₅ writes R7, but I₂ does not read R7. → No WAR here. S1 is false.

S2: Anti-dependence between I₂ and I₄

  • I₂ reads R3.

  • I₄ writes R3. → Later instruction (I₄) writes to a register (R3) that earlier instruction (I₂) reads. → This is a WAR. S2 is true.

S3: Within a pipeline, an anti-dependence always creates one or more stalls

  • Not always. Anti-dependence can often be eliminated by register renaming.

  • So it does not always cause stalls. S3 is false.

✅ Final Answer

Only S2 is correct.

Answer:
Position:
Show:

Related questions

200 200 votes
9 answers 9 answers
79.4k
79.4k views
Kathleen asked Sep 22, 2014
79,415 views
A $5$ stage pipelined CPU has the following sequence of stages:IF – instruction fetch from instruction memoryRD – Instruction decode and register readEX – Execute: ALU op...
74 74 votes
4 answers 4 answers
36.1k
36.1k views
Kathleen asked Sep 12, 2014
36,110 views
Which of the following are NOT true in a pipelined processor?Bypassing can handle all RAW hazardsRegister renaming can eliminate all register carried WAR hazardsControl h...
94 94 votes
6 answers 6 answers
61.4k
61.4k views
go_editor asked Feb 16, 2015
61,436 views
Consider the following reservation table for a pipeline having three stages $S_1, S_2 \text{ and } S_3$.$$\begin{array}{|l|l|} \hline \textbf{Time} \rightarrow \\\hline &...
80 80 votes
11 answers 11 answers
34.1k
34.1k views
go_editor asked Sep 28, 2014
34,139 views
Consider a $6$-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is exec...