Difference between revisions of "Concurrency"

From HaskellWiki
Jump to navigation Jump to search
 
Line 49: Line 49:
 
* http://www-i2.informatik.rwth-aachen.de/~stolz/dhs/
 
* http://www-i2.informatik.rwth-aachen.de/~stolz/dhs/
 
* http://www.informatik.uni-kiel.de/~fhu/PUBLICATIONS/1999/ifl.html
 
* http://www.informatik.uni-kiel.de/~fhu/PUBLICATIONS/1999/ifl.html
  +
  +
----

Revision as of 13:45, 20 January 2006

Concurrent programming in GHC

This page contains notes and information about how to write concurrent programs in GHC.

Please feel free to add stuff here (Edit page link at the bottom).

Starting points


Using concurrency in GHC

  • The GHC manual gives a few useful flags that control scheduling (not usually necessary) RTS options.


Multiprocessor GHC

As of version 6.5, GHC supports running programs in parallel on an SMP or multi-core machine. How to do it:

  • All code currently has to be built using the -smp switch, including the libraries. If you downloaded a binary snapshot, then you already have the required libraries. If you build GHC from source, you need to add

GhcLibWays += s

to the file mk/build.mk in the build tree before building.

  • Compile your program with -smp
  • Run the program with +RTS -N2 to use 2 threads, for example. You should use a -N value equal to the number of CPU cores on your machine (not including Hyper-threading cores).
  • Concurrent threads (forkIO and forkOS) will run in parallel, and you can also use the par combinator and Strategies from the Control.Parallel.Strategies module to create parallelism.
  • Use +RTS -sstderr for timing stats.


Links to related work on parallel and distributed Haskell (many based on GHC)