Docsity

Control Height Reduction through If-Conversion and Branch Prediction in EECS 583 - Prof. S, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download Control Height Reduction through If-Conversion and Branch Prediction in EECS 583 - Prof. S and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

EECS 583 – Lecture 6 Hyperblocks, Control CPR

University of Michigan January 27, 2003

  • 1 -

Homeworks^ Y^

HW 1 due today @11:59pm Y No 4

th^ testcase – I didn’t get around to it

Y^ scp tar file to lloth.eecs.umich.edu^ »

Please don’t email it to me » user = eecs583 » password is same » Create tar file, uniquename.tgz » put in /y/eecs583/hw1^ y^

scp mahlke.tgz [email protected]:/y/eecs583/hw1/.

Y^ HW 2 is available – Due in 2 wks

  • 3 -

Region Formation + If-conversion

BB2 BB4 BB

BB5’

BB

BB

64.^

BB4’^2028 BB6’

2.^

Y^ Control flow representation^ »

branches » predicated operations

Y^ If-conversion not all all ornothing deal^ »

Often bad to apply in blanketmode » Selectively apply

Y^ Regions^ »

Extend a superblock tocontain if-converted code » Convert off-trace transitionsto on-trace » A hyperblock is born » Superblock is a special caseHB where all guardingpredicates are True

  • 4 -

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

BB

BB4 BB

BB

BB

BB

  • 6 -

Negative 2: Dependence Height Dependence height is max of for all BBs that are if-converted (dep height = schedule length with infinite resources)

Case 1: height(bb1) = 1, height(bb2) = 3 Height(bb3) =

^9 , height(bb4) = 2 No IC: 11 + .63 + .49 + 12 = 8.4 IC: 11 + 1MAX(3,9) + 1*3 = 13

BB

60 BB

BB^

Case 2: height(bb1) = 1, height(bb2) = 3 Height(bb3) =

^3 , height(bb4) = 2 No IC: 11 + .63 + .43 + 12 = 6 IC: 11 + 1MAX(3,3) + 1*2 = 6 BB

BB2 if p BB^

BB3 if p2^ BB

100

  • 7 -

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)

BB

60 BB

BB^

BB

BB2 if p BB^

BB3 if p2^ BB

100

  • 9 -

The Hyperblock^ Y^

Hyperblock

  • Collection of

basic blocks in which controlflow may only enter at the firstBB.^ All internal control flowis eliminated via if-conversion^ »^ “Likely control flow paths

»^ Acyclic (outer backedge ok) »^ Multiple intersecting traceswith no side entrances »^ Side exits still exist Y Hyperblock formation »^ 1. Block selection »^ 2. Tail duplication »^ 3. If-conversion

BB

BB4 BB

BB

BB

BB

  • 10 -

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

BB

BB4 BB

BB

BB

BB

  • 12 -

Example - Step 1 - Block Selection

main path = 1,2,4,

num_ops = 5 + 8 + 3 + 2 = 18 weight = 80 Calculate the BSVs for BB3, BB5 assuming no hazards, K = 4 BSV3 = 4 x (20 / 2) x (18 / 80) = 9 BSV5 = 4 x (10 / 5) x (18 / 80) = 1.8 If Threshold = 2.0, select BB3 along with main path 10 BB2 - 8

80 BB4 - 3^ BB6 - 2

BB5 - 5

BB1 - 5 80

BB3 – 2

  • 13 -

Example - Step 2 - Tail Duplication

Tail duplication same as with Superblock formation 10 BB

80 BB4^ BB

BB

BB

20 BB

BB

80 BB4^ BB

BB

BB

10 BB

10 BB6’^9

  • 15 -

Hyperblock Performance Evaluation (1)^ Y^

O = BB code Y IP = Structural if-conversion^ »^ All innermost loops, acyclic SEME regions Y PP = Selective if-conversion

  • 16 -

Class Problem

Form the HB for this subgraph Assume K = 4, BSV Threshold = 2

BB2 - 8

BB4 - 2

55

10 10

35

BB7 -

20 BB5 - 3

100 80 BB1- 3 20

80 BB3 - 2

45

55 BB6 - 2

35 BB8 -2^ BB9 -

  • 18 -

Block Selection – Try 2 (continued)^ Y^

Path selection^ »^ Rank paths from highest to lowest priority^ »^ Include paths until either:

y^ Estimated available resources full y^ Priority drops too low » Exclude any paths with excessive resource util or dep height

Y^ Use union of selected paths to form Hyperblock^ »

Causes some lower priority paths to be included

  • 19 -

Block Selection - Try 2 - Example

Enumerate all paths, rank by priority

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