Parallel forkOS does not work on ubuntu
hoangta at comp.nus.edu.sg
Wed Dec 10 11:20:54 EST 2008
Thanks Simon for your detail explanation. It does help me as I am new to
Haskell. Btw, I did not use -O option.
On Wed, Dec 10, 2008 at 9:24 PM, Simon Marlow <marlowsd at gmail.com> wrote:
> Hoang Truong wrote:
>> Hi Simon,
>> I tried with forkIO and added another dowork functions but the result is
>> the same: only one core is used, three other cores are idle. Do you have any
>> other suggestions? Is there anything I should take care when installing GHC?
>> I also did try the Wombat.hs from the tutorial, but only one core is used
>> and the times are almost the same.
>> seq sum: 119201850
>> seq time: 20.959932 seconds.
>> par sum: 119201850
>> par time: 20.959547 seconds.
> Your program is suffering from microbenchmarkitis, I'm afraid. There's
> only one spark, which tickles a bug in the scheduler in 6.10.1 and earlier
> (but sometimes doesn't happen due to random scheduling behaviour). Even
> with that fixed, the program uses fib which tickles another bug: when
> optimised, fib doesn't do any allocation, and GHC's scheduler relies on
> allocation happening at regular enough intervals.
> In 6.10.1 we never get to do load-balancing in this example, because fib
> doesn't ever yield control to the scheduler. In HEAD, where we have
> work-stealing and don't rely on the scheduler for load-balancing, the
> load-balancing problem goes away but reveals another problem: the second
> thread wants to GC, but in order to GC it has to synchronise with the other
> running threads, but the other thread is running fib and never yields. We
> can fix this by allowing CPUs to GC independently (which we plan to do), but
> even then you could still run into the same problem because eventually a
> global GC will be required. If you really want to see the program running
> in parallel, turn off -O.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Glasgow-haskell-users