Question

These two pieces of code are executed on a 5 stage pipelined processor. Code-A : Counting...

These two pieces of code are executed on a 5 stage pipelined processor.

Code-A : Counting sum of 1 to 100 using a for loop .

Code-B : Looping through 100 values and printing if values are +ve or -ve. There is 50-50 chance of value being positive or negative.

This processor always predicts 'branch is taken'. Which code does suffer more from purging / aborting instruction on fly?

a) Both will suffer equal

b) Insufficient information

c) Code A  

d) Code B

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code A will suffer more because in code A, there is for loop which executes for 100 iteration and hence branch taken will be false for these 100 iterations and only after 100 iteration the breaching condition will be actually true .

While in code B, there is 50% chance of branch taken strategy to be good and 50% will result in aborting instructions .

So since processor always predicts 'branch is taken', code B suffer only 50% times, code A suffer almost 100% . Hence code A will suffer more from purging.

Please comment for any clarification.

Add a comment
Know the answer?
Add Answer to:
These two pieces of code are executed on a 5 stage pipelined processor. Code-A : Counting...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • These two pieces of code are executed on a 5 stage pipelined processor. Code-A : Counting sum of 1 to 100 using a for loop . Code-B : Looping through 100 values and printing if values are +ve or -ve....

    These two pieces of code are executed on a 5 stage pipelined processor. Code-A : Counting sum of 1 to 100 using a for loop . Code-B : Looping through 100 values and printing if values are +ve or -ve. There is 50-50 chance of value being positive or negative. This processor always predicts 'branch is taken'. Which code does suffer more from purging / aborting instruction on fly? a) Both will suffer equal b) Insufficient information c) Code A  ...

  • The code chain below is executed on a data forwarding, 5-stage pipelined processor. Which of the...

    The code chain below is executed on a data forwarding, 5-stage pipelined processor. Which of the following instructions will encounter a stall? Write the instruction number along with the number of stall cycles that instruction experiences. (Note the data forwarding) 1. add $4, $5, $6 2. add $7, $4, $5 3. sw $8, 0($7) 4. add $8, $8, $6 5. lw $6, 0($8) 6. add $10, $9, $8

  • (60 points) The following instructions are executed on the 5-stage MIPS pipelined datapath. add r...

    Computer architecture help: (60 points) The following instructions are executed on the 5-stage MIPS pipelined datapath. add r5,r2, r1 lw r3, 4(r5) lw r2, 0(r2) or r3, r5, r3 sw r3, 0(r5) (a) (20 points) List the data hazards in the above code. For each data hazard identified, clearly mark the source and the destination. For example you can say, there is a data hazard from instruction X to instruction Y on register Z. (b) (20 points) Assume there is...

  • Consider the following code to be executed on a pipelined processor lw $s1, 40(Ss6) add $s6,...

    Consider the following code to be executed on a pipelined processor lw $s1, 40(Ss6) add $s6, $s2, $s2 sw Ss6, 48(Ss1) a. Include stalls/nops in the code so it executes correctly in the cases of (i) No forwarding (ii) ALU-ALU for warding, (iii) Full forwarding b. In each case calculate the number of clock cycles required to execute the code c. Assume further that the clock cycle time is 110 ps with no forwarding, 120 ps with ALU-ALU forwarding and...

  • The classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem....

    The classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem. Assume the followings: The architecture fully supports forwarding, Register write is done in the first half of the clock cycle; register read is performed in the second half of the clock cycle, Branches are resolved in the third stage of the pipeline and the architecture does not utilize any branch prediction mechanism, Register R4 is initially 100. L1:  lw    R1, 0(R4)   add   R3, R1, R2 sw   ...

  • The classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem....

    The classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem. Assume the followings: • The architecture fully supports forwarding, • Register write is done in the first half of the clock cycle; register read is performed in the second half of the clock cycle, • Branches are resolved in the third stage of the pipeline and the architecture does not utilize any branch prediction mechanism, • Register R4 is initially 100. L1: lw add...

  • he classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem....

    he classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem. Assume the followings: The architecture fully supports forwarding, • Register write is done in the first half of the clock cycle; register read is performed in the second half of the clock cycle, • Branches are resolved in the third stage of the pipeline and the architecture does not utilize any branch prediction mechanism, • Register R4 is initially 100. Ll: lw add SW...

  • add SW addi bne The classic five-stage pipeline MIPS architecture is used to execute the code...

    add SW addi bne The classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem. Assume the followings: The architecture fully supports forwarding, • Register write is done in the first half of the clock cycle; register read is performed in the second half of the clock cycle, • Branches are resolved in the third stage of the pipeline and the architecture does not utilize any branch prediction mechanism, • Register R4 is initially 100....

  • A short program loop goes through a 16 kB array one word at a time, reads...

    A short program loop goes through a 16 kB array one word at a time, reads a number from the array, adds a random number, and stores the result in the corresponding entry in another array that is located in the memory immediately following the first array. An outer loop repeats the above operation 100 times. The 64-bit processor, operating at a clock frequency of 4 GHz, is pipelined, has 48 address lines, three levels of caches with a 64...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT