Parallel Haskell on MultiCores and Clusters: Software Setup
The main pieces of software need for the exercises in this course are:
- GHC the Glasgow Haskell Compiler
- Several (sequential) visualisation tools, that are part of GHC
- threadscope a parallel visualisation library
There are several alternatives how to run the exercises, each explained below, pick the one that is most convenient to you.
You can get all sources for the exercises from a local git repository, if you work on ghc.di.unimi.it:
git clone /home/hwloidl/www/hackspace/Milan15If you want to download these to your laptop you need to access the git repo through ssh like this (inserting your username):
git clone ssh://<USERNAME>@ghc.di.unimi.it:/home/hwloidl/www/hackspace/Milan15You can also download the files one-by-one, following the links on the Exercises page.
For quizes go to the web page http://www.socrative.com and enter the room number: ab8ec07e
Running the exercises on ghc.di.unimi.it
If you can login to ghc.di.unimi.it you don't have to install anything, all pieces of software are already installed. To make sure that threadscope is in your path, and that you can call it by its name, rather than by the full path, do:
> export PATH=$PATH:/home/hwloidl/.cabal/bin
To check the configuration do the following:
# check that all programs are in the path > which ghc /bin/ghc > ghc --version The Glorious Glasgow Haskell Compilation System, version 7.6.3 > which threadscope /home/hwloidl/.cabal/bin/threadscope # test a hello world program > echo "main = putStrLn \"Hello world\"" > hello.hs > ghc -o hello hello.hs [1 of 1] Compiling Main ( hello.hs, hello.o ) Linking hello ... ghc[111](4.2)> ./hello Hello world
Running the exercises on your laptop using a docker image
You can use a docker image, which is in essence a virtual machine pre-configured with all software needed for these exercises. Once installed and started, you work as if on a separate machine.
Start a docker container like this:
sudo docker run -i -t -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/$HOME/.Xauthority -v $HOME/GPH:$HOME/GPH --net=host hwloidl/milan15_gph_ubuntu:devel
Inside the container, create a user with the same name and id as on your laptop (use the command id to print both). This is needed if you want to use threadscope for visualisation. For example, in my setup I do the following (as root):
root> groupadd -g 1701 hwloidl root> useradd -u 1701 -g 1701 -G sudo -s /bin/bash -m hwloidl root> passwd hwloidl
This container already has a user milan15, with the Haskell examples in the directory GPH. Use this this user to compile and run your programs like this (starting as root):
# su -l milan15 > cd GPH/ > ghc -O2 -rtsopts -threaded -eventlog -o parsum_thr_l parsum.hs > ./parsum_thr_l 90M 100 +RTS -N6 -ls Workers: 6 Running ... done parallel sum up to 90000000 using 6 cores is OK? True
To visualise the data with threadscope you need to log in as the user, that you created above:
> su -l hwloidl > cd GPH > which threadscope /home/milan15/.cabal/bin/threadscope > cd ~milan15/GPH > threadscope parsum_thr_l.eventlog
Running the exercises directly on your laptop
Details will follow
Troubleshooting
If you can't find threascope, add this to your path:
> export PATH=$PATH:/home/milan15/.cabal/bin
If the compiler can't find the Control.Parallel.Strategies module, do the following:
> cabal update > cabal install deepseq > cabal install parallel