gcc ici (interactive compilation interface) alchemy group inria futurs france grigori fursin funded...

28
GCC ICI GCC ICI (Interactive Compilation (Interactive Compilation Interface) Interface) ALCHEMY Group ALCHEMY Group INRIA Futurs INRIA Futurs France France Grigori Fursin Grigori Fursin Funded by HiPEAC network Funded by HiPEAC network January, 2007 January, 2007

Post on 22-Dec-2015

238 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

GCC ICIGCC ICI(Interactive Compilation (Interactive Compilation

Interface)Interface)

ALCHEMY GroupALCHEMY GroupINRIA FutursINRIA Futurs

FranceFrance

Grigori FursinGrigori Fursin

Funded by HiPEAC networkFunded by HiPEAC network

January, 2007January, 2007

Page 2: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

OutlineOutline

• Introduction and MotivationIntroduction and Motivation

• Iterative Interactive Compiler Framework Iterative Interactive Compiler Framework

• Interactive Compilation Interface (ICI)Interactive Compilation Interface (ICI)

• Tools and ExperimentsTools and Experiments

• Conclusions and Future WorkConclusions and Future Work

Page 3: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

MotivationMotivation

Current compilers fail to deliver best performance on modern processors due to Current compilers fail to deliver best performance on modern processors due to

• rapidly evolving hardwarerapidly evolving hardware

• simplistic hardware modelssimplistic hardware models

• fixed black-box optimization heuristicsfixed black-box optimization heuristics

• inability to fine-tune applicationsinability to fine-tune applications

• lack of run-time informationlack of run-time information

Different research compilers or transformation toolsDifferent research compilers or transformation tools

• rewritten from scratch to “clean” internals and understand behavior (time rewritten from scratch to “clean” internals and understand behavior (time consuming)consuming)

• have many unnecessary duplications of other compiler internalshave many unnecessary duplications of other compiler internals

• are often incompatible with each other and non-portable are often incompatible with each other and non-portable

• usually support limited number of languagesusually support limited number of languages

• still often have ambiguous and non-portable optimization heuristicsstill often have ambiguous and non-portable optimization heuristics

Page 4: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

GoalsGoals

Instead of developing new compiler or transformations tools, modify current Instead of developing new compiler or transformations tools, modify current popular (non-research) rigid compilers into simpler transparent open transformation popular (non-research) rigid compilers into simpler transparent open transformation toolsets with externally tunable optimization heuristics through a standardized toolsets with externally tunable optimization heuristics through a standardized Interactive Compilation Interface (ICI)Interactive Compilation Interface (ICI)

Control only decision process at global and local levels and avoid revealing all Control only decision process at global and local levels and avoid revealing all intermediate compiler representation to allow further transparent compiler evolutionintermediate compiler representation to allow further transparent compiler evolution

Narrow down optimization space by suggesting only legal transformationsNarrow down optimization space by suggesting only legal transformations

Enable iterative recompilation algorithm to apply sequences of transformationsEnable iterative recompilation algorithm to apply sequences of transformations

Treat current optimization heuristic as a black-box and progressively adapt it to a Treat current optimization heuristic as a black-box and progressively adapt it to a given program and given architecturegiven program and given architecture

Allow life-long, whole-program optimization research with optimization knowledge Allow life-long, whole-program optimization research with optimization knowledge reusereuse

Page 5: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Current CompilersCurrent Compilers

ApplicationApplication

BinaryBinary

Source-to-sourceSource-to-sourcetransformerstransformers

Binary-to-binaryBinary-to-binarytransformerstransformers

Decision for Perform Decision for Perform transformation transformation 11 transf transf 11

Sub-heuristic Sub-heuristic ii

Sub-heuristic Sub-heuristic 11

Sub-heuristic Sub-heuristic jj

Sub-heuristic Sub-heuristic 22

Sub-heuristic Sub-heuristic kk

Compiler optimization Compiler optimization heuristicheuristic

Decision for Perform Decision for Perform transformation transformation ii transf transf ii

Page 6: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Iterative Interactive Compiler Iterative Interactive Compiler FrameworkFramework

ICIICI11

PerformPerformtransf. transf. 11

Decision for Decision for transformation transformation 11

ICIICI22

PerformPerformtransf. transf. 22

Decision for Decision for transformation transformation 22

ICIICIii

PerformPerformtransf. transf. ii

Decision for Decision for transformation transformation ii

Rigid compiler Rigid compiler optimization heuristicoptimization heuristic

““black box”black box”

ProgramProgramOptimizationOptimization

DatabaseDatabaseBinaryBinary

ExternalExternalcompilercompilerdriversdrivers

Iterative Interactive Iterative Interactive CompilerCompiler

ApplicationApplication

Page 7: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Interactive Compilation InterfaceInteractive Compilation Interface

Analysis, decision Analysis, decision and parameters and parameters for decision for for decision for

optimizationoptimization

Apply Apply transformationtransformation

ApplicationApplication

ExecutableExecutable

Iterative Iterative Interactive Interactive CompilerCompiler

……

……

Page 8: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Interactive Compilation InterfaceInteractive Compilation Interface

Analysis, decision Analysis, decision and parameters and parameters for decision for for decision for

optimizationoptimization

Apply Apply transformationtransformation

ApplicationApplication

ExecutableExecutable

Saved decisions Saved decisions and parameters for and parameters for transformations transformations

Iterative Iterative Interactive Interactive CompilerCompiler External output External output

transformation file transformation file

Write modeWrite mode

……

……

Page 9: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Interactive Compilation InterfaceInteractive Compilation Interface

Analysis, decision Analysis, decision and parameters and parameters for decision for for decision for

optimizationoptimization

Apply Apply transformationtransformation

ApplicationApplication

ExecutableExecutable

Saved decisions Saved decisions and parameters for and parameters for transformations transformations

Iterative Iterative Interactive Interactive CompilerCompiler

External output External output transformation file transformation file

oror

Socket Socket CommunicationCommunication

Write modeWrite mode Read modeRead mode

External input External input transformation file transformation file

oror

Socket Socket CommunicationCommunication

Read/Write modeRead/Write mode

……

Modified decisions Modified decisions and parameters for and parameters for transformations transformations

……

Page 10: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Interactive Compilation InterfaceInteractive Compilation Interface

Invoking ICIInvoking ICI• Through command line:Through command line:

Write mode:Write mode:

gcc gcc -fici-generate-fici-generate -ftree-loop-linear -funroll-loops-ftree-loop-linear -funroll-loops *.c *.c

Read/Write mode: Read/Write mode:

gcc gcc -fici-generate -fici-use-fici-generate -fici-use -ftree-loop-linear -funroll-loops-ftree-loop-linear -funroll-loops *.c *.c

• Through environment variables Through environment variables (to enable transparent continuous optimizations):(to enable transparent continuous optimizations):

Write mode:Write mode:

exportexport GCC_ICI_GEN GCC_ICI_GEN = 1= 1

makemake

Read/Write mode: Read/Write mode:

exportexport GCC_ICI_GEN GCC_ICI_GEN = 1= 1

exportexport GCC_ICI_USE GCC_ICI_USE = 1= 1

export export GCC_ICI_OPTS GCC_ICI_OPTS = = -ftree-loop-linear -funroll-loops-ftree-loop-linear -funroll-loops

makemake

Page 11: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Current ImplementationCurrent Implementation

External output transformation xml file:External output transformation xml file:

<?xml version="<?xml version="1.01.0"?>"?><compiler_ici><compiler_ici> <file_name="<file_name="swim.fswim.f">"> <transformation name="<transformation name="unroll_and_peelunroll_and_peel">"> <function><function>calc1calc1</function></function> <loop_number><loop_number>44</loop_number></loop_number> <depth><depth>11</depth></depth> <decision><decision>44</decision></decision> <factor><factor>77</factor></factor> </transformation></transformation> <transformation name="<transformation name="unroll_and_peelunroll_and_peel">"> <function><function>calc1calc1</function></function> <loop_number><loop_number>33</loop_number></loop_number> <depth><depth>11</depth></depth> <decision><decision>44</decision></decision> <factor><factor>77</factor></factor> </transformation></transformation> … …</file_name></file_name></compiler_ici></compiler_ici>

