= Building the Repa Plugin = == Install LLVM and GHC head == Start with GHC head and LLVM 3.4 in your `$PATH`. LLVM 3.1 also works (and probably other versions). Leave the GHC head build in-place, soft link `$GHC/inplace/bin/ghc-stage2` to `$GHC/inplace/bin/ghc` and then put the whole `$GHC/inplace/bin` directory in your `$PATH`. This way you also get `ghc-pkg` and other tools in your `$PATH`. {{{ $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.7.20140126 $ ghc-pkg --version GHC package manager version 7.7.20140126 $ opt --version LLVM version 3.4 ... }}} == Update the cabal database == Update your cabal database so you don't inadvertently install old library versions. {{{ $ cabal update }}} == Download and build the DDC head == Clone the DDC head repo. {{{ $ git clone https://github.com/DDCSF/ddc }}} Install external dependencies for DDC. {{{ $ cd ddc $ cabal install `make show-pkgs` --enable-shared }}} The DDC `make show-pkgs` target lists what external Hackage packages DDC needs. We need to use `--enable-shared` to build shared libraries that will work with the Repa plugin. Now build the DDC packages and register them with Cabal. {{{ $ make packages }}} Note that just using `make` here will build DDC locally, but we won't get Cabal packages registered with the GHC development build. We need these when building the Repa plugin. == Download and build the Repa head == Clone the Repa head repo. {{{ $ cd .. $ git clone https://github.com/DDCSF/repa }}} Install the Repa packages. {{{ $ cd repa $ make plugin }}} Doing this should also install the `QuickCheck` and `bmp` packages as dependencies. After this step you should have the following cabal libraries installed, on top of the ones that come with the GHC development build. {{{ $ ghc-pkg list ... QuickCheck-2.6 bmp-1.2.5.2 buildbox-2.1.3.1 ddc-base-0.3.3.0 ddc-build-0.3.3.0 ddc-code-0.3.3.0 ddc-core-0.3.3.0 ddc-core-eval-0.3.3.0 ddc-core-flow-0.3.3.0 ddc-core-llvm-0.3.3.0 ddc-core-salt-0.3.3.0 ddc-core-simpl-0.3.3.0 ddc-core-tetra-0.3.3.0 ddc-driver-0.3.3.0 ddc-interface-0.3.3.0 ddc-source-tetra-0.3.3.0 mtl-2.1.2 parsec-3.1.5 repa-3.2.3.4 repa-io-3.2.3.4 repa-plugin-1.0.1.0 repa-series-1.0.1.0 stm-2.4.2 text-1.1.0.0 wl-pprint-1.1 }}} == Using the repa-plugin == Compile one of the tests using the Repa plugin: {{{ $ cd repa-plugin/test/90-Benchmarks/repa/FilterMax $ ghc -fforce-recomp -O2 -fllvm -optlo-O3 \ --make Main.hs \ -fplugin=Data.Array.Repa.Plugin \ -fplugin-opt=Data.Array.Repa.Plugin:dump }}} The ':dump' flag tells the plugin to drop the intermediate code at several points along the compilation pipeline. You should get a stack of `dump.*` files in the current directory. == Run the repa-plugin test == Run the version using flow fusion. {{{ $ ./Main flow 100000000 elapsedTimeMS = 281 cpuTimeMS = 280 }}} Run the version using stream fusion. {{{ $ ./Main vector 100000000 elapsedTimeMS = 319 cpuTimeMS = 320 }}} == Running DDC Flow Fusion tests == Although the repa-plugin is invoked via GHC, the actual flow fusion transforms are done on the DDC Core language. There are tests for the low-level transforms in the DDC repo. Go back to the root of the DDC build. {{{ $ cd $DDC }}} Set the number of threads for a parallel build (substitute 8 => whatever) {{{ $ echo THREADS=8 > make/config-override.mk }}} Build DDC locally and run all the regression tests. {{{ $ make war }}} The flow fusion tests are in `$DDC/test/ddc-main/60-CoreFlow` {{{ $ cat test/ddc-main/60-CoreFlow/30-Scalar/20-Map/Test.dcx $ cat test/ddc-main/60-CoreFlow/30-Scalar/20-Map/Test.stdout.check }}} We can also run individual tests manually. {{{ $ bin/ddci-core test/ddc-main/60-CoreFlow/30-Scalar/20-Map/Test.dcx }}}