Question

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  

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 sum of 1 to 100 using a for loop . Code-B : Looping through 100 values and printing if values are +ve or -ve....
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...

    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  ...

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
ADVERTISEMENT