Page 12: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Current ImplementationCurrent Implementation

External output transformation xml file:External output transformation xml file:

<?xml version="<?xml version="1.01.0"?>"?><compiler_ici><compiler_ici> <file_name="<file_name="swim.fswim.f">"> <transformation name="<transformation name="unroll_and_peelunroll_and_peel">"> <function><function>calc1calc1</function></function> <loop_number><loop_number>44</loop_number></loop_number> <depth><depth>11</depth></depth> <decision><decision>44</decision></decision> <factor><factor>77</factor></factor> </transformation></transformation> <transformation name="<transformation name="unroll_and_peelunroll_and_peel">"> <function><function>calc1calc1</function></function> <loop_number><loop_number>33</loop_number></loop_number> <depth><depth>11</depth></depth> <decision><decision>44</decision></decision> <factor><factor>77</factor></factor> </transformation></transformation> … …</file_name></file_name></compiler_ici></compiler_ici>

Supported optimizations:Supported optimizations:

global:global:• program phase reorderingprogram phase reordering

local:local:• loop interchangeloop interchange• loop peelingloop peeling• loop unrollingloop unrolling

more optimizations soon …more optimizations soon …

Page 13: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Current ImplementationCurrent Implementation

External output transformation xml file:External output transformation xml file:

<?xml version="<?xml version="1.01.0"?>"?><compiler_ici><compiler_ici> <file_name="<file_name="swim.fswim.f">"> <transformation name="<transformation name="unroll_and_peelunroll_and_peel">"> <function><function>calc1calc1</function></function> <loop_number><loop_number>44</loop_number></loop_number> <depth><depth>11</depth></depth> <decision><decision>44</decision></decision> <factor><factor>77</factor></factor> </transformation></transformation> <transformation name="<transformation name="unroll_and_peelunroll_and_peel">"> <function><function>calc1calc1</function></function> <loop_number><loop_number>33</loop_number></loop_number> <depth><depth>11</depth></depth> <decision><decision>44</decision></decision> <factor><factor>77</factor></factor> </transformation></transformation> … …</file_name></file_name></compiler_ici></compiler_ici>

Supported optimizations:Supported optimizations:

global:global:• program phase reorderingprogram phase reordering

local:local:• loop interchangeloop interchange• loop peelingloop peeling• loop unrollingloop unrolling

more optimizations soon …more optimizations soon …

Based on PathScale ICI (2004-2006)Based on PathScale ICI (2004-2006)

• inlininginlining• array padding (global/local)array padding (global/local)• loop fusion/fissionloop fusion/fission• loop interchangeloop interchange• loop blockingloop blocking• loop unrolling loop unrolling • register tilingregister tiling• prefetchingprefetching

Page 14: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Iterative Recompilation AlgorithmIterative Recompilation Algorithm

Iterative Recompilation Algorithm to apply sequences of transformations:Iterative Recompilation Algorithm to apply sequences of transformations:

clear clear transformation_file_out.xmltransformation_file_out.xml

set PATHSCALE_ICI_W to 1 set PATHSCALE_ICI_W to 1

compile programcompile program

(write (write transformation_file_out.xmltransformation_file_out.xml))

set PATHSCALE_ICI_R to 1set PATHSCALE_ICI_R to 1

_label_recompile:_label_recompile:

copy copy transformation_file_out.xmltransformation_file_out.xml to to

transformation_file_in.xmltransformation_file_in.xml

modify modify transformation_file_in.xmltransformation_file_in.xml if needed if needed

compile programcompile program

(read (read transformation_file_in.xmltransformation_file_in.xml, ,

write write transformation_file_out.xmltransformation_file_out.xml))

if if transformation_file_in.xmltransformation_file_in.xml not the same not the same

as as transformation_file_out.xmltransformation_file_out.xml

