runhaskell a parallel program
marlowsd at gmail.com
Thu May 7 06:12:51 EDT 2009
On 06/05/2009 17:19, Neil Mitchell wrote:
> I've got a program which I'd like to run on multiple threads. If I
> compile it with ghc --make -threaded, then run with +RTS -N2 it runs
> on 2 cores very nicely.
> 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
runhaskell is picking up the +RTS options instead of giving them to GHC
itself. Unfortunately there isn't a good way to pass these options to
GHC, because it is the GHC runtime interpreting them rather than
runhaskell itself. Trying the GHCRTS environment variable doesn't work,
because runhaskell isn't compiled with -threaded so it rejects -N2.
As a workaround you could use 'ghc -e main foo.hs +RTS -N2'.
What's interesting to me is whether the byte-code interpreter will work
right with +RTS -N2. It's not disabled, and in theory there's no good
reason why it shouldn't work, but it hasn't been tested. Still,
parallelism is about performance, and if you want performance you should
start by compiling your program.
More information about the Glasgow-haskell-users