runhaskell a parallel program

Neil Mitchell ndmitchell at
Thu May 7 06:27:34 EDT 2009


>> 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
>> thing.
> 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?

> 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.

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.



More information about the Glasgow-haskell-users mailing list