FP /

Feldspar hacking session

Installation

Make sure to have GHC 7.0.* installed.

You also need to install Happy:

  cabal install happy

Download the files:

(These can only be accessed from within the Chalmers network.)

Next, run

  cabal unpack syntactic-0.8.tar.gz
  cabal unpack feldspar-language-0.5.0.1.tar.gz
  cabal unpack feldspar-compiler-0.5.0.1.tar.gz

First, install happy:

  cabal install happy

Then, go into each of the created directories and run

  cabal install

Quick start

API reference

The interesting modules are:

Example

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import qualified Prelude
import Feldspar
import Feldspar.Vector
import Feldspar.Compiler

revProd :: Vector (Data Float) -> Data Float
revProd a = sum $ zipWith (*) a (reverse a)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*Main> eval revProd [1..10]
220.0

*Main> drawAST revProd 
(prints out the resulting core language AST)

*Main> icompile revProd 
(prints out the C code)

*Main> compile revProd "code" "revProd" defaultOptions 
(creates the C function revProd in the file code.c)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

FFT

One suggestion is to focus the hacking session on FFT algorithms. Some FFT resources:

CEFP

It is also possible to try out the exercises in our CEFP summer school notes.