Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. [10 points] Your branch target buffer (and branch history buffer) each have 8 slots. Your CPU executes the follovw ing code fragment. Assume that

image text in transcribed

image text in transcribed

2. [10 points] Your branch target buffer (and branch history buffer) each have 8 slots. Your CPU executes the follovw ing code fragment. Assume that prediction takes place in the Fetch cycle, and that the result of a branch is actually known after the eXecute cycle. Assume full forwarding (MX, WX, WM). Also, assume that array[] = {100, 150, 200, 250, 300} addi x12, x0, 5 add x11, x0, x0 add x19, x0, x0 addi x20, x0,150 //x1 =0 //x19 =0 L1: bge x11, x12, Exit slli x13, x11, 3 add x14, x16, x13 ld x15, 0(x14) blt x15, x20, L2 sd x0, 0(x14) add x19, x15, x19 beq x0, x0, L3 //x16 - address of array[0] L2: addi x15, x15, 1 sd x15, 0(x14) L3: addi x11, x11, 1 jal x0, L1 Exit: (a) Draw a pipeline diagram for the execution of the program, assuming a static predict-not-taken policy (yes, this means that the BTB and BHT aren't used yet). Circle the stages in which the outcome of a branch is known. Make sure to include stalls due to branch misprediction. How many cycles are lost due to stalls? (b) Assume that you are using a 1-bit branch predictor, and redraw the pipeline diagram. How many cycles are lost due to stalls? Make sure that you incorporate the cycle in which the outcome of a branch is known, if necessary. Show the values read and written from the BTB and BHT (from 2b, and the cycles in which the read/write occurs. You need not show reads due to fetches of non-branch instructions (c) (d) Assume that you are using a 2-bit branch predictor, and redraw the pipeline diagram. How many cycles are lost due to stalls? Make sure that you incorporate the cycle in which the outcome of a branch is Known, if necessary Show the values read and written from the BTB and BHT (from 2d, and the cycles in which the read/write occurs. You need not show reads due to fetches of non-branch instructions (e) 2. [10 points] Your branch target buffer (and branch history buffer) each have 8 slots. Your CPU executes the follovw ing code fragment. Assume that prediction takes place in the Fetch cycle, and that the result of a branch is actually known after the eXecute cycle. Assume full forwarding (MX, WX, WM). Also, assume that array[] = {100, 150, 200, 250, 300} addi x12, x0, 5 add x11, x0, x0 add x19, x0, x0 addi x20, x0,150 //x1 =0 //x19 =0 L1: bge x11, x12, Exit slli x13, x11, 3 add x14, x16, x13 ld x15, 0(x14) blt x15, x20, L2 sd x0, 0(x14) add x19, x15, x19 beq x0, x0, L3 //x16 - address of array[0] L2: addi x15, x15, 1 sd x15, 0(x14) L3: addi x11, x11, 1 jal x0, L1 Exit: (a) Draw a pipeline diagram for the execution of the program, assuming a static predict-not-taken policy (yes, this means that the BTB and BHT aren't used yet). Circle the stages in which the outcome of a branch is known. Make sure to include stalls due to branch misprediction. How many cycles are lost due to stalls? (b) Assume that you are using a 1-bit branch predictor, and redraw the pipeline diagram. How many cycles are lost due to stalls? Make sure that you incorporate the cycle in which the outcome of a branch is known, if necessary. Show the values read and written from the BTB and BHT (from 2b, and the cycles in which the read/write occurs. You need not show reads due to fetches of non-branch instructions (c) (d) Assume that you are using a 2-bit branch predictor, and redraw the pipeline diagram. How many cycles are lost due to stalls? Make sure that you incorporate the cycle in which the outcome of a branch is Known, if necessary Show the values read and written from the BTB and BHT (from 2d, and the cycles in which the read/write occurs. You need not show reads due to fetches of non-branch instructions (e)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions