[Haskell-cafe] GHC threaded runtimes and pure functions

Gregory Propf gregorypropf at yahoo.com
Wed Sep 16 10:34:49 EDT 2009


That makes sense.  So maybe I should split my mapping into two parallel ones or however many CPUs there are using par.

--- On Wed, 9/16/09, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:

From: Bulat Ziganshin <bulat.ziganshin at gmail.com>
Subject: Re: [Haskell-cafe] GHC threaded runtimes and pure functions
To: "Gregory Propf" <gregorypropf at yahoo.com>
Cc: "Haskell-Cafe" <haskell-cafe at haskell.org>
Date: Wednesday, September 16, 2009, 6:29 AM

Hello Gregory,

Wednesday, September 16, 2009, 5:17:01 PM, you wrote:

no. additional threads are launched for i/o system and, as you
requested by -N2 for haskell workload. but ghc don't auto-parallelize
your code. it's a bit too hard, since making too much threads (e.g.
one for every addition) will make bookkeeping too heavy and it's
impossible to automatically deduce how much operations each
computation will require. instead, you are provided with 'par'
primitive to show compiler explicitly what parts to run in parallel

> One of the things I liked about Haskell was the notion of pure
> functions and the fact that they can be, in theory, automatically
> parallelized on multicore hardware. I think this will become a huge
> deal in a few years as cores multiply.  My question is simply this:
> under GHC is this what really happens with, say a mapping over a
> pure function.  Yes, I compiled with --threaded and am using the
> +RTS -N2 options on my dual core machine.  Here's the code I wrote
> as a speed test.  It just doesn't seem any faster with -N2.  Using
> the ps command I found that multiple threads are indeed launched
> (this is Linux) but all but one show as being in a state of waiting
> for some event to finish (the ps output flags them all 'Sl'.




> main = do rg <- getStdGen
>           let rs = take  10000000 $ randomRs (1::Int,100000::Int) rg
>               rs'= map (\n -> n*n) rs
>           print rs'

>   


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/b72e0223/attachment.html


More information about the Haskell-Cafe mailing list