[Haskell-cafe] testing par with simple program

Paolino paolo.veronelli at gmail.com
Fri Aug 21 13:21:23 EDT 2009


Hi, reading a previous thread I got interested.
I simplified the example pointed by dons in

import Control.Parallel

main = a `par` b  `pseq` print (a + b )
    where
        a = ack 3 11
        b = ack 3 11

ack 0 n = n+1
ack m 0 = ack (m-1) 1
ack m n = ack (m-1) (ack m (n-1))

compiled with
ghc --make prova  -O2 -threaded

timings
paolino at paolino-casa:~$ time ./prova +RTS -N1
32762

real    0m7.031s
user    0m6.304s
sys    0m0.004s
paolino at paolino-casa:~$ time ./prova +RTS -N2
32762

real    0m6.997s
user    0m6.728s
sys    0m0.020s
paolino at paolino-casa:~$

without optimizations it gets worse

paolino at paolino-casa:~$ time ./prova +RTS -N1
32762

real    1m20.706s
user    1m18.197s
sys    0m0.104s
paolino at paolino-casa:~$ time ./prova +RTS -N2
32762

real    1m38.927s
user    1m45.039s
sys    0m0.536s
paolino at paolino-casa:~$

staring at the resource usage graph I can see it does use 2 cores when told
to do it, but with -N1 the used cpu goes 100% and with -N2 they both run
just over 50%

thanks for comments

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


More information about the Haskell-Cafe mailing list