GATE / CS ARCHIVE

SIMILAR QUESTIONS / COMPUTER ORGANIZATION & ARCHITECTURE

Classify dependencies from register reads and writes

2 questions solved the same way, newest first. Back to Computer Organization & Architecture

How these are solved

Extract the read/write sets of each destination-first instruction and test RAW/WAR/WAW intersections in program order. The 2015 variant also rejects the universal claim that anti-dependence always stalls.

1 mark · MSQ
Report issue

Classify register dependencies by read and write sets

Pipelining & Hazards

Question 31, GATE 2024: Instructions have destination first: I1 DIV R3,R1,R2; I2 SUB R5,R3,R4; I3 ADD R3,R5,R6; I4 MUL R7,R3,R8. Which are true? A I1→I2 RAW on R3; B I1→I3 WAR on R3; C I2→I3 RAW on R3; D I3→I4 WAW on R3.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A

Approach: Write down which instruction produces a register and which consumes it; retain the stated register name.

1. Derivation. I1 writes R3 and I2 reads R3, a read-after-write dependency, so A is true. I1 and I3 both write R3, making their relation WAW rather than WAR. I2 reads R3 and I3 writes it, giving WAR on R3 (they also have RAW on R5). I3 writes R3 and I4 reads it, giving RAW rather than WAW. Only A.

2. Explanation and checks. On R3 the four operations are write, read, write, read. A later read after an earlier write is RAW, two writes give WAW, and a write after an earlier read gives WAR. This sequence directly classifies each proposed pair. Although I2→I3 does have a RAW dependency on R5, option C explicitly says R3 and is therefore false. A dependency is a program-order relationship; whether it produces an actual stall depends on the implementation.

Original paper, page 21 · Answer key

2 marks · MCQ
Report issue

Pipelining & Hazards

Question 49, GATE 2015: Instructions have form OP Ri,Rj,Rk, which reads Rj,Rk and writes Ri. The sequence is I1: ADD R1,R2,R3; I2: MUL R7,R1,R3; I3: SUB R4,R1,R5; I4: ADD R3,R2,R4; I5: MUL R7,R8,R9. Consider S1: I2 and I5 have an anti-dependence; S2: I2 and I4 have an anti-dependence; S3: in a pipeline, an anti-dependence always causes at least one stall. Options: (A) S1 only; (B) S2 only; (C) S1 and S3 only; (D) S2 and S3 only.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. I2 reads R3 and I4 later writes R3, a write-after-read anti-dependence, so S2 holds.

2. I2 and I5 both write R7, an output dependence rather than anti-dependence. In-order reads/writes or register renaming can avoid stalls for anti-dependences, so S3 is false. Thus only S2, B.

Original paper, page 70 · Answer key