Download presentation

Presentation is loading. Please wait.

Published byNoemi Legate Modified over 2 years ago

1
Constraint Programming for Compiler Optimization March 2006

2
2 Acknowledgements Joint work with: Alexander Golynski Alejandro López-Ortiz Abid Malik Jim McInnes Claude-Guy Quimper John Tromp Kent Wilken Funding: NSERC IBM Canada

3
3 Optimization problems in compilers Instruction selection Instruction scheduling ·basic-block instruction scheduling ·super-block scheduling ·software pipelining & loop unrolling Register allocation Memory hierarchy optimizations

4
4 Basic-block instruction scheduling Schedule basic-block ·straight-line sequence of code with single entry, single exit Multiple-issue pipelined processors ·multiple instructions can begin execution each clock cycle ·delay or latency before results are available Find minimum length schedule Classic problem ·lots of attention in literature

5
5 Example: (a + b) + c instructions A r1 a B r2 b C r3 c D r1 r1 + r2 E r1 r1 + r3 33 31 AB DC E dependency DAG

6
6 Single-issue pipelined processor non-optimal schedule Ar1 a Br2 b nop Dr1 r1 + r2 Cr3 c nop Er1 r1 + r3 AB DC E 33 31 dependency DAG

7
7 Single-issue pipelined processor optimal schedule Ar1 a Br2 b Cr3 c nop Dr1 r1 + r2 Er1 r1 + r3 AB DC E 33 31 dependency DAG

8
8 Multiple-issue pipelined processor AB DC E 33 31 dependency DAG A issue width is 2 1 5 4 3 2 BCDE

9
9 Multiple-issue pipelined processor AB DC E 33 31 dependency DAG A issue width is 1+1 1 5 4 3 2 CBD E 6

10
10 Production compilers “At the outset, note that basic-block scheduling is an NP-hard problem, even with a very simple formulation of the problem, so we must seek an effective heuristic, rather than exact, approach.” Steven Muchnick, Advanced Compiler Design & Implementation, 1997

11
11 Optimal approaches state-of-the-art Single-issue Previous ·10-40 instructions ILP (Arya, 1985) CP (Ertl & Krall, 1991) ·up to 1000 instructions ILP (Wilken et al, 2000) Our work ·up to 2600 instructions ·20 × faster Multiple-issue Previous ·10-40 instructions ILP (Chang et al., 1997) DP (Kessler, 1998) ·up to 1000 instructions B&B (Heffernan et al., 2005) Our work ·up to 2600 instructions ·50-fold improvement

12
12 Constraint programming methodology Model problem ·specify in terms of constraints on acceptable solutions ·define/choose constraint model: variables, domains, constraints Solve model ·define/choose search algorithm ·define/choose heuristics

13
13 Constraint programming methodology Model problem ·specify in terms of constraints on acceptable solutions ·define/choose constraint model: variables, domains, constraints Solve model ·define/choose search algorithm ·define/choose heuristics

14
14 Minimal constraint model variables A, B, C, D, E domains {1, …, m} constraints D A + 3 D B + 3 E C + 3 E D + 1 gcc(A, B, C, D, E, width) AB DC E 33 31 dependency DAG

15
15 Bounds consistency constraint propagation [1, 3] [4, 6] variable A B C D E domain [1, 6] D A + 3 constraints [4, 5] [1, 3] [4, 6] [1, 3] [1, 2] D B + 3 E C + 3 E D + 1 gcc(A, B, C, D, E, 1) [5, 6] [1, 2] [3, 3] [6, 6]

16
16 Improvements to constraint model 1. Distance constraints constraints over nodes which define regions 2. Predecessor and successor constraints constraints over nodes with multiple predecessors or multiple successors 3. Safe pruning constraint global constraint 4. Dominance constraints constraints based on graph isomorphism

17
17 Improvements to constraint model 1. Distance constraints constraints over nodes which define regions 2. Predecessor and successor constraints constraints over nodes with multiple predecessors or multiple successors 3. Safe pruning constraint global constraint 4. Dominance constraints constraints based on graph isomorphism

18
18 Distance constraints: Regions A pair of nodes i, j define a region in a DAG G if: (i) there is more than one path from i to j, and (ii) not all paths from i to j go through some node k distinct from i and j. i j

19
19 Distance constraints: Estimate A B ED H FG C 1 1 1 3 3 1 3 1 3

20
20 Distance constraints: Estimate A B ED H FG C 1 1 1 3 3 1 3 1 3 jj+1j+2j+3j+4j+5 5 A F

21
21 Distance constraints: Estimate A B ED H FG C 1 1 1 3 3 1 3 1 3 jj+1j+2j+3j+4j+5 E H 5

22
22 Distance constraints: Estimate A B ED H FG C 1 1 1 3 3 1 3 1 3 9 A jj+1j+2j+3j+4j+5 j+6j+7j+8j+9 H

