Hello Bryan,

2008/6/4 Bryan O'Sullivan <bos@serpentine.com>:

I intended to write a half chapter or so about parallel programming in
Haskell for the book I'm working on, but I've been coming to the
conclusion that the time is not yet ripe for this.  I hope it will be
helpful if I share my experiences here.

Specifically, I was planning to write about parallel programming in pure
code: use of "par" and programming with strategies.

The most substantial problem is that the threaded RTS in GHC 6.8.2 is
very crashy in the face of "par": about 90% of my runs fail with a
segfault or an assertion failure.  Simon Marlow mentioned that this bug
is fixed, but I've been unsuccessful in building a GHC 6.8.3 release
candidate snapshot so far, so I can't verify this.

When a run does go through, I have found it surprisingly difficult to
actually get both cores of a dual-core system to show activity.  As
there are no tools I can use to see what is happening, I am stumped.  It
is of course quite likely that I am doing something wrong that results
in unexpected dependencies, but I cannot find a means to gaining insight
into the problem.

Although my Google Summer of Code project was not selected, I decided to go ahead and work on the Parallel Profiling Tools for GHC this Summer, with the help of Simon Marlow of course, for my Master's thesis.  The work is nowhere near complete, as I just began working on it a couple of weeks ago.   I was able to run the ParSort.hs program in your original post with my modified version of GHC HEAD that now supports parallel profiling.  Hopefully, by the end of the Summer, Haskell's support for parallel profiling will be vastly improved. 

This is the example test I performed:
ghc -parprof -threaded -o ParSort --make ParSort.hs

time ./ParSort 1000000 +RTS -pN -N6 -RTS
We have 1000000 elements to sort.
Sorted all 1000000 elements.
28.04362s elapsed.

real    0m36.060s
user    0m44.107s
sys    0m0.708s

I have attached an Postscript file containing a graph that visualizes the parallel profiling data from the above test.  A lot of work still needs to be done, but I just wanted to let you know that improvements are expected soon.

Btw, ParSort.hs was taking advantage of both cores on my machine.
Thank you.
__
Donnie Jones