
Hi, I was toying with the Control.Parallel.Strategies library, but can't seem to get it to actually do anything in parallel! Here's the code: import System.Random import Control.Parallel.Strategies fib :: Int -> Int fib 0 = 1 fib 1 = 1 fib n = fib (n-1) + fib (n-2) main = print $ parMap rnf fib $ take 80 $ randomRs (30,35) (mkStdGen 123) I compile with "-threaded", and run with +RTS -N2 -RTS, but yet it stays at 50% on my dual core machine! I should point out that any manual threading with forkIO does indeed use 100% of the CPU, and this problem happens on my work computer too (Vista on my home computer, XP on the work one). Anything I'm missing here? Thanks, -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862

On Wed, Apr 9, 2008 at 10:22 PM, Justin Bailey
main = print $ parMap rnf fib $ take 80 $ randomRs (30,35) (mkStdGen
2008/4/9 Sebastian Sylvan
: 123) Does the strategy "rwhnf" do it for you?
Justin
Nope! This is GHC 6.8.2 btw, downloaded the binary from the web site, so it's nothing strange. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862

On Wed, Apr 9, 2008 at 2:25 PM, Sebastian Sylvan
Nope!
This is GHC 6.8.2 btw, downloaded the binary from the web site, so it's nothing strange.
On my hyper-threaded CPU, your original code works fine. With -N2, I see 100% CPU. With N1, only 50%. I am also using GHC 6.8.2. Justin

On Wed, Apr 9, 2008 at 10:58 PM, Justin Bailey
On Wed, Apr 9, 2008 at 2:25 PM, Sebastian Sylvan
wrote: Nope!
This is GHC 6.8.2 btw, downloaded the binary from the web site, so it's nothing strange.
On my hyper-threaded CPU, your original code works fine. With -N2, I see 100% CPU. With N1, only 50%. I am also using GHC 6.8.2.
Justin
Hmm, that's curious. I compile with "ghc --make -threaded partest.hs -o par.exe", and then run it with "par.exe +RTS -N2 -RTS". Am I making some silly configuration error? Are you running this on windows? -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862

On Wed, Apr 9, 2008 at 3:03 PM, Sebastian Sylvan
Hmm, that's curious. I compile with "ghc --make -threaded partest.hs -o par.exe", and then run it with "par.exe +RTS -N2 -RTS". Am I making some silly configuration error? Are you running this on windows?
Yep, that's the command line I used and I am running XP. Justin

On Wed, Apr 9, 2008 at 11:10 PM, Justin Bailey
On Wed, Apr 9, 2008 at 3:03 PM, Sebastian Sylvan
wrote: Hmm, that's curious. I compile with "ghc --make -threaded partest.hs -o par.exe", and then run it with "par.exe +RTS -N2 -RTS". Am I making some silly configuration error? Are you running this on windows?
Yep, that's the command line I used and I am running XP.
Justin
That is indeed weird. The only difference seems to be that you have hyperthreading, whereas I have dual cores. But as I mentioned, manual parallelism works (using forkIO)... -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862

sebastian.sylvan:
On Wed, Apr 9, 2008 at 10:58 PM, Justin Bailey <[1]jgbailey@gmail.com> wrote:
On Wed, Apr 9, 2008 at 2:25 PM, Sebastian Sylvan <[2]sebastian.sylvan@gmail.com> wrote: > Nope! > > This is GHC 6.8.2 btw, downloaded the binary from the web site, so it's > nothing strange.
On my hyper-threaded CPU, your original code works fine. With -N2, I see 100% CPU. With N1, only 50%. I am also using GHC [3]6.8.2. Justin
Hmm, that's curious. I compile with "ghc --make -threaded partest.hs -o par.exe", and then run it with "par.exe +RTS -N2 -RTS". Am I making some silly configuration error? Are you running this on windows?
I think its always worth using -O or -O2 too, for what its worth. -- Don

On Fri, Apr 11, 2008 at 10:43 AM, Don Stewart
sebastian.sylvan:
On Wed, Apr 9, 2008 at 10:58 PM, Justin Bailey <[1]jgbailey@gmail.com
wrote:
On Wed, Apr 9, 2008 at 2:25 PM, Sebastian Sylvan <[2]sebastian.sylvan@gmail.com> wrote: > Nope! > > This is GHC 6.8.2 btw, downloaded the binary from the web site, so it's > nothing strange.
On my hyper-threaded CPU, your original code works fine. With -N2, I see 100% CPU. With N1, only 50%. I am also using GHC [3]6.8.2. Justin
Hmm, that's curious. I compile with "ghc --make -threaded partest.hs -o par.exe", and then run it with "par.exe +RTS -N2 -RTS". Am I making some silly configuration error? Are you running this on windows?
I think its always worth using -O or -O2 too, for what its worth.
Yes I've tried both, neither helped. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862

Out of interest, have you tried using parListChunk to break the work into larger pieces? It seems rather unlikely to help with this case as the parts are already pretty large, but perhaps it's worth a shot.
participants (4)
-
Cale Gibbard
-
Don Stewart
-
Justin Bailey
-
Sebastian Sylvan