[Haskell-beginners] parallel program in haskell in 5 steps

Jack Kennedy jack at realmode.com
Tue May 5 15:19:55 EDT 2009


In step 4 of Haskell in 5 Steps [
http://haskell.org/haskellwiki/Haskell_in_5_steps],
a parallel program is given. I changed it very slightly so it would run a
long time (see below).

It compiles and runs but my CPU meter is barely above 50%.  I have a dual
core processor.
What in the world would keep this program from completely saturating the
CPU?

import Control.Parallel

main = a `par` b `pseq` print (a + b)
    where
        a = ack 4 10
        b = ack 4 10

fac 0 = 1
fac n = n * fac (n-1)

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

fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090505/2d831639/attachment.htm


More information about the Beginners mailing list