predicting good compiler .predicting good compiler transformations using machine learning edwin v

Download Predicting Good Compiler .Predicting Good Compiler Transformations Using Machine Learning Edwin V

Post on 30-Jul-2018

215 views

Category:

Documents

2 download

Embed Size (px)

TRANSCRIPT

  • Predicting Good Compiler Transformations

    Using Machine Learning

    Edwin V. Bonilla

    Master of Science

    Artificial Intelligence

    School of Informatics

    University of Edinburgh

    2004

  • I

    Abstract

    This dissertation presents a machine learning solution to the compiler optimisation problem

    focused on a particular program transformation: loop unrolling. Loop unrolling is a very

    straightforward but powerful code transformation mainly used to improve Instruction Level

    Parallelism and to reduce the overhead due to loop control. However, loop unrolling can also

    be detrimental, for example, when the instruction cache is degraded due to the size of the

    loop body. Additionally, the effect of the interactions between loop unrolling and other

    program transformations is unknown. Consequently, determining when and how unrolling

    should be applied remains a challenge for compiler writers and researchers. This project

    works under the assumption that the effect of loop unrolling on the execution times of

    programs can be learnt based on past examples. Therefore, a regression approach able to

    learn the improvement in performance of loops under unrolling is presented. This novel

    approach differs from previous work ([Monsifrot et al., 2002] and [Stephenson and

    Amarasinghe, 2004]) because it does not formulate the problem as a classification task but as

    a regression solution. Great effort has been invested in the generation of clean and reliable

    data in order to make it suitable for learning. Two different regression algorithms have been

    used: Multiple Linear Regression and Classification and Regression Trees (CART).

    Although the accuracy of the methods is questionable, the realisation of final speed-ups on

    seven out of twelve benchmarks indicates that something has been gained with this learning

    process. A maximum 18% of re-substitution improvement has been achieved. 2.5% of

    overall improvement in performance for Linear Regression and 2.3% for CART algorithm

    have been obtained. The present work is the beginning of an ambitious project that attempts

    to build a compiler that can learn to optimise programs and can undoubtedly be improved in

    the near future.

  • II

    Acknowledgements Special thanks to my supervisor Dr. Chris Williams for his invaluable advice and

    comprehensive revision of my progress throughout this project.

    Thanks to Dr. Michael O'Boyle and Dr. Grigori Fursin for the discussions held during our

    meetings that made possible the creation of the dataset that has been used in this project.

    Thanks to Catalina Voroneanu and Bonny Quick for their patience when revising some

    drafts of this dissertation.

    Supported by the Programme Alan, European Union Programme of High Level

    Scholarships for Latin America, identification number (E03M14650CO).

  • III

    Declaration I declare that this thesis was composed by myself, that the work contained herein is my own

    except where explicitly stated otherwise in the text, and that this work has not been

    submitted for any other degree or professional qualification except as specified.

    (Edwin V. Bonilla)

  • IV

    Table of Contents

    Introduction.............................................................................................................................. 1 Overview and Motivation .................................................................................................... 1 Project Objectives ................................................................................................................ 2 Organisation......................................................................................................................... 3

    Chapter One: Literature Review .............................................................................................. 6 1.1 Introduction ............................................................................................................ 6 1.2 Tuning heuristics and recommending program transformations ............................ 6 1.3 Learning in a particular program transformation: loop unrolling........................... 8 1.4 Summary............................................................................................................... 10

    Chapter 2: Background on Compiler Optimisation ............................................................... 11 2.1 Introduction .......................................................................................................... 11 2.2 Definition of compilation ..................................................................................... 11 2.3 Compiler organisation .......................................................................................... 12 2.4 The purpose of a compiler .................................................................................... 13 2.5 An Optimising Compiler ...................................................................................... 14

    2.5.1 Goals of Compiler Optimisation ...................................................................... 14 2.5.2 Considerations for program transformations.................................................... 15 2.5.3 The process of transforming a program for optimisation................................. 16 2.5.4 The problem of interaction............................................................................... 17 2.5.5 Types of program transformations ................................................................... 18 2.5.6 The scope of optimisation ................................................................................ 18 2.5.7 Some common transformations........................................................................ 20

    2.6 Loop Unrolling ..................................................................................................... 20 2.6.1 Definition ......................................................................................................... 20 2.6.2 Implementation ................................................................................................ 21 2.6.3 Advantages of loop unrolling........................................................................... 22 2.6.4 Disadvantages of loop unrolling ...................................................................... 23 2.6.5 Interactions, again ............................................................................................ 24 2.6.6 Candidates for unrolling................................................................................... 24

    2.7 Summary............................................................................................................... 24 Chapter 3: Data Collection..................................................................................................... 26

    3.1 Introduction .......................................................................................................... 26

  • V

    3.2 The Benchmarks................................................................................................... 28 3.3 Implementation of loop unrolling......................................................................... 31

    3.3.1 Which loops should be unrolled? ..................................................................... 31 3.3.2 Initial experiments............................................................................................ 31 3.3.3 Loop level profiling.......................................................................................... 32

    3.4 Generating the targets........................................................................................... 34 3.4.1 Preparing the benchmarks ................................................................................ 34 3.4.2 Selecting loops ................................................................................................. 34 3.4.3 Profiling............................................................................................................ 34 3.4.4 Filtering............................................................................................................ 34 3.4.5 Running the search strategy ............................................................................. 35

    3.5 Technical Details .................................................................................................. 35 3.5.1 The platform..................................................................................................... 35 3.5.2 The compiler .................................................................................................... 35 3.5.3 The timers precision........................................................................................ 35

    3.6 The results in summary......................................................................................... 36 3.7 Feature extraction ................................................................................................. 36 3.8 The representation of a loop ................................................................................. 39 3.9 Summary............................................................................................................... 40

    Chapter 4: Data Preparation and Exploratory Data Analysis................................................. 41 4.1 Introduction .......................................................................................................... 41 4.2 The general framework for data integration .................................................

Recommended

View more >