40
Adopt a Polyhedral Compiler! IMPACT 2013 Workshop Albert Cohen INRIA and ´ Ecole Normale Sup´ erieure, Paris http://www.di.ens.fr/ParkasTeam.html

Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Adopt a Polyhedral Compiler!

IMPACT 2013 Workshop

Albert Cohen

INRIA and Ecole Normale Superieure, Parishttp://www.di.ens.fr/ParkasTeam.html

Page 2: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

People Have Great Expectations

Accelerating legacy code for ever

Simplifying compiler construction and library generation

Peak performance at the touch of a button

Proving program transformations

Code generation for heterogeneous architectures

High-level circuit synthesis

Publishing great papers

[ Name your own dream project here ]

2 / 27

Page 3: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

There Were, and Will Be Times in the Wilderness...

3 / 27

Page 4: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

But the World Will Eventually Turn Polyhedral!

Courtesy www.progonos.com/furuti4 / 27

Page 5: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Lost Memories in the Not-Yet-Polyhedral World

DDR3-2133 SDRAM

Latency: 10.3 ns

Memory bandwidth: 17.6 GB/s

4-core 2GHz ARM Cortex A15

Compute bandwidth: 2 × 4 threads × 1 NEON unit × 16 bytes × 2 GHz = 1024 GB/s

8-core 3GHz AMD Opteron

Compute bandwidth: 2 × 8 threads × 2 SSE units × 16 bytes × 3 GHz = 1536 GB/s

Memory bandwidth: 17.6 GB/s

256-core 400MHz Kalray MPPA

Compute bandwidth: 2 × 256 threads × 2 words × 4 bytes × 400 MHz = 1638.4 GB/s

1536-core 1.006GHz NVIDIA Kepler

Compute bandwidth: 2 × 1536 threads × 1 float × 4 bytes × 1.006 GHz = 12361.6 GB/s

Memory bandwidth: 190 GB/s

5 / 27

Page 6: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Many Candidates for Adoption

B What are the essential semantic requirements for source programs?

B Should programmers careAbout parallelism?About the memory and power walls?

B Which programmers?

B What role for the software stack?CompilersRuntime systemsLibraries, library generatorsAuto-tuning, dynamic optimizationOperating system, virtual machine monitor

B What role for the polyhedral tools?

6 / 27

Page 7: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Challenges for apolyhedral world

Modularity,genericity,functional

abstraction

Domain-specific

languages

Accelerators,vectorization,

distributedmemory

Data-dependent

control flow,dynamicanalysis

Scalability,just-in-timecompilation

Task-leveloptimiza-

tions,stream-

computing

7 / 27

Page 8: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

State-of-the-Art Tool: PPCG – Polyhedral Parallel Code Generator