go to _label_recompilego to _label_recompile

Page 15: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

GCC Instrumentation (Phase GCC Instrumentation (Phase Reordering)Reordering)gcc/passes.cgcc/passes.c

#include “fici.h”#include “fici.h”

voidvoidexecute_pass_list (…) {execute_pass_list (…) {…… /* GCC ICI *//* GCC ICI */ if (if (flag_ici_useflag_ici_use) {) { int i;int i; for(i = 0; i < fici_pass_count(type); i++)for(i = 0; i < fici_pass_count(type); i++) execute_one_pass(pass_list[fici_reorder_pass_number(type, i)]); execute_one_pass(pass_list[fici_reorder_pass_number(type, i)]); }} elseelse execute_pass_list(pass, new_type);execute_pass_list(pass, new_type);…… do {do { if (if (flag_ici_generateflag_ici_generate)) fici_reorder_add_pass(type, pass->name, pass->index);fici_reorder_add_pass(type, pass->name, pass->index); if (execute_one_pass (pass) && pass->sub)if (execute_one_pass (pass) && pass->sub) execute_pass_list (pass->sub, type);execute_pass_list (pass->sub, type); pass = pass->next;pass = pass->next; }} while (pass);while (pass);

Page 16: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

GCC Instrumentation GCC Instrumentation (Transformations)(Transformations)gcc/loop-unroll.cgcc/loop-unroll.c

#include “fici.h”#include “fici.h”

static voidstatic voiddecide_unrolling_and_peeling (struct loops *loops, int flags) {decide_unrolling_and_peeling (struct loops *loops, int flags) { … … decide_unroll_constant_iterations (loop, flags);decide_unroll_constant_iterations (loop, flags); if (loop->lpt_decision.decision == LPT_NONE)if (loop->lpt_decision.decision == LPT_NONE)

decide_unroll_runtime_iterations (loop, flags);decide_unroll_runtime_iterations (loop, flags); if (loop->lpt_decision.decision == LPT_NONE)if (loop->lpt_decision.decision == LPT_NONE)

decide_unroll_stupid (loop, flags);decide_unroll_stupid (loop, flags); if (loop->lpt_decision.decision == LPT_NONE)if (loop->lpt_decision.decision == LPT_NONE)

decide_peel_simple (loop, flags);decide_peel_simple (loop, flags);

/* GCC ICI *//* GCC ICI */ if (if (flag_ici_useflag_ici_use)) fici_unroll_in(get_name(current_function_decl), loop->num, loop->depth,fici_unroll_in(get_name(current_function_decl), loop->num, loop->depth, &(loop->lpt_decision.decision)&(loop->lpt_decision.decision),, &(loop->lpt_decision.times)&(loop->lpt_decision.times)););

if (if (flag_ici_generateflag_ici_generate)) fici_unroll_out(get_name(current_function_decl), loop->num, loop->depth,fici_unroll_out(get_name(current_function_decl), loop->num, loop->depth, &(loop->lpt_decision.decision)&(loop->lpt_decision.decision), , &(loop->lpt_decision.times)&(loop->lpt_decision.times));); loop = next;loop = next; }}

Page 17: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

GCC Instrumentation (Features)GCC Instrumentation (Features)gcc/tree-loop-linear.cgcc/tree-loop-linear.c

#include “fici.h”#include “fici.h”

linear_transform_loops (struct loops *loops)linear_transform_loops (struct loops *loops) {{ … … if (if (flag_api_generateflag_api_generate)) {{ dump_file_tmp=dump_file;dump_file_tmp=dump_file; dump_flags_tmp=dump_flags;dump_flags_tmp=dump_flags; dump_file=fici_features_group_start_out(FICI_FGR_LOOP_DEPS);dump_file=fici_features_group_start_out(FICI_FGR_LOOP_DEPS);

dump_flags=TDF_DETAILS | TDF_STATS;dump_flags=TDF_DETAILS | TDF_STATS;

fapi2_features_start_dump_tmp();fapi2_features_start_dump_tmp(); }} … … }}

Reuse GCC dump information and progressively clean itReuse GCC dump information and progressively clean it

Page 18: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Preliminary ResultsPreliminary Results

MatmulSmall dataset(3x3 matrices,

27400000 multiplications)

Optimization Execution time Speedup

-O3 5.0 s.

-O3 –funroll-all-loops

(internal factor 7)

3.9 s. 1.3

-O3 –funroll-all-loops

(factor 2 selected with GCC ICI)

3.1 s. 1.6

Page 19: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Using FrameworkUsing Framework

• Continuous iterative optimization driver with run-time adaptation at function, loopContinuous iterative optimization driver with run-time adaptation at function, loop--levellevel or instruction level using low-overhead phase detection techniqueor instruction level using low-overhead phase detection technique

• Driver to continuously collect all possible optimization parametersDriver to continuously collect all possible optimization parameters

• Driver to automatically and continuously rebuild compiler optimization heuristic, Driver to automatically and continuously rebuild compiler optimization heuristic, and adapt to a specific architecture using statistical methods and collective and adapt to a specific architecture using statistical methods and collective optimization knowledge reuse among different programs and architecturesoptimization knowledge reuse among different programs and architectures

• Prototype framework to replace a model-based compiler heuristic with Prototype framework to replace a model-based compiler heuristic with automatically learned one by connecting ICI with WEKA - an open-source machine automatically learned one by connecting ICI with WEKA - an open-source machine learning software packagelearning software package

Porting from PathScale Continuous Optimization Framework (2003-cur) to Porting from PathScale Continuous Optimization Framework (2003-cur) to GCC or developing:GCC or developing:

Page 20: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Iterative Continuous OptimizationsIterative Continuous Optimizations

applicationapplication

binarybinary

source-to-source source-to-source transformationstransformations

current compilerscurrent compilers

executionexecution

binary-to-binary binary-to-binary transformationstransformations

Page 21: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Iterative Continuous Adaptive Iterative Continuous Adaptive OptimizationsOptimizations

applicationapplication

binarybinary

source-to-source source-to-source transformationstransformations

Iterative Interactive Iterative Interactive CompilerCompiler

executionexecution

binary-to-binary binary-to-binary transformationstransformations

Program Program Transformation Transformation

DatabaseDatabase

Iterative Optimizations/Iterative Optimizations/Machine LearningMachine Learning

Page 22: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

ML to Remove Compiler HeuristicML to Remove Compiler Heuristic

applicationapplication11 GCC ICIGCC ICI

transformationstransformations

featuresfeatures

execution timeexecution time

applicationapplicationNN GCC ICIGCC ICI

Building Building Model Model

with with WEKAWEKA

transformationstransformations

featuresfeatures

execution timeexecution time

Page 23: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

ML to Remove Compiler HeuristicML to Remove Compiler Heuristic

applicationapplication11 GCC ICIGCC ICI

transformationstransformations

featuresfeatures

execution timeexecution time

applicationapplicationNN GCC ICIGCC ICI

Building Building Model Model

with with WEKAWEKA

transformationstransformations

featuresfeatures

execution timeexecution time

new new applicationapplication

GCC ICIGCC ICI

transformationstransformations

featuresfeatures

Page 24: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

ML to Remove Compiler HeuristicML to Remove Compiler Heuristic

applicationapplication11 GCC ICIGCC ICI

transformationstransformations

featuresfeatures

execution timeexecution time

applicationapplicationNN GCC ICIGCC ICI

Building Building Model Model

with with WEKAWEKA

transformationstransformations

featuresfeatures

execution timeexecution time

new new applicationapplication

GCC ICIGCC ICI

transformationstransformations

featuresfeatures

GCC ICIGCC ICI

Page 25: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

ML to Remove Compiler HeuristicML to Remove Compiler Heuristic

applicationapplication11 GCC ICIGCC ICI

transformationstransformations

featuresfeatures

execution timeexecution time

applicationapplicationNN GCC ICIGCC ICI

Building Building Model Model

with with WEKAWEKA

transformationstransformations

featuresfeatures

execution timeexecution time

new new applicationapplication

GCC ICIGCC ICI

transformationstransformations

featuresfeatures

GCC ICIGCC ICI best best execution timeexecution time

Page 26: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

ConclusionsConclusions

• WWe demonstrate a simple, practical and non-intrusive way to turn currente demonstrate a simple, practical and non-intrusive way to turn currentrigid compilers into powerful interactive transformation toolset with an Interactiverigid compilers into powerful interactive transformation toolset with an InteractiveCompilation Interface that allows to bias compiler optimization decisions externallyCompilation Interface that allows to bias compiler optimization decisions externally

• We avoid the pitfalls of rigidifying the compiler internals while grantingWe avoid the pitfalls of rigidifying the compiler internals while grantingaccess to rich-enough features to take performance-critical decisionsaccess to rich-enough features to take performance-critical decisions

• We considerably reduce optimization search space by analyzing and applying only We considerably reduce optimization search space by analyzing and applying only legal transformationslegal transformations

• We develop tools for continuous collective life-long optimizations and knowledge We develop tools for continuous collective life-long optimizations and knowledge reuse across different programs and architecturesreuse across different programs and architectures

• We use framework in EU projects to automatically adapt and optimize programs for We use framework in EU projects to automatically adapt and optimize programs for performance, code size, power consumption, multiple ISA, etcperformance, code size, power consumption, multiple ISA, etc

Page 27: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Future workFuture work

• Porting ICI to GCC in collaboration with IBM, NXP (Philips), STMicro, ARC, Porting ICI to GCC in collaboration with IBM, NXP (Philips), STMicro, ARC, multiple universities within HiPEAC network of excellence and within EU-funded multiple universities within HiPEAC network of excellence and within EU-funded projects MilePost, SARC and GGCCprojects MilePost, SARC and GGCC

• Adding more transformations and enabling phase-reordering at function level in Adding more transformations and enabling phase-reordering at function level in GCCGCC

• Unifying optimization naming conventions to enable portability and knowledge Unifying optimization naming conventions to enable portability and knowledge reuse to build optimization heuristics automaticallyreuse to build optimization heuristics automatically

• Implementing run-time adaptation technique to select different program versions Implementing run-time adaptation technique to select different program versions at run-time depending on program behaviorat run-time depending on program behavior

• Finishing framework for practical continuous life-long whole-program optimizations Finishing framework for practical continuous life-long whole-program optimizations with statistical or machine learning techniqueswith statistical or machine learning techniques

• Porting ICI to JIT compilers (Jikes, .NET) to unify run-time optimizationsPorting ICI to JIT compilers (Jikes, .NET) to unify run-time optimizations

Would like to participate?Would like to participate? http://sourceforge.net/projects/gcc-icihttp://sourceforge.net/projects/gcc-ici

Page 28: GCC ICI (Interactive Compilation Interface) ALCHEMY Group INRIA Futurs France Grigori Fursin Funded by HiPEAC network January, 2007

Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007Grigori Fursin “GCC ICI (interactive Compilation Interface)” GCC Tutorial, Ghent, Belgium January, 2007

Contact e-mail: Contact e-mail: [email protected]@inria.fr

More information: More information: http://fursin.net/research_desc.htmlhttp://fursin.net/research_desc.html

Questions?Questions?

Thanks to Thanks to Sebastian PopSebastian Pop, , Cupertino MirandaCupertino Miranda and and Hamid DaoudHamid Daoudfor help with gcc modifications for help with gcc modifications

Collaborations and Support:Collaborations and Support:IBM, NXP (Philips), STMicro, ARC, CAPS, Universities within HiPEACIBM, NXP (Philips), STMicro, ARC, CAPS, Universities within HiPEAC

This work is funded by HiPEACThis work is funded by HiPEAChttp://www.hipeac.nethttp://www.hipeac.net

Software development web-site for GCC ICI:Software development web-site for GCC ICI:

http://sourceforge.net/projects/gcc-icihttp://sourceforge.net/projects/gcc-ici