pure functions and the parallel evaluation of reduce-like operations
Jim Mayer
jim at pentastich.org
Sat Nov 27 14:10:17 PST 2010
Doug,
Well, I suspect that 99 percent of programmers will neither know not care
how their floating point calculations are ordered. I'm also quite sure that
anyone trying to invert an ill conditioned matrix will care a lot. But
that's just for number crunching, and addition and multiplication are
wonderfully tractable operations.
What about functions that are not associative at all? Then it is not a
matter of determinism but of correctness. Considered List.reduce (#{s, v ->
s * s + v}). This is a pure function but is not associative. (1^ 2 +2)^ 2
+3 is 12, but 1^ 2 +(2^ 2 + 3) is 8.
I also suspect that some operations will be slowed down by parallel
execution because they are gated by the memory subsystem and not the CPU.
My point is that we won't be able to just turn existing functions just into
parallel versions of themselves, and that for operations like
reduce/fold/etc., which are incredibly useful even in single threaded
environments, we may well end up with multiple versions with differing
degrees of allowed parallelism.
-- Jim
On Nov 27, 2010 12:28 PM, "Doug Lea" <dl at cs.oswego.edu> wrote:
More information about the lambda-dev
mailing list