runhaskell a parallel program
marlowsd at gmail.com
Thu May 7 09:24:54 EDT 2009
On 07/05/2009 11:27, Neil Mitchell wrote:
>>> If however I run it with runhaskell Test.hs +RTS -N2 I get told the
>>> -N2 flag isn't supported. Is there a way to runhaskell a program on
>>> multiple cores? Is this a bug that it doesn't work, a feature request
>>> I'm making, or is there some trick to getting it working I haven't
>>> thought of? I'll raise a bug report if that turns out to be the right
>> As a workaround you could use 'ghc -e main foo.hs +RTS -N2'.
> That works great :-) Perhaps this trick should be documented? I
> thought runhaskell was just sugar over ghc -e, so couldn't it share
> the same mechanism?
>> What's interesting to me is whether the byte-code interpreter will work right with +RTS -N2
> Isn't ghc -e using the byte-code interpreter?
Yes; apparently it "works", though we still haven't stress-tested it
running real parallel programs using GHCi with +RTS -N2.
>> Still, parallelism
>> is about performance, and if you want performance you should start by
>> compiling your program.
> This is a test framework that spawns system commands. My guess is the
> Haskell accounts for a few milliseconds of execution per hour. Running
> two system commands in parallel gives a massive boost.
That still doesn't explain why you need +RTS -N2. You can spawn
multiple processes by making multiple calls to runProcess or whatever.
If you want to wait for multiple processes simultaneously, compile with
-threaded and use forkIO.
> A related question I wanted to ask. Is there any way to have my
> Haskell program support -j3, which is equivalent to +RTS -N3 -RTS. At
> the moment I've set this up with a shell script to translate the -j3,
> but a nicer method would be preferable. Even something as sledgehammer
> like as restartWithNProcessors :: Int -> IO (), which aborted the
> program entirely and restarted main with a completely fresh heap but a
> given number of processors.
We don't have anything like that right now. Personally I think the
shell script method is quite reasonable.
More information about the Glasgow-haskell-users