On 18/12/2009 18:31, Marcus D. Gabriel wrote:
Hello,

In Control.Parallel.Strategies, parList is defined as

     parList strat []     = ()
     parList strat (x:xs) = strat x `par` (parList strat xs)

with

     parMap strat f xs = map f xs `using` parList strat.

I have recently found that if I define

     forceParMap strat f xs = map f xs `using` forceParList strat

where

     forceParList strat = foldl (\done ->  (done>||) . strat) ()

then to date, forceParList via forceParMap gives faster results
than parList via parMap.  For example, in one experiment, parMap
with parList run at 0.81 the time of the serial solution whereas
forceParMap with forceParList run at 0.58 the time of the serial
solution.  This is to say, forceParList completed in 0.72 the
time of parList.  So,

1. Why is forceParList faster than parList?
2. Is this generic to the ghc runtime model or a particularity
    of the ghc implementation?

I'm not sure. Your forceParList looks equivalent to parList, unless I'm misreading it.

I recommend trying out the new parallel package, here:

  http://hackage.haskell.org/package/parallel

which has a new implementation of Strategies. The version of parList you quoted above has a space leak problem which may be affecting your results.

Cheers,
        Simon
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to