Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi...
-
Upload
nathan-johnston -
Category
Documents
-
view
218 -
download
0
Transcript of Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi...
Research in Compilers and How it Relates to Software EngineeringPart I: Compiler Research
Tomofumi Yuki
EJCP 2015June 22, Nancy
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
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
What is a Compiler?
What does compiler mean to you?
4
EJCP 2015, June 22, Nancy
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
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
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
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
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
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
What is a Compiler?
Bridge between “source” and “target”
11
source targetcompile
EJCP 2015, June 22, Nancy
Compiler vs Assembler
What are the differences?
12
source targetcompile
assembly
objectassemble
EJCP 2015, June 22, Nancy
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
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
Productivity vs Performance
Higher Abstraction ≈ Less Performance
15
Performance
Abst
ract
ion
Assembly
Fortran
C
Java
Python
EJCP 2015, June 22, Nancy
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
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
Compiler Research
Branch of Programming Languages Program Analysis, Transformations Formal Semantics Type Theory Runtime Systems Compilers ...
18
EJCP 2015, June 22, Nancy
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
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
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
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
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
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
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
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
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
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
Case 3: Bug Detection
29
EJCP 2015, June 22, Nancy
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
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
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