A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej...
-
date post
22-Dec-2015 -
Category
Documents
-
view
219 -
download
0
Transcript of A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej...
![Page 1: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/1.jpg)
A Dynamic Programming Approach to Optimal
Integrated Code Generation
Christoph KeßlerAndrzej Bednarski
Linköping University (Sweden)
![Page 2: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/2.jpg)
Outline Code generation Our integrated approach Implementation and results Current and future work Conclusion
![Page 3: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/3.jpg)
Code Generation
Instru
ctio
n s
ele
ctio
n
Instru
ctio
n s
ele
ctio
n
Instru
ctio
n s
ele
ctio
n
Instru
ctio
n s
ele
ctio
n
IR
Targetcode
IR-levelInstruction scheduling
Target-levelInstruction scheduling
IR-levelInstruction scheduling
Target-levelInstruction scheduling
Targ
et-le
vel
Reg. A
lloc
Targ
et-le
vel
Reg. A
lloc
IR-le
vel
Reg. A
lloc
IR-le
vel
Reg. A
lloc
![Page 4: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/4.jpg)
Related Work Heuristics Optimal approaches
ILP Dynamic programming Branch-and-bound Enumeration Constraint logic programming
![Page 5: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/5.jpg)
Integrated Code Generation
Instru
ctio
n s
ele
ctio
n
Instru
ctio
n s
ele
ctio
n
Instru
ctio
n s
ele
ctio
n
Instru
ctio
n s
ele
ctio
n
IR
Targetcode
IR-levelInstruction scheduling
Target-levelInstruction scheduling
IR-levelInstruction scheduling
Target-levelInstruction scheduling
Targ
et-le
vel
Reg. A
lloc
Targ
et-le
vel
Reg. A
lloc
IR-le
vel
Reg. A
lloc
IR-le
vel
Reg. A
lloc
Integrated
Code generation
![Page 6: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/6.jpg)
Integrated Approach Christoph Keßler’s previous work
Scheduling by topological sorting Dynamic programming Selection DAG
Time profile Extended selection DAGBasic block scope of code generation
![Page 7: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/7.jpg)
Topological Sorting
u
v
scheduled(z)
z
scheduled(z’)
u
v
z’
![Page 8: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/8.jpg)
Selection Tree
h
f g
d e
a b c
{a,b,c}
{b,c} {a,c} {a,b}
a cb
{c,d} {b} {c,d} {a,e} {b} {a,e}
… … … … … …
b c a c a b
![Page 9: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/9.jpg)
Selection DAG Merge multiple instances of same
zero indegree set z in one selection node
Selection DAG Selection DAG is leveled in n+1 levels Each schedule S corresponds to one
path in the selection DAG
![Page 10: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/10.jpg)
Selection DAG
h
f g
d e
a b c
{a,b,c}
{b,c} {a,c} {a,b}
a cb
{c,d} {b} {a,e}
… … …
b c ca ab
![Page 11: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/11.jpg)
Towards Time Optimization Machine model
Generic superscalar/VLIW architecture Single/Multiple issue
From IR level to target level Instruction selection Register allocation (homogenous) Imitate instruction dispatcher
behaviour
![Page 12: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/12.jpg)
Time Profile Window of the instructions scheduled
last for each unit that may still influence future scheduling decisions
e f -
c
t
d
- -
--a
b
-
time
u3u2u1
![Page 13: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/13.jpg)
Extended Selection Node An extended selection node (z, t,
P), summarizes all schedules of scheduled(z) that end with the time profile (t, P).
Pruning (formal proof in the paper)time e f -
c
t
d
- -
--a
b
-
u3u2u1
e f -
c
t’
d
- -b
a
u3u2u1
a f -
c
t’
d
- -b
e
u3u2u1
![Page 14: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/14.jpg)
Extended Selection DAGLevel 0
Level 1
Level 2
...
![Page 15: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/15.jpg)
Solution Space Group the extended
selection nodes in each level according to execution time
Construct solution space in order of increasing time
Postpones the combinatorial explosion
![Page 16: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/16.jpg)
Implementation C++ LEDA XML based architecture description
language LCC as C–front-end
![Page 17: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/17.jpg)
Results – Random DAGs
![Page 18: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/18.jpg)
Results – Random DAGs
![Page 19: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/19.jpg)
Results – FIR Filter
Basic Block
DAG#node
sTime
archi. 1Time
archi. 2
BB1 16 3.5s 4.0s
BB2 16 8.0s 9.5s
BB3 303:21:50.
2s4:40:44.9
s
![Page 20: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/20.jpg)
Results – Matrix Multiplication
Basic Block
DAG#node
sTime
archi. 1Time
archi. 2
BB2 30 1:05.0s 1:41.8s
BB2 (unrolle
d)40 6:08.5s 9:47.2s
![Page 21: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/21.jpg)
Results – Jacobi Grid Relax.
Basic Block
DAG#node
sTime
archi. 1Time
archi. 2
Loop body (5)
40 1:15.8s 1:31.8s
Loop body (9)
531:36:13.2
s2:00:51.5
s
![Page 22: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/22.jpg)
Current and Future Work Time-space profile for irregular
register sets Speculative instruction selection Extensions of architecture
description language Beyond basic block level
Time-space profiles as connector descriptions
![Page 23: A Dynamic Programming Approach to Optimal Integrated Code Generation Christoph Keßler Andrzej Bednarski Linköping University (Sweden)](https://reader035.fdocuments.us/reader035/viewer/2022081514/56649d7f5503460f94a635c3/html5/thumbnails/23.jpg)
Conclusion Goal: fully integrated code generation Dynamic programming approach Time profiles to compress the solution space Improved order of solution space construction Feasible for medium sized basic blocks Potential for extensions Alternative to ILP Home page: www.ida.liu.se/~chrke/optimist