[Haskell-cafe] Parallelism on concurrent?

Dusan Kolar kolar at fit.vutbr.cz
Tue Mar 13 13:10:11 EDT 2007


Yes, it works for operator /par/. That's what I've reported. But should 
it work for forkIO and forkOS? Could anybody give more detailed answer 
than yes, no? :-) (Link to the Web is OK.)

BTW, thanks for the link to the paper (moreover, I can see, that 
googling over haskell.org is not sufficient ;-) ).

Regards,

  Dusan


Pepe Iborra wrote:
> 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:
>>
>> http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz
>
> 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:
>
> \begin{code}
> import Control.Parallel
> import System.Environment
> import Fib
>
> 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))
> \end{code}
>
> pep:~/code/snippets/Parallelism$ ghc --make -O Main -threaded
>
> pep:~/code/snippets/Parallelism$ time src/Main 33
> 11405773
>
> real    0m1.444s
> user    0m1.343s
> sys     0m0.020s
>
> pep:~/code/snippets/Parallelism$ time src/Main 33 +RTS -N2
> 11405773
>
> real    0m0.764s
> user    0m1.367s
> sys     0m0.030s
>
>
>
> Got a speedup of 100%, and didn't use threads at all. Yay!
>
> pepe
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

-- 

 Dusan Kolar            tel: +420 54 114 1238
 UIFS FIT VUT Brno      fax: +420 54 114 1270
 Bozetechova 2       e-mail: kolar at fit.vutbr.cz
 Brno 612 66
 Czech Republic

--



More information about the Haskell-Cafe mailing list