Docsity

Hyperblock Regions and Control Height Reduction: A Study on If-conversion - Prof. Scott Ma, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download Hyperblock Regions and Control Height Reduction: A Study on If-conversion - Prof. Scott Ma and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

  • EECS 583 – Class 5 Hyperblock Regions Control Height Reduction University of Michigan January 24,
  • 1 -

Reading Material^ Y^ Today’s class^ »^ "Effective Compiler Support for Predicated Execution using theHyperblock", S. Mahlke et al., MICRO-25, 1992.^ »^ "Control CPR: A Branch Height Reduction Optimization forEPIC Processors", M. Schlansker et al., PLDI-99, 1999.^ Y^ Material for the next lecture^ »^ “Profiled Guided Code Positioning”,^ K. Pettis and R. Hansen, Proc. PLDI-90, 1990^ “Procedure Placement Using Temporal Ordering Information”,^ N. Gloy et al., Proc. MICRO-30, 1997

  • 3 -

When to Apply If-conversion^ Y^ Positives^ »^ Remove branch^ y^ No disruption to sequential fetch^ y^ No prediction or mispredict^ y^ No use of branch resource^ »^ Increase potential for operationoverlap^ »^ Enable more aggressive compilerxforms^ y^ Software pipelining^ y^ Height reduction^ Y^ Negatives^ »^ Max or Sum function applied whenoverlap^ y^ Resource usage^ y^ Dependence height^ y^ Hazard presence^ »^ Executing useless operations

10 BB1 80 20 BB2 8020 BB4 BB5 BB

BB3 10 90 10 10

  • 4 -

Negative 1: Resource Usage Resource usage is additive for all BBs that are if-converted

Case 1: Each BB requires 3 resources Assume processor has 2 resources No IC: 13 + .63 + .43 + 13 = 9^ 9 / 2 = 4.5 = 5 cycles IC: 1(3 + 3 + 3+ 3) = 12^ 12 / 2 = 6 cycles (^100) BB1^ BB2 60 40 BB

BB 60 40

BB2 if p1 BB^

Case 2: Each BB requires 3 resources BB3 if p2 Assume processor has 6 resources BB4 No IC: 13 + .63 + .43 + 13 = 9^ 9 / 6 = 1.5 = 2 cycles IC: 1(3+3+3+3) = 12^ 12 / 6 = 2 cycles 100

  • 6 -

Negative 3: Hazard Presence Hazard = operation that forces the compiler to be conservative, so limited reordering or optimization, e.g., subroutine call, pointer store, …

Case 1: Hazard in BB3 No IC : SB out of BB1, 2, 4, operations In BB4 free to overlap with those in BB1 and BB2 IC: operations in BB4 cannot overlap With those in BB1 (BB2 ok) (^100) BB1^ BB2 60 40 BB

BB 60 40

BB2 if p1 BB3^ BB3 if p2^ BB4 100

  • 7 -

When To If-convert^ Y^ Resources^ »^ Small resource usage ideal forless important paths^ Y^ Dependence height^ »^ Matched heights are ideal^ »^ Close to same heights is ok^ Y^ Remember everything is relative^ for resources and dependenceheight!^ Y^ Hazards^ »^ Avoid hazards unless on mostimportant path^ Y^ Estimate of benefit^ »^ Branches/Mispredicts removed^ »^ Fudge factor

100 BB1^ BB2 60 40 BB

BB 60 40

BB2 if p1 BB3^ BB3 if p2^ BB4 100

  • 9 -

Block Selection

Y^ Block selection^ »^ Select subset of BBs forinclusion in HB^ »^ Difficult problem^ »^ Weighted cost/benefitfunction^ y^ Height overhead^ y^ Resource overhead^ y^ Hazard overhead^ y^ Branch elimination benefit^ y^ Weighted by frequency

10 BB1 80 20 BB2 8020 BB4 BB5 BB

BB3 10 90 10 10

  • 10 -

Block Selection^ Y^ Create a trace

Æ“main path” »^ Use a heuristic function to select other blocks that are“compatible” with the main path »^ Consider each BB by itself for simplicity^ y^ Compute priority for other BB’s^ y^ Normalize against main path. Y BSVi = (K x (weight_bbi / size_bbi) x (size_main_path /weight_main_path) x bb_chari) »^ weight = execution frequency »^ size = number of operations »^ bb_char = characteristic value of each BB^ y^ Max value = 1, Hazardous instructions reduce this to 0.5, 0.25, ... »^ K = constant to represent processor issue rate Y Include BB when BSVi > Threshold

  • 12 -

Example - Step 2 - Tail Duplication

Tail duplication same as with Superblock formation 10 BB1 (^80 20) BB2^ BB3 8020 BB4 (^10) BB5^9010 BB6 90 10

BB2^80 BB4^ BB

BB1^20 BB

10 80 20 BB

10 BB6’^91

  • 13 -

Example - Step 3 – If-conversion

If-convert intra-HB branches only!! BB2^80 BB4^ BB

BB1^20 BB

10 80 20 BB

10 BB6’ 1

BB1 p1,p2 = CMPP BB2 if p1 BB3 if p2 BB4 BB^

BB5^10 BB6’ 1

  • 15 -

Class Problem

Form the HB for this subgraph Assume K = 4, BSV Threshold = 2 BB2 - 8^ BB4 - 2

55 (^20) BB5 - 3 (^10) BB7 -1^3510

100 BB1- 3 20 80 BB3 - 2^8045 55 BB6 - 2 35 BB8 -2 BB9 -

  • 16 -

Block Selection – Try 2^ Y^ Problems with BSV formula^ »^ Ignore dependence height^ »^ Blocks considered independently (control flow ignored)^ Y^ Enumerate all paths of execution through region of interest^ »^ Consider a path – execution from entry to some exit^ »^ Give priority to path as a whole^ Y^ Path priority^ »^ dep_ratioi = 1.0 – (dep_heighti / max dep_height)^ »^ op_ratioi = 1.0 – (num_opsi / max num_ops)^ »^ priorityi = (probabilityi x hazardi) x (dep_ratioi + op_ratioi + K)^ y^ Hazard multiplier was 0.25 for paths containing subroutine call orunresolvable memory store^ y^ K = base contribution for a path (0.1 used)

  • 18 -

Block Selection - Try 2 - Example

Enumerate all paths, rank by priority1. A-B-D-E-F-H-N2. A-B-D-E-F-H-K-N3. A-B-D-E-G-J-M-N4. A-B-D-E-G-J-L-M-N5. A-B-D-E-G-I-M-N6. A-B-D-E-G-J-L-N7. A-B-D8. A-C-D-E-F-H-N9. A-C-D-E-F-H-K-N10. A-C-D-E-G-J-M-N11. A-C-D-E-G-J-L-M-N12. A-C-D-E-G-I-M-N13. A-C-D-E-G-J-L-N14. A-C-D

15. A-B-D-E-F-G-I-M-N16. A-B-D-E-F-G-J-M-N17. A-B-D-E-F-G-J-L-M-N18. A-B-D-E-F-G-J-L-N19. A-B-C-E-F-G-I-M-N20. A-B-C-E-F-G-J-M-N21. A-B-C-E-F-G-J-L-M-N22. A-B-C-E-F-G-J-L-N

  • 19 -

Block Selection – Try 2 – Example continued