cheukwing / hashkell

Semi-automatic Parallelisation of Timed Functional Programs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hashkell

Parser for a simple subset of Haskell with time complexity annotations and dependency graphs.

Compilation, running, and testing

This project uses Stack:

stack build # to build

stack run -- <args> # or ./hashkell-exe <args>, to run with <args>

stack test # to test

Usage

To parallelise an input file code.hs with the func method:

stack run -- parallelise func code.hs

To graph all the functions in an input file code.hs:

stack run -- graph -A code.hs

For all options, refer to the help manual:

stack run -- --help

Example of Supported Code

fib ## 2^x;
fib :: Int -> Int;
fib x =
  if x < 1
    then 0
    else if x < 2
           then 1
           else fib (x - 1) + fib (x - 2)

Generated Dependency Graph

Dependency graph for the naive fib function

Time Complexity Annotations

Time complexity annotations are used by the compiler to generate branching paths for parallelisation. Annotations are written using ##, as so:

<function-name> ## <time-complexity>;

The following annotations are supported:

-- Constant time
func ## 1;

-- Polynomial time
func ## n;

func ## n^2;

func ## n^100;

-- Exponential time
func ## 2^n;

func ## 100^n;

-- Logarithmic time
func ## log n;

-- Factorial time
func ## fac n;

The given identifier name in the annotation must correspond to an argument in the function declaration, and only one such name is allowed in any annotation.

About

Semi-automatic Parallelisation of Timed Functional Programs

License:MIT License


Languages

Language:Haskell 94.1%Language:Yacc 3.1%Language:Logos 2.8%