I\'m trying to learn how to use the Control.Parallel
module, but I think I didn\'t get it right.
I\'m trying to run the following code (fibs.hs).>
Re (1): par
allows a
to be computed in another thread. I am guessing here, but I think pseq
behaves much like a seq
: that it forces the first result to be computed first (well, seq
isn't guaranteed to do this, but in practice on GHC it does). So in this case, the computation of a
is forked off as one thread, and the other thread computes b
and then sums a
and b
.
Re (2): This is a pretty trivial computation being forked off to other threads; it's probably just as fast for the cpu to just calculate it itself. I'm betting the overhead of threads is hurting almost as much as helping for this simple computation.