Code Monkey home page Code Monkey logo

apref's Introduction

APReF: Automatic Parallelizer of REcursive Functions

This is a source-to-source Haskell compiler that automatically identifies and rewrites recursive functions in a parallel form.

Optimizations implemented:

  • Automatic parallelization
  • Constant folding
  • Reassociation of terms for commutative operations
  • Symbolic simplification of scan operations

References

Automatic Parallelization of Recursive Functions with Rewriting Rules
Rodrigo C. O. Rocha, Luís F. W. Góes, Fernando M. Q. Pereira
Journal of Science of Computer Programming, 2018

An Algebraic Framework for Parallelizing Recurrence in Functional Programming
Rodrigo C. O. Rocha, Luís F. W. Góes, Fernando M. Q. Pereira
SBLP 2016 - Brazilian Symposium on Programming Languages

Example

Given the following sequential recursive function:

f :: Integer -> [Integer]
f 0 = []
f n = [n] ++ f(n-1) ++ [n]

the source-to-source compiler is able to rewrite it as in the following parallel version:

f_g_1 :: Integer -> [Integer]
f_g_1 i = [i]
f_g_2 :: Integer -> [Integer]
f_g_2 i = [i]
f :: Integer -> [Integer]
f 0 = []
f n = let k = n
      in (parFoldr (++) (map f_g_1 (reverse [1..k]))) ++ [] ++
         (parFoldr (++) (map f_g_2 [1..k]))

Usage

By passing a Haskell file to the source-to-source compiler, any parallelizable function will be rewritten in their parallel counterparts. Auxiliary packages and functions will also be added.

python apref.py -f <haskell-file> --scan --constfold

The flag '--scan' enables a scan-based optimization. Similarly, the '--constfold' enables a constant folding optimization.

apref's People

Contributors

rcorcs avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

suleisl2000

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.