Monday, April 25, 2011

Multi-Core Haskell on Windows

I've been reading a number of tutorials on Haskell. However, I have not been able to get the compiled application to run on a multicore (I have an Intel Quad Core) on windows (32 bit).

I have tried a number of things:

But no luck.

The compiled application runs 100% on one core only.

Any ideas?

Code:

import Control.Parallel
import Control.Monad
import Text.Printf

fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = l `pseq` r `pseq` l+r
    where
    l = fib (n-1)
    r = fib (n-2)

main = forM_ [0..350] $ \i ->
        printf "n=%d => %d\n" i (fib i)
From stackoverflow
  • Using par instead of pseq seems to fix it.

    cbrulak : are you running windows? Because that didn't do anything for me
  • If vili is correct (I can't test as I don't own any MS boxes), it might be related to this bug

0 comments:

Post a Comment