Giter VIP home page Giter VIP logo

pass-optimizer's Introduction

IR Pass Optimizer

This is an ongoing project that uses a genetic algorithm to optimize the layout of LLVM IR passes used to compile Julia code.

Quick start

  1. git clone https://github.com/WestleyArgentum/pass-optimizer.git
  2. cd pass-optimizer
  3. ./init.sh
  4. julia pass-ga.jl

Design of the GA

Crossover

Many traditional methods of crossover (single and double point, uniform) assume a genome of a fixed length, or some knowledge about what the optimal length might be. Others support variable length genomes (messy ga, SAGA), but pick largely random points when splicing parent sequences together.

The algorithm employed by this GA is called "Synapsing Variable Length Crossover". It uses the longest common subsequence to identify and split parents genomes in a way that preserves the order and content of the lcs shared by both parents. The paper that formally describes SVLC is behind a paywall, but you can read some here and the code in this repository represents my attempt at an accurate reproduction.

Mutation

Because this GA relies on variable length genomes, it's important for the mutation function to sometimes insert and remove genes, in addition to simply changing them in place. Right now this is done very agressively at first (with a large number of passes being added / removed / changed), and less agressively over time until the GA has reached a predefined MAX_GENERATIONS and stops.

Areas for improvement

Please see the open issues for information about planned improvments / known problems.

pass-optimizer's People

Contributors

westleyargentum avatar

Stargazers

 avatar abdul dakkak avatar Tony Kelman avatar

Watchers

James Cloos avatar  avatar  avatar

pass-optimizer's Issues

add validation to randomly created / changed pass configurations

Very frequently, randomly generated passes result in combinations that will not run for various reasons (loop passes won't work because they're uninitialized, etc). Right now, all of these fail and are assigned a fitness of +inf. This dramatically reduces the actual combinations that are tested.

Potentially, a better alternative could be to add a validation / patching pass that looks for common problems and attempts to fix them. Maybe this would be cheating? But it might be effective.

improve corpus used to calculate fitness

Right now the micro-benchmarks that come with Julia are used to evaluate the fitness (speed) of pass layouts. This has a bunch of potential problems, and raises some interesting questions.

Should we try to find a layout that optimizes naively-written julia well?
Or should we focus on finding one that makes julia written to be performant as fast as possible?
Will the best layout be the same in both cases?

Is it possible to come up with a small, relatively quick-running set of benchmarks that would still be representative as fitness tests? Because the algorithm has to run fitness test one-by-one, this could help tremendously with speeding up the search.

reign in mutation?

Right now 50% of entities have [1-5] passes added / removed / modified during each mutation pass. That seems really aggressive, and in practice I've seen great entities appear and then get lost forever (despite elitism) because of it.

I see a couple ways to solve this:

  1. tone down mutation, or scale it over time better
  2. don't mutate entities that were passed through because of elitism

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.