| 2 | |
| 3 | == Install LLVM and GHC head == |
| 4 | Start with GHC head and LLVM 3.4 in your `$PATH`. |
| 5 | |
| 6 | LLVM 3.1 also works (and probably other versions). |
| 7 | |
| 8 | 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`. |
| 9 | |
| 10 | {{{ |
| 11 | $ ghc --version |
| 12 | The Glorious Glasgow Haskell Compilation System, version 7.7.20140126 |
| 13 | |
| 14 | $ ghc-pkg --version |
| 15 | GHC package manager version 7.7.20140126 |
| 16 | |
| 17 | $ opt --version |
| 18 | LLVM version 3.4 |
| 19 | ... |
| 20 | }}} |
| 21 | |
| 22 | == Update the cabal database == |
| 23 | Update your cabal database so you don't inadvertently install old library versions. |
| 24 | {{{ |
| 25 | $ cabal update |
| 26 | }}} |
| 27 | |
| 28 | |
| 29 | == Download and build the DDC head == |
| 30 | Clone the DDC head repo. |
| 31 | |
| 32 | {{{ |
| 33 | $ git clone https://github.com/DDCSF/ddc |
| 34 | }}} |
| 35 | |
| 36 | Install external dependencies for DDC. |
| 37 | |
| 38 | {{{ |
| 39 | $ cd ddc |
| 40 | $ cabal install `make show-pkgs` --enable-shared |
| 41 | }}} |
| 42 | |
| 43 | The DDC `make show-pkgs` target lists what external Hackage packages DDC needs. |
| 44 | We need to use `--enable-shared` to build shared libraries that will work with the Repa plugin. |
| 45 | |
| 46 | Now build the DDC packages and register them with Cabal. |
| 47 | {{{ |
| 48 | $ make packages |
| 49 | }}} |
| 50 | |
| 51 | 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. |
| 52 | |
| 53 | |
| 54 | |
| 55 | == Download and build the Repa head == |
| 56 | |
| 57 | Clone the Repa head repo. |
| 58 | |
| 59 | {{{ |
| 60 | $ cd .. |
| 61 | $ git clone https://github.com/DDCSF/repa |
| 62 | }}} |
| 63 | |
| 64 | Install the Repa packages. |
| 65 | |
| 66 | {{{ |
| 67 | $ cd repa |
| 68 | $ make plugin |
| 69 | }}} |
| 70 | |
| 71 | 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. |
| 72 | |
| 73 | {{{ |
| 74 | $ ghc-pkg list |
| 75 | ... |
| 76 | QuickCheck-2.6 |
| 77 | bmp-1.2.5.2 |
| 78 | buildbox-2.1.3.1 |
| 79 | ddc-base-0.3.3.0 |
| 80 | ddc-build-0.3.3.0 |
| 81 | ddc-code-0.3.3.0 |
| 82 | ddc-core-0.3.3.0 |
| 83 | ddc-core-eval-0.3.3.0 |
| 84 | ddc-core-flow-0.3.3.0 |
| 85 | ddc-core-llvm-0.3.3.0 |
| 86 | ddc-core-salt-0.3.3.0 |
| 87 | ddc-core-simpl-0.3.3.0 |
| 88 | ddc-core-tetra-0.3.3.0 |
| 89 | ddc-driver-0.3.3.0 |
| 90 | ddc-interface-0.3.3.0 |
| 91 | ddc-source-tetra-0.3.3.0 |
| 92 | mtl-2.1.2 |
| 93 | parsec-3.1.5 |
| 94 | repa-3.2.3.4 |
| 95 | repa-io-3.2.3.4 |
| 96 | repa-plugin-1.0.1.0 |
| 97 | repa-series-1.0.1.0 |
| 98 | stm-2.4.2 |
| 99 | text-1.1.0.0 |
| 100 | wl-pprint-1.1 |
| 101 | }}} |
| 102 | |
| 103 | == Using the repa-plugin == |
| 104 | |
| 105 | Compile one of the tests using the Repa plugin: |
| 106 | |
| 107 | {{{ |
| 108 | $ cd repa-plugin/test/90-Benchmarks/repa/FilterMax |
| 109 | $ ghc -fforce-recomp -O2 -fllvm -optlo-O3 \ |
| 110 | --make Main.hs \ |
| 111 | -fplugin=Data.Array.Repa.Plugin \ |
| 112 | -fplugin-opt=Data.Array.Repa.Plugin:dump |
| 113 | }}} |
| 114 | |
| 115 | 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. |
| 116 | |
| 117 | |
| 118 | == Run the repa-plugin test == |
| 119 | |
| 120 | Run the version using flow fusion. |
| 121 | |
| 122 | {{{ |
| 123 | $ ./Main flow 100000000 |
| 124 | elapsedTimeMS = 281 |
| 125 | cpuTimeMS = 280 |
| 126 | }}} |
| 127 | |
| 128 | Run the version using stream fusion. |
| 129 | |
| 130 | {{{ |
| 131 | $ ./Main vector 100000000 |
| 132 | elapsedTimeMS = 319 |
| 133 | cpuTimeMS = 320 |
| 134 | }}} |
| 135 | |
| 136 | |
| 137 | == Running DDC Flow Fusion tests == |
| 138 | |
| 139 | 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. |
| 140 | |
| 141 | Go back to the root of the DDC build. |
| 142 | |
| 143 | {{{ |
| 144 | $ cd $DDC |
| 145 | }}} |
| 146 | |
| 147 | Set the number of threads for a parallel build (substitute 8 => whatever) |
| 148 | |
| 149 | {{{ |
| 150 | $ echo THREADS=8 > make/config-override.mk |
| 151 | }}} |
| 152 | |
| 153 | Build DDC locally and run all the regression tests. |
| 154 | |
| 155 | {{{ |
| 156 | $ make war |
| 157 | }}} |
| 158 | |
| 159 | The flow fusion tests are in `$DDC/test/ddc-main/60-CoreFlow` |
| 160 | |
| 161 | {{{ |
| 162 | $ cat test/ddc-main/60-CoreFlow/30-Scalar/20-Map/Test.dcx |
| 163 | $ cat test/ddc-main/60-CoreFlow/30-Scalar/20-Map/Test.stdout.check |
| 164 | }}} |
| 165 | |
| 166 | We can also run individual tests manually. |
| 167 | |
| 168 | {{{ |
| 169 | $ bin/ddci-core test/ddc-main/60-CoreFlow/30-Scalar/20-Map/Test.dcx |
| 170 | }}} |
| 171 | |