GitXplorerGitXplorer
b

supercompilation-by-evaluation

public
16 stars
4 forks
1 issues

Commits

List of commits on branch master.
Unverified
daeb3e12ca8319a5144dd48a763cf7e7825a1999

Add missing filter function

bbatterseapower committed 14 years ago
Unverified
5bedee72a64378725c54a58b2046af5f15d94219

Backport changes from CHSC to ensure that we invoke GHC 7 with the right flags

bbatterseapower committed 14 years ago
Unverified
2dd496765d9c0cb8574c919ff61cf4957870c63b

Bump versions for GHC 7 compatability

bbatterseapower committed 14 years ago
Unverified
c991a0e68bae2e8b53c8770388a9d2c07be3e56e

Direct support for less-than operator to get cleaner output code

bbatterseapower committed 14 years ago
Unverified
6bf60eeb9b74bb1fc1bd96959e085e6ed3d68b47

Example using an accumulator: a good test for generalisation, as we can get fusion despite the accumulation

bbatterseapower committed 14 years ago
Unverified
cef3ca2d4288f65941d95e7bf12e1fc61b29fa7e

Note about the LetRec example

bbatterseapower committed 14 years ago

README

The README file for this repository.

The Cambridge Haskell Supercompiler (CHSC)

Overview

The Cambridge Haskell Supercompiler (CHSC) is a preprocessor which supercompiles programs written in a subset of Haskell. The output is source code suitable for presentation to the Glasgow Haskell Compiler (GHC) for compilation as standard Haskell.

The hope is that the process of supercompiling the input makes it more efficient and hence CHSC can be used as a program optimisation tool. Because of the focus on program optimisation the design of CHSC is somewhat different from that of supercompilers used for theorem proving:

  • We are careful to never duplicate work that is shared in the input program
  • We compile a language which models full Haskell: in particular, we can supercompile strict primops and recursive let bindings
  • We care a lot about code duplication and compile time, even if we don't have any good answers yet

The intention is to eventually integrate the supercompiler into GHC to supercompile the Core language. This will let us truly supercompile any Haskell program, not just those written in the subset that CHSC knows how to desugar.

Bugs

At the time of writing, there are no known bugs in the master branch of the supercompiler. However, supercompiling certain programs (even some of the examples I have provided) has never been observed to terminate due to the supercompilation code explosion problem.

Using

If you want to try out the CHSC, use the test script:

$ ./test examples/toys/MapMapFusion.core

This will print output similar to the following:

examples/toys/MapMapFusion.core
mapmapfusion & 0.0s & 0.50 & 0.82 & 1.02 \\

The fields on the second row are, from left to right:

  1. The name of the benchmark
  2. The time taken to supercompile (in seconds)
  3. Time taken by GHC to compile to the supercompiled program, as a fraction of the time taken for the input program
  4. Runtime of the supercompiled program, as a fraction of that of the input program
  5. Total heap allocation by the supercompiled program as a fraction of that of the input

In addition to supercompiling and running the benchmarks, the test script outputs the supercompiled forms of the programs:

  • The input program (as a valid Haskell program) is placed in input/examples/toys/MapMapFusion.hs
  • The output program (again, as valid Haskell) is placed in output/primops/gen/examples/toys/MapMapFusion.hs

Naturally, the suffix of this file name varies with the file name that test was invoked with.

You can use test with more than one filename if you would like.

Paper

A description of the design of CHSC was accepted to the Haskell Symposium 2010, and is available online: