Question: Question 2 . [ Loop Unrolling ] [ 3 0 pts ] Consider the following loop in a simple assembly language, which is executed on

Question 2.[Loop Unrolling][30 pts]
Consider the following loop in a simple assembly language, which is executed on a 5-stage RISC pipeline:
Loop: ld x1,0(x2) # Load value from memory address x2 into register x1
addi x1, x1,1 # Increment x1 by 1
sd x1,0(x2) # Store the updated value of x1 back to memory address x2
addi x2, x2,8 # Increment x2 by 8 to point to the next memory location
sub x3, x3, x4 # Decrement the loop counter x3
bnez x3, Loop # Branch back to Loop if x3 is not zero
Assume that the loop runs 4 times initially and that the pipeline has full forwarding/bypassing hardware, but branches cause a 2-cycle penalty when mispredicted. Additionally, memory references (loads and stores) take 1 cycle each.
(a)(10 pts) Unroll the loop 2 times. Show the unrolled version of the loop.
(b)(10 pts) Compare the performance (number of cycles) of the original loop and the unrolled loop, assuming perfect branch prediction after unrolling.
(c)(10 pts) Calculate the speedup achieved as a result of unrolling

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!