Re: [Haskell-cafe] Parallel foldl doesn't work correctly

2009-12-12 Thread Michael Lesniak
Hello,

> This compiles and if I monitor my CPUs it starts to use both cores, but
> after approx 10 seconds, one core drops to low rate (I'm using a 2 core
> machine).
Just a shot in the dark: what OS are you using? I have had some
problems with GHC 6.10.4 and Ubuntu Karmic Koala{1[, which are fixed
for me in GHC 6.12 RC1.

- Michael

[1] 
http://www.mlesniak.com/2009/12/01/ghc-6-12-rc1-and-ubuntu-9-10-karmic-koala/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Parallel foldl doesn't work correctly

2009-12-11 Thread Philip Beadling
Hi,

Can anyone put me right here.  I am trying to use a setup similar to
parMap to spark each valuation in a list in parallel, where the
resulting (evaluated) list is folded to produce a final single result.

Having done the obligatory google, I modified a few common examples to
give:

pfoldl f acc xs =  foldl' f acc (xs `using` parList rwhnf)


This compiles and if I monitor my CPUs it starts to use both cores, but
after approx 10 seconds, one core drops to low rate (I'm using a 2 core
machine).

The end result is that -N2 is actually a bit slower than -N1!

I'm guessing I haven't grasped the concept properly - although as map is
just 'foldl (+) 0' I'm at a loss to see why this approach wouldn't work
given it is pretty similar to parMap - could anyone point out what I'm
missing?

If it's any use the context of the code is below.

Many thanks!


Phil.


mc :: MonteCarloUserData -> [[Double]] -> Double
mc userData rndss = 
  existentialResult (pfoldl f existenAvg rndss) $ numOfSims userData
where f   = flip $ existentialCombine . payOff' .
expiryValue 
  payOff' = existentialPayOff userData
  expiryValue = foldl' (existentialEvolve userData) (stock
userData)
  existenAvg  = averager userData

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe