GATE 2007
184 questions
MCQ 1841-mark 184
Questions 66–70 of 184
Data forwarding techniques can be used to speed up the operation in presence of data dependencies. Consider the following replacements of LHS with RHS.
i.
ii.
iii.
iv.
In which of the following options, will the result of executing the RHS be the same as executing the LHS irrespective of the instructions that follow ?
i.
ii.
iii.
iv.
In which of the following options, will the result of executing the RHS be the same as executing the LHS irrespective of the instructions that follow ?
Answer: (B)
(i) is true. and both receive the value of in and in .
(ii) is false. gets the correct data in and in , but is not updated in .
(iii) is false. In the last write to is from , but in gets .
(iv) is true. The first write to in is of no use, because the next write overwrites it.
So (i) and (iv) hold.
Answer: (B)
(ii) is false. gets the correct data in and in , but is not updated in .
(iii) is false. In the last write to is from , but in gets .
(iv) is true. The first write to in is of no use, because the next write overwrites it.
So (i) and (iv) hold.
Answer: (B)
The floating point unit of a processor using a design D takes 2t cycles compared to t cycles taken by the fixed point unit. There are two more design suggestions and . uses 30% more cycles for fixed point unit but 30% less cycles for floating point unit as compared to design D. uses 40% less cycles for fixed point unit but 10% more cycles for floating point unit as compared to design D. For a given program which has 80% fixed point operations and 20% floating point operations, which of the following ordering reflects the relative performances of three designs? ( > denotes that is faster than )
Answer: (B)
Average time per operation = 0.8 (cycles of fixed point) + 0.2 (cycles of floating point). Fewer cycles means faster.
: fixed point 1.3t, floating point , so
: fixed point 0.6t, floating point , so
takes the fewest cycles (0.92t), then (1.2t), then (1.32t). So .
Answer: (B)
: fixed point 1.3t, floating point , so
: fixed point 0.6t, floating point , so
takes the fewest cycles (0.92t), then (1.2t), then (1.32t). So .
Answer: (B)
A processor takes 12 cycles to complete an instruction . The corresponding pipelined processor uses 6 stages with the execution times of 3, 2, 5, 4, 6 and 2 cycles respectively. What is the asymptotic speedup assuming that a very large number of instructions are to be executed?
Answer: (B)
The pipeline cycle time must match the slowest stage, which takes 6 cycles. When the pipeline is full, one instruction completes every 6 cycles.
Speed-up = 12 / 6 = 2
Answer: 2
Speed-up = 12 / 6 = 2
Answer: 2
Consider a pipelined processor with the following four stages:
IF: Instruction Fetch
ID: Instruction Decode and Operand Fetch
EX: Execute
WB: Write Back
The IF, ID and WB stages take one clock cycle each to complete the operation. The number of clock cycles for the EX stage depends on the instruction. The ADD and SUB instructions need 1 clock cycle and the MUL instruction needs 3 clock cycles in the EX stage. Operand forwarding is used in the pipelined processor. What is the number of clock cycles taken to complete the following sequence of instructions?
ADD R2, R1, R0 (R2 R1 + R0)
MUL R4, R3, R2 (R4 R3 * R2)
SUB R6, R5, R4 (R6 R5 - R4)
IF: Instruction Fetch
ID: Instruction Decode and Operand Fetch
EX: Execute
WB: Write Back
The IF, ID and WB stages take one clock cycle each to complete the operation. The number of clock cycles for the EX stage depends on the instruction. The ADD and SUB instructions need 1 clock cycle and the MUL instruction needs 3 clock cycles in the EX stage. Operand forwarding is used in the pipelined processor. What is the number of clock cycles taken to complete the following sequence of instructions?
ADD R2, R1, R0 (R2 R1 + R0)
MUL R4, R3, R2 (R4 R3 * R2)
SUB R6, R5, R4 (R6 R5 - R4)
Answer: (B)
Forwarding passes a result from the end of one EX stage to the start of the next EX stage, so a dependent instruction does not wait for WB.
ADD: IF in t1, ID in t2, EX in t3, WB in t4. MUL needs R2 from ADD, which is forwarded, so MUL does EX in t4 to t6 and WB in t7. SUB needs R4, which MUL makes only at the end of its 3-cycle EX (t6). So SUB stalls in t5 and t6, gets R4 by forwarding, does EX in t7 and WB in t8.
Here is the EX to EX data forwarding:
The last WB is in t8, so 8 cycles are taken.
Answer: (B)
ADD: IF in t1, ID in t2, EX in t3, WB in t4. MUL needs R2 from ADD, which is forwarded, so MUL does EX in t4 to t6 and WB in t7. SUB needs R4, which MUL makes only at the end of its 3-cycle EX (t6). So SUB stalls in t5 and t6, gets R4 by forwarding, does EX in t7 and WB in t8.
Here is the EX to EX data forwarding:
The last WB is in t8, so 8 cycles are taken.
Answer: (B)
Following table indicates the latencies of operations between the instruction producing the result and instruction using the result.
Consider the following code segment:
What is the number of cycles needed to execute the above code segment assuming each instruction takes one cycle to execute?
Consider the following code segment:
Load R1, Loc 1; Load R1 from memory location Loc1
Load R2, Loc 2; Load R2 from memory location Loc 2
Add R1, R2, R1; Add R1 and R2 and save result in R1
Dec R2; Decrement R2
Dec R1; Decrement R1
Mpy R1, R2, R3; Multiply R1 and R2 and save result in R3
Store R3, Loc 3; Store R3 in memory location Loc 3 What is the number of cycles needed to execute the above code segment assuming each instruction takes one cycle to execute?
Answer: (C)
The code has 7 instructions, and each takes 1 cycle to execute. The latency in the table is the number of idle cycles that must lie between the producing instruction and the instruction using its result. For example, an ALU result used by another ALU operation needs 2 idle cycles in between.
So 13 clock cycles are needed in total.
Answer: (C)
- Load R1, Loc 1: no dependence, so it runs in T1.
- Load R2, Loc 2: no dependence, so it runs in T2.
- Add R1, R2, R1: uses R1 and R2, both from loads (Load to ALU latency 1). It must wait 1 cycle after I2, so it runs in T4. The wait after I1 is already covered.
- Dec R2: uses R2 from I2 (Load to ALU latency 1). It needs one idle cycle after T2, which is already there, so it runs in T5.
- Dec R1: uses R1 from I3 (ALU to ALU latency 2). I3 is in T4, so I5 cannot run before T7. I4 fills T5 and T6 is idle, so I5 runs in T7.
- Mpy R1, R2, R3: uses R1 from I5 (ALU to ALU latency 2), so it runs in T10. It also uses R2 from I4, which is satisfied by then.
- Store R3, Loc 3: uses R3 from I6 (ALU to Store latency 2), so it runs in T13.
So 13 clock cycles are needed in total.
Answer: (C)