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