![Page 1: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/1.jpg)
Research in Compilers and How it Relates to Software EngineeringPart I: Compiler Research
Tomofumi Yuki
EJCP 2015June 22, Nancy
![Page 2: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/2.jpg)
Background
Defended Ph.D. in C.S. on October 2012 Colorado State University Advisor: Dr. Sanjay Rajopadhye
Currently Inria Chargé de Recherche Rhône-Alpes, LIP @ ENS Lyon
Optimizing compiler + programming language static analysis (polyhedral model) parallel programming models High-Level Synthesis
2
![Page 3: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/3.jpg)
What is this Course About?
Research in compilers a bit about compiler itself
Understand compiler research what are the problems? what are the techniques? what are the applications?
may be do research in compilers later on!
3
Be able to (partially) understand work by “compiler people” at conferences.
EJCP 2015, June 22, Nancy
![Page 4: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/4.jpg)
What is a Compiler?
What does compiler mean to you?
4
EJCP 2015, June 22, Nancy
![Page 5: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/5.jpg)
Compiler Advances
Old compiler vs recent compiler modern architecture different versions of gcc
How much speedup by compiler alone after 20 years of research?
5
EJCP 2015, June 22, Nancy
![Page 6: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/6.jpg)
Compiler Advances
Old compiler vs recent compiler modern architecture different versions of gcc 2x difference after 20 years (anecdotal)
Not so much?
6
EJCP 2015, June 22, Nancy
![Page 7: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/7.jpg)
Compiler Advances
Old compiler vs recent compiler modern architecture different versions of gcc 2x difference after 20 years (anecdotal)
Not so much?
7
“The most remarkable accomplishment by far of the compiler field is the widespread use of high-level languages.”
by Mary Hall, David Padua, and Keshav Pingali[Compiler Research: The Next 50 Years, 2009]
EJCP 2015, June 22, Nancy
![Page 8: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/8.jpg)
Earlier Accomplishments
Getting efficient assembly register allocation instruction scheduling ...
High-level language features object-orientation dynamic types automated memory management ...
8
EJCP 2015, June 22, Nancy
![Page 9: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/9.jpg)
What is Left?
Parallelism multi-cores, GPUs, ... language features for parallelism
Security/Reliability verification certified compilers
Power/Energy data movement voltage scaling
9
EJCP 2015, June 22, Nancy
![Page 10: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/10.jpg)
Agenda for today
Part I: What is Compiler Research?
Part II: Compiler Optimizations
Part III: Connection to Software Engineering
Lab: Introduction to Loop Transformations
10
EJCP 2015, June 22, Nancy
![Page 11: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/11.jpg)
What is a Compiler?
Bridge between “source” and “target”
11
source targetcompile
EJCP 2015, June 22, Nancy
![Page 12: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/12.jpg)
Compiler vs Assembler
What are the differences?
12
source targetcompile
assembly
objectassemble
EJCP 2015, June 22, Nancy
![Page 13: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/13.jpg)
Compiler vs Assembler
Compiler Many possible targets (semi-portable) Many decisions are taken
Assembler Specialized output (non-portable) Usually a “translation”
13
EJCP 2015, June 22, Nancy
![Page 14: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/14.jpg)
Goals of the Compiler
Higher abstraction No more writing assemblies! enables language features
loops, functions, classes, aspects, ...
Performance while increasing productivity speed, space, energy, ... compiler optimizations
14
EJCP 2015, June 22, Nancy
![Page 15: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/15.jpg)
Productivity vs Performance
Higher Abstraction ≈ Less Performance
15
Performance
Abst
ract
ion
Assembly
Fortran
C
Java
Python
EJCP 2015, June 22, Nancy
![Page 16: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/16.jpg)
Productivity vs Performance
How much can you regain?
16
Performance
Abst
ract
ion
Assembly
Fortran
C
Java
Python Python
Java
C
Fortran
EJCP 2015, June 22, Nancy
![Page 17: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/17.jpg)
Productivity vs Performance
How sloppy can you write code?
17
Performance
Abst
ract
ion
Assembly
Fortran
C
Java
Python
Java
C
Fortran
Python
EJCP 2015, June 22, Nancy
![Page 18: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/18.jpg)
Compiler Research
Branch of Programming Languages Program Analysis, Transformations Formal Semantics Type Theory Runtime Systems Compilers ...
18
EJCP 2015, June 22, Nancy
![Page 19: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/19.jpg)
Current Uses of Compiler
Optimization important for vendors many things are better left to the
compiler parallelism, energy, resiliency, ...
Code Analysis IDEs static vs dynamic analysis
New Architecture IBM Cell, GPU, Xeon-Phi, ...
19
EJCP 2015, June 22, Nancy
![Page 20: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/20.jpg)
Case 1: Register Allocation
Classical optimization problem
20
C = A + B;D = B + C;
load %r1, Aload %r2, Badd %r3, %r1, %r2store %r3, Cload %r1, Bload %r2, Cadd %r3, %r1, %r2store %r3, D
naïve translation
load %r1, Aload %r2, Badd %r1, %r1, %r2store %r1, Cadd %r1, %r2, %r1store %r1, D
smart compilation
3 registers8 instructions
2 registers6 instructions
EJCP 2015, June 22, Nancy
![Page 21: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/21.jpg)
Register Allocation in 5min.
Often viewed as graph coloring
Live Range: when a value is “in use” Interference: both values are “in use”
e.g., two operands of an instruction Coloring: conflicting nodes to different
reg.21
c = a + b;d = b + c;
a b c d
Live Range Analysis
a b
dc
Interference Graph
b
add %r1, %r1, %r2add %r1, %r2, %r1
EJCP 2015, June 22, Nancy
![Page 22: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/22.jpg)
Register Allocation in 5min.
Registers are limited
c = a + b;d = b + c;x = c + d;y = a + x;
a b c d x y
a = load A;c = a + b;d = b + c;x = c + d;z = load A;y = z + x;
a b c d x y z
a b
dc
yx
a b
dc
zx
22
a b
dc
yx
a b
dc
zx
Live Range Splitting
EJCP 2015, June 22, Nancy
22
![Page 23: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/23.jpg)
Research in Register Allocation How to do a good allocation
which variables to split which values to spill
How to do it fast? Graph-coloring is expensive Just-in-Time compilation
23
“Solved”
EJCP 2015, June 22, Nancy
![Page 24: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/24.jpg)
Case 2: Instruction Scheduling Another classical problem
24
X = A * B * C;Y = D * E * F;
R = A * B;X = R * C;S = D * E;Y = S * F;
naïve translation
R = A * B;S = D * E;X = R * C;Y = S * F;
smart compilation
Pipeline Stall(if mult. takes 2
cycles)Also done in
hardware(out-of-order)
EJCP 2015, June 22, Nancy
![Page 25: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/25.jpg)
DAG Scheduling + Resource Constraints
Instruction Scheduling in 5min.
X = A * B * C;Y = D * E * F;
×
A B C
×
X
25
×
D E F
×
Y
Scheduling: - dependences - latency of opsResource Allocation: - #of ALUs - #of mem. requests
EJCP 2015, June 22, Nancy
25
![Page 26: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/26.jpg)
Research in Instruction Scheduling Not much anymore for
speed/parallelism beaten to death hardware does it for you
Remains interesting in specific contexts faster methods for JIT energy optimization “predictable” execution
in-order cores, VLIW, etc.
26
EJCP 2015, June 22, Nancy
![Page 27: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/27.jpg)
Case 1+2: Phase Ordering
Yet another classical problem practically no solution
Given optimization A and B A after B vs A before B which order is better? can you solve the problem globally?
Parallelism requires more memory trade-off: register pressure vs
parallelism
27
EJCP 2015, June 22, Nancy
![Page 28: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/28.jpg)
Case 3: Bug Detection
Static Analysis to help programming
28
short A = 30000;short B = 30000;short C = A + B;
Is there a problem?
EJCP 2015, June 22, Nancy
![Page 29: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/29.jpg)
Case 3: Bug Detection
29
EJCP 2015, June 22, Nancy
![Page 30: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/30.jpg)
Hardware Description ≈ Assembly for HW Still in heavy use!
Case 4: High-Level Synthesis
30
for (i=0; i<N; i++) for (j=i; j<N; j++) C[i] += A[i][j] * B[i];
if j<N-1 i,j+1
if j=N-1 i+1,i
i,j
× C
A
B
+
EJCP 2015, June 22, Nancy
![Page 31: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/31.jpg)
Tracks in PLDI 2015
Correctness Verification Optimization Concurrency I/II Parallelism Performance Synthesis I/II Semantics I/II Analysis Logic
31
EJCP 2015, June 22, Nancy
![Page 32: Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy](https://reader036.vdocuments.us/reader036/viewer/2022081520/56649e765503460f94b77640/html5/thumbnails/32.jpg)
Job Market
Where do they work at? IBM Mathworks amazon start-ups
Many opportunities in France Mathworks @ Grenoble Many start-ups
32
EJCP 2015, June 22, Nancy