Question: The following code implements Y = aX + Y for a vector length 100. Initially, R1 is set to the base address of array X
The following code implements Y = aX + Y for a vector length 100. Initially, R1 is set to the base address of array X and R2 is set to the base address of Y:
DADDIU R4,R1,#800 ; R1 = upper bound for X foo: L.D F2,0(R1) ; (F2) = X(i) MUL.D F4,F2,F0 ; (F4) = a*X(i) L.D F6,0(R2) ; (F6) = Y(i) ADD.D F6,F4,F6 ; (F6) = a*X(i) + Y(i) S.D F6,0(R2) ; Y(i) = a*X(i) + Y(i) DADDIU R1,R1,#8 ; increment X index DADDIU R2,R2,#8 ; increment Y index DSLTU R3,R1,R4 ; test: continue loop? BNEZ R3,foo ; loop if needed
Assume the functonal unit latencies as shown in the table below. Assume a one cycle delayed banch that resolves in the ID stage. Assume that results are fully bypassed.
| Instruction producing result | Instruction using result | Latency in clock cycles |
| FP multiply | FP ALU op | 6 |
| FP add | FP ALU op | 4 |
| FP multiply | FP store | 5 |
| FP add | FP store | 4 |
| Integer operations and all loads | Any | 2 |
a) Assume a single-issue pipeline. Show how the loop would look both unscheduled by the compiler and after compiler scheduling for both floating-point operation and branch delays, including any stalls or idle clock cycles. What is the execution time (in cycles) per element of the result vector, Y, unscheduled and scheduled?
b) Assume a single-issue pipeline. Unroll the loop as many times as necessary to schedule it without any stalls, collapsing the loop overhead instructions. How many times must the loop be unrolled? Show the instruction schedule. What is the execution time per element of the result?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