23
23 Distance constraints: Optimal A B ED H FG C 1 1 1 3 3 1 3 1 3 [1,1] [10,10] [2,3] [5,6] [6,7] [2,3] propagate latency propagate all-diff Not optimal: A 1 H 10 Estimate: H A + 9

24
24 Distance constraints: Optimal Optimal: H A + 10 A B ED H FG C 1 1 1 3 3 1 3 1 3 [1,1] [10,10] [2,3] [5,6] [6,7] [2,3] propagate latency Not optimal: A 1 H 10 Estimate: H A + 9 propagate all-diff inconsistent

25
25 Improvements to constraint model 1. Distance constraints constraints over nodes which define regions 2. Predecessor and successor constraints constraints over nodes with multiple predecessors or multiple successors 3. Safe pruning constraint global constraint 4. Dominance constraints constraints based on graph isomorphism

26
26 Predecessor constraints [4, ] 3 1 A B DCE H FG 3 3 2 2 1 1 1 [,14] [5,9] [8,12] [9,12] [5,9][6,9] [5,8] 7 11

27
27 Predecessor constraints DE G A B C H F [4, ] 1 1 3 1 2 1 2 [,14] 3 3 [5,9] [8,12] [9,12] [5,9][6,9] [5,8] 7 11 [9,12] 56789

28
28 Predecessor constraints [4, ] 3 1 A B DCE H FG 3 3 2 2 1 1 1 [,14] [5,9] [8,12] [9,12] [5,9][6,9] [5,8] 7 11 [9,12] [12,14] 9101112

29
29 Successor constraints [4, ] 3 1 A B DCE H FG 3 3 2 2 1 1 1 [,14] [5,9] [8,12] [9,12] [5,9][6,9] [5,8] 7 11 [9,12] [12,14] [4,6] 6789

30
30 Constraint programming methodology Model problem ·specify in terms of constraints on acceptable solutions ·define/choose constraint model: variables, domains, constraints Solve model ·define/choose search algorithm ·define/choose heuristics

31
31 Solving instances of the model Use constraints to establish: ·lower bound on length m of optimal schedule ·min and max of domains of variables Backtracking search ·branches on min(x), min(x)+1, … ·interleave with bounds consistency constraint propagation ·fallback: singleton consistency on bounds If no solution found, increment m and repeat search

32
32 Solving instances of the model A B C D 1245 E AB DC E 33 31 [1,5]

33
33 Solving instances of the model A B C D 1245 E AB DC E 33 31 [ ]

34
34 Solving instances of the model A B C D 1256 E AB DC E 33 31 [1,6]

35
35 Solving instances of the model A B C D 1256 E AB DC E 33 31 [1,2] [5,5][3,3] [6,6]

36
36 Improvements to constraint solver Design special purpose constraint propagators ·commonly occurring constraints ·significantly improve efficiency Improved algorithms for bounds consistency ·all-diff constraint ·gcc constraint

37
37 Comparing all-diff propagators (prototype) Time (sec.) to solve instruction scheduling problems; model includes latency, distance, and all-diff constraints. DC: Régin, 1994; MT: Mehlhorn & Thiel, 2000; BC: IJCAI-2003

38
38 Comparing gcc propagators (prototype) Time (sec.) to solve instruction scheduling problems; model includes latency and gcc constraints; width is 2. DC: Régin, 1996; vH: van Hentenryck et al., 1992; BC: CP-2003

39
39 Putting it all together: Experimental results SPEC 2000 & MediaBench Benchmarks Total of 352,111 basic blocks of size 3 or greater Improved = improved schedule over heuristic scheduler Timed out = not solved within 10 minutes

40
40 Putting it all together: Experimental results SPEC 2000 & MediaBench Benchmarks For basic blocks with improved schedules

41
41 Conclusions CP approach to instruction scheduling ·Single-issue processors 20-times faster than previous best optimal approach ·Multiple-issue processors larger and more difficult problems 50-fold reduction in number of problems that cannot be solved Constraint propagators ·faster all-diff and gcc constraint propagators ·useful in many problems

42
42 Current and future work: Expand scope of problem Instruction selection Instruction scheduling ·basic-block instruction scheduling ·super-block scheduling ·software pipelining & loop unrolling Register allocation Memory hierarchy optimizations

Similar presentations

OK

Optimal Instruction Scheduling for Multi-Issue Processors using Constraint Programming Abid M. Malik and Peter van Beek David R. Cheriton School of Computer.

Optimal Instruction Scheduling for Multi-Issue Processors using Constraint Programming Abid M. Malik and Peter van Beek David R. Cheriton School of Computer.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on weapons of mass destruction iraq Ppt on marketing strategy of coca cola in india Ppt on combination of resistances in series Ppt on statistics and probability tutorial Ppt on teacher's day messages Ppt on limits and derivatives in calculus Ppt on flora and fauna of kerala Action words for kids ppt on batteries Ppt on embedded c programming Ppt on media research panel