Petr P <petr.mvd <at> gmail.com> writes:

> Is there any reason to use
>   a `par` b `pseq` (a + b)
> instead of
>   a `par` b `par` (a + b)

(better ask this on parallel-haskell?)

> It seems to me that the second variant would work as well: 
> The main thread would block on one of the sparked computations,

I think the main thread would not block at all.
Instead, it would start to evaluate  a  (or  b) right away, 
since (+) is strict, thus duplicating the work of
a spark, and causing the spark to fizzle.

Why does it work in   a `par` b `pseq` a+b ?
I am not even sure - there might be a race condition:
assume that evaluation (to WHNF) of  b (and of  a)  takes a long time,
but  b  (in the main thread) finishes shortly 
before  a  does (in the spark), 
then the spark still fizzles and its work was in vain?

J.W.



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

Reply via email to