05-Superblocks

5
8/6/2019 05-Superblocks http://slidepdf.com/reader/full/05-superblocks 1/5 Lecture 5: Lecture 5: Superblocks Superblocks COS 598C COS 598C –  – Advanced Compilers Advanced Compilers Prof. David August COS 598C - Advanced Compilers Regions Regions   ! "#$%& "'()*(& Prof. David August COS 598C - Advanced Compilers Regions (2) Regions (2) + ,! -- . /!0 . 1 .0"& Prof. David August COS 598C - Advanced Compilers Region Type 1 Region Type 1 –  – Trace Trace 2 $ 3 0 435  " & . 6 . 6 *((7 89"::; & BB2 BB4 BB6 BB5 BB1 BB3 80 20 10 90 10 90 10 80 20 10

Transcript of 05-Superblocks

Page 1: 05-Superblocks

8/6/2019 05-Superblocks

http://slidepdf.com/reader/full/05-superblocks 1/5

Lecture 5:Lecture 5: SuperblocksSuperblocks

COS 598CCOS 598C –  – Advanced CompilersAdvanced Compilers

Prof. David AugustCOS 598C - Advanced Compilers

RegionsRegions

 

!

"#$%&

"'()*(&

Prof. David AugustCOS 598C - Advanced Compilers

Regions (2)Regions (2)

+ ,!

--

.

/!0

. 1

.0"&

Prof. David AugustCOS 598C - Advanced Compilers

Region Type 1Region Type 1 –  – TraceTrace

2 $ 30

435 

" &

. 6

. 6

*((7

89"::;&

BB2

BB4

BB6

BB5

BB1

BB3

80 20

10

90

10

90

10

80 20

10

Page 2: 05-Superblocks

8/6/2019 05-Superblocks

http://slidepdf.com/reader/full/05-superblocks 2/5

Prof. David AugustCOS 598C - Advanced Compilers

LinearizingLinearizing a Tracea Trace

BB2

BB4

BB6

BB5

BB1

BB3

80 20 (side exit)

10 (side exit)

90

10 (entry count)

90 (entry/ 

exit count)

10 (exit count)

8020 (side entrance)

10 (side entrance)

Prof. David AugustCOS 598C - Advanced Compilers

Intelligent Trace Layout for IIntelligent Trace Layout for I--Cache PerformanceCache Performance

BB2

BB4

BB6

BB5

BB1

BB3

trace1

trace 2

trace 3

The rest

Intraprocedural code placement

Procedure positioning

Procedure splitting

Procedure viewTrace view

Prof. David AugustCOS 598C - Advanced Compilers

Issues With Selecting TracesIssues With Selecting Traces

2

3<=

>- /$)$

8!$

8!$

$*((7" &

$

2"&

3 3

BB2

BB4

BB6

BB5

BB1

BB3

80 20

10

90

10

90

10

80 20

10

Prof. David AugustCOS 598C - Advanced Compilers

Trace Selection AlgorithmTrace Selection Algorithm

i = 0;

mark all BBs unvisited

while (there are unvisited nodes) do

seed = unvisited BB with largest execution freq

trace[i] += seed

mark seed visited

current = seed

 /* Grow trace forward */ 

while (1) do

next = best_successor_of(current)

if (next == 0) then break 

trace[i] += next

mark next visited

current = next

endwhile

 /* Grow trace backward analogously */ i++

endwhile

Page 3: 05-Superblocks

8/6/2019 05-Superblocks

http://slidepdf.com/reader/full/05-superblocks 3/5

!Prof. David AugustCOS 598C - Advanced Compilers

Best Successor/PredecessorBest Successor/Predecessor

>9:

2./31

$

?($@(7

>

*

9

8" *((&

 best_successor_of(BB)

e = control flow edge with highest

 probability leaving BB

if (e is a backedge) then

return 0endif

if (probability(e) <= THRESHOLD) then

return 0

endif

d = destination of e

if (d is visited) then

return 0

endif

return d

endprocedure

"Prof. David AugustCOS 598C - Advanced Compilers

Class Problem 1Class Problem 1

BB2

BB4

BB6

BB5

BB1

BB3

20 80

100

450

20 80

BB3

BB6

BB6

51 49

49

10

41

10

41

Find the traces. Assume

a threshold probability

of 60%.

#Prof. David AugustCOS 598C - Advanced Compilers

Class Problem 2Class Problem 2

BB1

100

BB2 BB3

BB5 BB6BB4

BB7

BB8

40

135 100

35

75

25

25

50 10 5

60

15

100

Find the traces. Assume

a threshold probability of 60%.

Prof. David AugustCOS 598C - Advanced Compilers

Traces are Nice, But …Traces are Nice, But …

2

2)

,

A

.

.

.

2

BB2

BB4

BB6

BB5

BB1

BB3

80 20

10

90

10

90

10

80 20

10

Page 4: 05-Superblocks

8/6/2019 05-Superblocks

http://slidepdf.com/reader/full/05-superblocks 4/5

Prof. David AugustCOS 598C - Advanced Compilers

Region Type 2Region Type 2 –  – SuperblockSuperblock

. $ 30

 

435 

" &

2

.

.

*:2

B:

BB2

BB4

BB6

BB5

BB1

BB3

80 20

10

90

10

90

10

80 20

10

Prof. David AugustCOS 598C - Advanced Compilers

Tail DuplicationTail Duplication

245

,

8<B$*

C

BB2

BB4

BB6

BB5

BB1

BB3

80 20

10

90

10

90

10

80 20

10

Prof. David AugustCOS 598C - Advanced Compilers

Superblock FormationSuperblock Formation

BB2

BB4

BB6

BB5

BB1

BB3

80 20

10

90

10

90

10

80 20

10

BB2

BB4

BB6

BB5’

BB1

BB3

80 20

8

72

10

64.8

7.2

80 20

26

BB6’

BB4’

18

2.8 25.2

2

Prof. David AugustCOS 598C - Advanced Compilers

Issues withIssues with SuperblocksSuperblocks

 

.

9

!

809.

.

*:(6 *:*(.

BB2

BB4

BB6

BB5’

BB1

BB3

80 20

8

72

10

64.8

7.2

80 20

26

BB6’

BB4’

18

2.8 25.2

2

Page 5: 05-Superblocks

8/6/2019 05-Superblocks

http://slidepdf.com/reader/full/05-superblocks 5/5

Prof. David AugustCOS 598C - Advanced Compilers

Class Problem 3Class Problem 3

BB2

BB4

BB7

BB5

BB1

BB3

20 80

100

450

20 80

BB6

BB8

BB9

51 49

49

10

41

10

41

Create the superblocks, trace

threshold is 60%