PPCG (http://freecode.com/projects/ppcg)

Input: C

Output:I OpenMPI CUDAI OpenCL (soon)

Steps:

Extract polyhedral model from source code (pet,isl)

Dependence analysis (isl)

Scheduling (isl)I Expose parallelism and tiling opportunitiesI Separate schedule into parts mapped on host and GPUI perform tiling, mapping outer parallel dimensions to blocks and inner parallel

dimensions to threads

Memory management (isl)I Add transfers of data to/from GPU (isl)I Detect array reference groupsI Allocate groups to registers and shared memory

Generate AST (isl)

8 / 27

Page 9: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

State-of-the-Art Tool: PPCG – Polyhedral Parallel Code Generator

PPCG (http://freecode.com/projects/ppcg)

Input: C

Output:I OpenMPI CUDAI OpenCL (soon)

Steps:

Extract polyhedral model from source code (pet,isl)

Dependence analysis (isl)

Scheduling (isl)I Expose parallelism and tiling opportunitiesI Separate schedule into parts mapped on host and GPUI perform tiling, mapping outer parallel dimensions to blocks and inner parallel

dimensions to threads

Memory management (isl)I Add transfers of data to/from GPU (isl)I Detect array reference groupsI Allocate groups to registers and shared memory

Generate AST (isl)

8 / 27

Page 10: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

PPCG Example – Input

Source code:

void matmul(int M, int N, int K,float A[static const restrict M][K],float B[static const restrict K][N],float C[static const restrict M][N])

{for (int i = 0; i < M; i++)for (int j = 0; j < N; j++) {

S1: C[i][j] = 0;for (int k = 0; k < K; k++)

S2: C[i][j] = C[i][j] + A[i][k] * B[k][j];}

}

Options:

--ctx="[M,N,K] -> { : M = N = K = 256 }"--sizes="{ kernel[i] -> tile[16,16,16];

kernel[i] -> block[8,16] }"

9 / 27

Page 11: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

PPCG Example – Output

Kernel code: (host code not shown)

int b0 = blockIdx.y, b1 = blockIdx.x;int t0 = threadIdx.y, t1 = threadIdx.x;__shared__ float s_A[16][16];__shared__ float s_B[16][16];float p_C[2][1];

p_C[0][0] = C[(16 * b0 + t0) * (256) + 16 * b1 + t1];p_C[1][0] = C[(16 * b0 + t0 + 8) * (256) + 16 * b1 + t1];for (int g9 = 0; g9 <= 240; g9 += 16) {for (int c0 = t0; c0 <= 15; c0 += 8)s_B[c0][t1] = B[(g9 + c0) * (256) + 16 * b1 + t1];

for (int c0 = t0; c0 <= 15; c0 += 8)s_A[c0][t1] = A[(16 * b0 + c0) * (256) + t1 + g9];

__syncthreads();if (g9 == 0) {p_C[0][0] = (0);p_C[1][0] = (0);

}for (int c2 = 0; c2 <= 15; c2 += 1) {p_C[0][0] = (p_C[0][0] + (s_A[t0][c2] * s_B[c2][t1]));p_C[1][0] = (p_C[1][0] + (s_A[t0 + 8][c2] * s_B[c2][t1]));

}__syncthreads();

}C[(16 * b0 + t0) * (256) + 16 * b1 + t1] = p_C[0][0];C[(16 * b0 + t0 + 8) * (256) + 16 * b1 + t1] = p_C[1][0];

10 / 27

Page 12: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

PPCG Results

corr

ela

tion

cova

rian

c e

2m

m

3m

m

bic

g

do

itge

n

ge

mm

ge

mve

r

ge

sum

mv

gra

msc

hm

idt lu

mvt

sym

m

syr2

k

syrk

tra

nsp

ose ad

i

fdtd

-2d

jaco

bi-1

d-im

pe

r

jaco

bi-2

d-im

pe

r

ge

om

etr

ic m

ea

n

0.1

1

10

100

1000Pluto OpenMPPar4AllPPCG

Sp

ee

du

p

Benchmarks: PolyBench 3.1

Platform: Tesla M2070

Baseline: sequential CPU execution gcc -Ofast

Attend Carlos Juega’s talk on Wednesday morning!

11 / 27

Page 13: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

CARP EU Project

w/ ARM, RealEyes, Rightware, Monoidics,

Imperial College, RWTH Aachen, U. Twente

Compiler construction for DSLs:support for parallelization,vectorization, loop transformation...

Reconcile advanced loop nestoptimizations and softwareengineering practices

Image processing

DSL

Linear algebra

DSL

Other DSLs

.PIL .PIL .PIL

Compiled PIL

.PIL .PIL .PIL

Hand-written PIL

OpenCV.PIL

MathLib.PIL

Other PIL libs

PIL

libra

ries

...

...

Portable Intermediate Language (PIL)

Single blob of optimised PIL

PIL Cross-Component Optimiser

Kernel fusion, memory reuse, iteration-space optimisations

DSL → PIL Compilers

Polyhedral representation

Polyhedral analysis

Performance data, from profiling

Optimised, power-efficient,

parallel OpenCL

.CL .CL .CL

Hand-Written OpenCL

.CL

.CL

.CL

...

Op

en

CL

libs

OpenCV.PIL

MathLib.PIL

Other PIL libs

PIL

libra

ries

...

ARM Mali Platform

NVIDIA GPUs

AMD GPUs

Other OpenCL-enabled

accelerators

Vendor-specific OpenCL drivers

Optimising, Auto-parallelizing, Power-aware Polyhedral Compiler

Compiler employs code-based cost analysis techniques

Profile-based Iterative Compilation and Auto-tuning

Accelerator Hardware

Domain Specific Languages

12 / 27

Page 14: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

DSLs to the Rescue

Problem: general purpose languages are not optimization-friendlyI much static semantics is lostI much domain information is lostI high expressiveness → ambiguitis disable optimizations (e.g., pointer aliasing)

Some DSLs are designed primarily for abstraction and productivity→ we are interested in the performance-focused DSLs

But compiling DSLs directly into OpenCL or CUDA is not advisable

Approach: target an appropriate intermediate language (IL) and leverage a genericoptimization framework

13 / 27

Page 15: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Zooming in on Pencil

14 / 27

Page 16: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Pencil: a Platform-Neutral Compute Intermediate Language

An intermediate language for DSL compilers

C-based intermediate language

Code regions specifically marked as Pencil-compliant

Sequential, platform neutral

A set of coding rules, language extensions and directives

Planning for an LLVM IR version of Pencil

Complementary objectives to DSL intermediate languages such as Delite IR

Design goals

Unlock the power of optimization frameworks byI keeping a maximum of information expressed by the DSLI eliminating ambiguity for optimizers

Users: Code generators + expert developers

15 / 27

Page 17: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Platform-Neutral Compute Intermediate Languages

Coding rules for Pencil functions

I cannot be recursiveI no gotosI no pointersI array arguments should be declared with static const

restrict inferred through automatic versioningI dedicated types and builtins for dynamic analysis (work in progress)

Language extensions (C11-compatible)

I access summary functionsI describe access pattern of a function if static analysis cannot be performed (no source or not

Pencil compliant) or if the results are too inaccurateI modular interprocedural information used in the caller through “polyhedral inlining”

Directives

I #pragma pencil independent [(l1, . . . , ln)]

listed statements (all if unspecified) do not carry any dependences across the loopfollowing the directive

16 / 27

Page 18: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Platform-Neutral Compute Intermediate Languages

Coding rules for Pencil functionsI cannot be recursiveI no gotosI no pointersI array arguments should be declared with static const

restrict inferred through automatic versioningI dedicated types and builtins for dynamic analysis (work in progress)

Language extensions (C11-compatible)

I access summary functionsI describe access pattern of a function if static analysis cannot be performed (no source or not

Pencil compliant) or if the results are too inaccurateI modular interprocedural information used in the caller through “polyhedral inlining”

Directives

I #pragma pencil independent [(l1, . . . , ln)]

listed statements (all if unspecified) do not carry any dependences across the loopfollowing the directive

16 / 27

Page 19: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Platform-Neutral Compute Intermediate Languages

Coding rules for Pencil functionsI cannot be recursiveI no gotosI no pointersI array arguments should be declared with static const

restrict inferred through automatic versioningI dedicated types and builtins for dynamic analysis (work in progress)

Language extensions (C11-compatible)I access summary functions

I describe access pattern of a function if static analysis cannot be performed (no source or notPencil compliant) or if the results are too inaccurate

I modular interprocedural information used in the caller through “polyhedral inlining”

Directives

I #pragma pencil independent [(l1, . . . , ln)]

listed statements (all if unspecified) do not carry any dependences across the loopfollowing the directive

16 / 27

Page 20: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Platform-Neutral Compute Intermediate Languages

Coding rules for Pencil functionsI cannot be recursiveI no gotosI no pointersI array arguments should be declared with static const

restrict inferred through automatic versioningI dedicated types and builtins for dynamic analysis (work in progress)

Language extensions (C11-compatible)I access summary functions

I describe access pattern of a function if static analysis cannot be performed (no source or notPencil compliant) or if the results are too inaccurate

I modular interprocedural information used in the caller through “polyhedral inlining”

DirectivesI #pragma pencil independent [(l1, . . . , ln)]

listed statements (all if unspecified) do not carry any dependences across the loopfollowing the directive

16 / 27

Page 21: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Example of Pencil code

int function(int A[static const restrict 100][100],int C[static const restrict 100][100]) {

#pragma pencil independentfor (int k = 0; k < N; k++)for (int j = 0; j < N; j++)A[k][t[j]] = foo(C);

}

17 / 27

Page 22: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Example of Pencil code

void foo_summary(int C[static const restrict n][n]) {for (int i=0; i<n; i++)USE(C[i]); // marks row i of C as being read

}

void foo(int C[const restrict n][n])ACCESS(foo_summary(C));

int function(int A[static const restrict 100][100],int C[static const restrict 100][100]) {

#pragma pencil independentfor (int k = 0; k < N; k++)for (int j = 0; j < N; j++)A[k][t[j]] = foo(C);

}

18 / 27

Page 23: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Modularity, Genericity, Functional Abstraction, and DSLs

Short-termI Functional abstraction → inliningI Genericity → specialization, partial evaluationI Modularity → staged programs: write program generatorsI ... a roadmap for a DSL compiler builder

cf. NumPy, pythran, C++ template metaprogramming (TaskGraph library,RapidMind/ArBB), Delite (Scala), Halide, OP2, MetaOCaml experiments...

Long-termI Support function-level fusion, vectorization, tiling

cf. Kennedy’s Telescoping LanguagesI On-demand function cloning rather than inlining

19 / 27

Page 24: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

What Else Do You Want From a Polyhedral Compiler?

Complex transformations

Scalability

Just-in-time and split compilation

Auto-tuning

Dynamic analysis, optimistic transformations

Adaptation and optimization of parallel code

20 / 27

Page 25: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

What Else Do You Want From a Polyhedral Compiler?

Complex transformations

Scalability

Just-in-time and split compilation

Auto-tuning

Dynamic analysis, optimistic transformations

Adaptation and optimization of parallel code

20 / 27

Page 26: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

What Else Do You Want From a Polyhedral Compiler?

Complex transformations

Scalability

Just-in-time and split compilation

Auto-tuning

Dynamic analysis, optimistic transformations

Adaptation and optimization of parallel code

20 / 27

Page 27: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Complex Transformations

E.g., split tiling, diamond tiling, overlapped tiling...

0 2 4 6 8 10 12 14 16i

0

2

4

6

8

10

12

14

16

j

Split Tiling (non-simplified), t=1

0 2 4 6 8 10 12 14 16i

0

2

4

6

8

10

12

14

16

j

Split Tiling (non-simplified), t=2

0 2 4 6 8 10 12 14 16i

0

2

4

6

8

10

12

14

16

j

Split Tiling (non-simplified), t=3

More complex?

Instancewise code generation options

Scripting affine transformations

[ Your crazy idea here ]

21 / 27

Page 28: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Scalability: Sub-Polyhedral Approximations

Interval

Octagon (UTVPI) TVPI Convex Polyhedra

a 6 xi 6 b ±xi ± xj 6 c axi + bxj 6 c∑

aixi 6 c

Precision−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−→Intervals ⊂ Octagons (UTVPI) ⊂ TVPI ⊂ Polyhedra−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−→

Cost

22 / 27

Page 29: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Scalability: Sub-Polyhedral Approximations

Replace linear programming(Simplex) with Bellman Ford

O(mn3) O(mn)

Applicable to dependence analysis,code generation:over-approximation

Applicable to affine scheduling:under-approximation

Preserving feasibility of polyhedrais a tough challenge for some affinescheduling problems

(Unrolled) Gauss-Seidel benchmarkAutomatic parallelization with PLuTo

0 1000 2000 3000 4000 5000 6000

0.0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

Time taken to Solve System (Seconds) vs. Number of Dependences

Dependences

Tim

e t

ake

n (

Se

co

nd

s)

Solve (SCoP)

PIP (SEI)BF (SEI)

23 / 27

Page 30: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Just-in-Time and Split Compilation

Tools could do a lot better, if provided with enough choice and precise information

Automatic Choice

AlgorithmicChoice

SpecializationChoice

SchedulingChoice

Rich StaticSemantics

AccurateDynamic

Information

24 / 27

Page 31: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Just-in-Time and Split Compilation

Tools could do a lot better, if provided with enough choice and precise information

Automatic Choice

AlgorithmicChoice

SpecializationChoice

SchedulingChoice

Rich StaticSemantics

AccurateDynamic

Information

Importance of static, non-functional semantics

24 / 27

Page 32: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Just-in-Time and Split Compilation

Tools could do a lot better, if provided with enough choice and precise information

Automatic Choice

AlgorithmicChoice

SpecializationChoice

SchedulingChoice

Rich StaticSemantics

AccurateDynamic

Information

Importance of delaying choice until information is available

24 / 27

Page 33: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Just-in-Time and Split Compilation

Tools could do a lot better, if provided with enough choice and precise information

Automatic Choice

AlgorithmicChoice

SpecializationChoice

SchedulingChoice

Rich StaticSemantics

AccurateDynamic

Information

contradiction!

Contradiction: accurate information is only available after the most important choiceshave already been made

24 / 27

Page 34: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Just-in-Time and Split Compilation

Tools could do a lot better, if provided with enough choice and precise information

DeferredAutomatic Choice

AlgorithmicChoice

SpecializationChoice

SchedulingChoice

Rich StaticSemantics

AccurateDynamic

Information

contradiction!

Deferred compilation enables Just-in-Time (JIT) optimization when accurate informationis available, but loses much of the static semantics carrying choice opportunities

24 / 27

Page 35: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Just-in-Time and Split Compilation

Tools could do a lot better, if provided with enough choice and precise information

DeferredAutomatic Choice

w/ Split Compilation

AlgorithmicChoice

SpecializationChoice

SchedulingChoice

Rich StaticSemantics

AccurateDynamic

Information

contradiction solved!

Contradiction solved with split compilation: optimizations split over coordinated, offlineand online compilation steps, communicating through rich intermediate languages

24 / 27

Page 36: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Auto-Tuning, Iterative Optimization, Machine Learning Compilation

Even with rich static semantics and accurate information, the compiler is left with a hugespace of optimization and specialization opportunities

“By continuously trying, we finally succeed.Therefore: the more it fails, the more it has chances to work.”

Principle of iterative, feedback-directed optimization

Can be embedded transparently in a virtual executionenvironment

Machine learning techniques for split compilation

Offline training, feeding online predictive models withtarget- and application-specific weights

Leveraging static features in deferred compilation steps

25 / 27

Page 37: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Auto-Tuning, Iterative Optimization, Machine Learning Compilation

Even with rich static semantics and accurate information, the compiler is left with a hugespace of optimization and specialization opportunities

“By continuously trying, we finally succeed.Therefore: the more it fails, the more it has chances to work.”

Principle of iterative, feedback-directed optimization

Can be embedded transparently in a virtual executionenvironment

Machine learning techniques for split compilation

Offline training, feeding online predictive models withtarget- and application-specific weights

Leveraging static features in deferred compilation steps

25 / 27

Page 38: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Auto-Tuning, Iterative Optimization, Machine Learning Compilation

Even with rich static semantics and accurate information, the compiler is left with a hugespace of optimization and specialization opportunities

“By continuously trying, we finally succeed.Therefore: the more it fails, the more it has chances to work.”

Principle of iterative, feedback-directed optimization

Can be embedded transparently in a virtual executionenvironment

Machine learning techniques for split compilation

Offline training, feeding online predictive models withtarget- and application-specific weights

Leveraging static features in deferred compilation steps

25 / 27

Page 39: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)
Page 40: Adopt a Polyhedral Compiler! - Inriaimpact.gforge.inria.fr/impact2013/adopt_a_polyhedral... · 2018. 1. 31. · I OpenCL (soon) Steps: Extract polyhedral model from source code (pet,isl)

Adopt a Polyhedral Compiler!

It is happening now

Many blockers have been lifted: better tools, more effective heuristics, betterperformance, more incentive to reengineer the compilers, more performance to gain,more market impact...

The expectations are high, much work is awaiting us

Convince industry to (really) invest into robust platforms, and address open issues,or let’s build the software company that will do it

Software

“Production-quality” integer Set Library: http://freshmeat.net/projects/isl

→ barvinok, iscc, pet, ppcg, PLuTo, PoCC, Polly (LLVM), Graphite (GCC)

27 / 27