[Haskell-cafe] Parallel compilation and execution?
michael rice
nowgate at yahoo.com
Fri May 27 14:20:44 CEST 2011
Oops! Guess I'm going to have to refine my searching techniques. Thanks, Simon.
Michael
--- On Fri, 5/27/11, Simon Marlow <marlowsd at gmail.com> wrote:
From: Simon Marlow <marlowsd at gmail.com>
Subject: Re: Parallel compilation and execution?
To: "michael rice" <nowgate at yahoo.com>
Cc: "David Virebayre" <dav.vire+haskell at gmail.com>, "Daniel Fischer" <daniel.is.fischer at googlemail.com>, haskell-cafe at haskell.org
Date: Friday, May 27, 2011, 7:08 AM
On 26/05/2011 14:32, michael rice wrote:
> Fair question. I copied the parallel version from:
>
> <http://www.haskell.org/ghc/docs/6.6/html/users_guide/lang-parallel.html>
> http://www.haskell.org/ghc/docs/6.6/html/users_guide/lang-parallel.html
That is the User Guide for GHC 6.6, incidentally. If you're using a
later version of GHC (highly recommended especially for parallel stuff),
then you should look at the docs for your version.
Cheers,
Simon
>
> <http://www.haskell.org/ghc/docs/6.6/html/users_guide/lang-parallel.html>but
> pulled the non-parallel version from a text.
>
> Michael
>
>
> --- On *Thu, 5/26/11, David Virebayre /<dav.vire+haskell at gmail.com>/* wrote:
>
>
> From: David Virebayre <dav.vire+haskell at gmail.com>
> Subject: Re: [Haskell-cafe] Parallel compilation and execution?
> To: "michael rice" <nowgate at yahoo.com>
> Cc: haskell-cafe at haskell.org, "Daniel Fischer"
> <daniel.is.fischer at googlemail.com>
> Date: Thursday, May 26, 2011, 8:56 AM
>
>
>
> 2011/5/26 michael rice <nowgate at yahoo.com
> </mc/compose?to=nowgate at yahoo.com>>
>
> Thank, Daniel
>
> Multiple threads are in evidence in my system monitor, but I
> wonder why I'm getting two different answers, one twice the
> other. The first is the parallel solution and the second is the non.
>
>
> Why do you add n1+n2+1 in the parallel program, but only n1+n2 in
> the non-parallel one ?
>
>
> Michael
>
> ===========
>
> {-
> import Control.Parallel
>
> nfib :: Int -> Int
> nfib n | n <= 1 = 1
> | otherwise = par n1 (pseq n2 (n1 + n2 + 1))
> where n1 = nfib (n-1)
> n2 = nfib (n-2)
> -}
>
> nfib :: Int -> Int
> nfib n | n <= 1 = 1
> | otherwise = nfib (n-1) + nfib (n-2)
>
> main = do putStrLn $ show $ nfib 39
>
> =============
>
> [michael at hostname ~]$ ghc --make -threaded nfib.hs
> [1 of 1] Compiling Main ( nfib.hs, nfib.o )
> Linking nfib ...
> [michael at hostname ~]$ ./nfib +RTS -N3
> 204668309
> [michael at hostname ~]$ ghc --make nfib.hs
> [1 of 1] Compiling Main ( nfib.hs, nfib.o )
> Linking nfib ...
> [michael at hostname ~]$ ./nfib
> 102334155
> [michael at hostname ~]$
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110527/1a89d655/attachment.htm>
More information about the Haskell-Cafe
mailing list