[Haskell-cafe] Showing >100% CPU usage of parallel code

Bulat Ziganshin bulat.ziganshin at gmail.com
Sat Feb 21 10:32:41 EST 2009


Hello Jim,

Saturday, February 21, 2009, 6:17:54 PM, you wrote:

> main = a `par` b `par` c `pseq` print (a + b + c)

two things:
1) that are grouping order? may be,
a `par` (b `par` (c `pseq` print (a + b + c))) ?

2) i recommend you to use 2 *same* computations.
otherwise, it's easily possible that one of them needs much more time
that the rest


>     where
>         a = ack 3 10
>         b = fac 42
>         c = fib 34

> 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)
> --------------------

> Thanks,

> Jim





-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list