[Haskell-cafe] Parallelism on concurrent?
mnislaih at gmail.com
Tue Mar 13 13:00:44 EDT 2007
On 13/03/2007, at 17:46, Jefferson Heard wrote:
> Simon will probably chime in on it as well, but his paper on the
> subject is
> the best there is:
It does work in GHC 6.6 very nicely.
You can try it with the following naive fib function, extracted from
the paper mentioned above:
main = do
(x:_) <- getArgs
print$ pfib (read x)
pfib 0 = 1
pfib 1 = 1
pfib n = n1 `par` n2 `seq` n1+n2+1
where (n1,n2) = (pfib(n-1), pfib(n-2))
pep:~/code/snippets/Parallelism$ ghc --make -O Main -threaded
pep:~/code/snippets/Parallelism$ time src/Main 33
pep:~/code/snippets/Parallelism$ time src/Main 33 +RTS -N2
Got a speedup of 100%, and didn't use threads at all. Yay!
More information about the Haskell-Cafe