HW2Solution

# HW2Solution - Homework 2 Prof Milos Prvulovic CS 4290/6290...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
v=0; for(i=0;i!=100;i++) for(j=0;j!=100;j++) if((j+i)%2)==0) v+=j; The branch at 0x10C is executed 101 times. It is not taken 100 times (in each iteration of the outer loop) and taken once (to exit of the outer loop). Correspondingly, the branch at 0x134 is taken 100 times (at the end of each iteration of the outer loop). The branch at 0x114 is executed 101 times in each of the 100 iterations of the outer loop. It is NT 100 times, then T once, then NT 100 times, then T once, etc. Overall, this branch is not taken 10,000 times and taken 100 times. Correspondingly, the branch at 0x12C is taken 10,000 times (at the end of each iteration of the inner loop). The branch at 0x120 is NT when (j+i) is an even number and taken when (i+j) is an odd number. When loop counter i is even, j takes values from 0 to 99 and this branch has a pattern of (NT,T) 50 (NT, then T, repeat 50 times). When I is odd, this branch has a pattern of (T,NT) 50 . Because i takes values from 0 to 99, the overall pattern of this branch is ((NT,T) 50 (T,NT) 50 ) 50 . Overall, this branch executes 10,000 times and is taken 5,000 times and not taken 5,000. In summary, the number of mispredictions with the always-taken predictor is 15,100
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/12/2010 for the course CS 6290 taught by Professor Staff during the Spring '08 term at Georgia Tech.

### Page1 / 9

HW2Solution - Homework 2 Prof Milos Prvulovic CS 4290/6290...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online