On 6 Jan 2011 20:45, "Cédric Beust ♔" <[email protected]> wrote: > > > > On Thu, Jan 6, 2011 at 12:37 PM, Ricky Clarkson <[email protected]> wrote: >> >> All it takes is for the compiler to know what operations are >> side-effect-ful and it can do all the necessary analysis. > > > It's still not enough: the loop might still be parallelizable even though it's performing side effect operations. > >> >> So, for instance, it's perfectly doable without any hints for Haskell > > > Are you sure? Remember: the only important factor here is whether the operations can be safely performed out of order. >
Got it exactly! You can be certain that any loop is safely parallelizable so long as no iteration depends on a previous one. This coupling can be direct, such as the addition of values in calculating the fibbonacci sequence (where integer addition exhibits referential integrity), or through side effects, such as printing and list to the console. Haskell helps here by ensuring a lack of side effects, so it *is* relevant. If iterations only depend on their index, then you can generate a list of indices first, and transform said list to output values in parallel. Take the example of printing to the console, the output lines could all be generated simultaneously and only printed afterwards, this shows how avoiding side effects helps concurrency. It's even possible to go further than this. By using a fork-join approach, lines could also be concatenated in parallel, then printed in a single operation. This is the sort of thing that functional languages can optimise automatically, using monad composition laws to prove when it's safe to parallelize in such a fashion, and doing so by manipulating the AST as an algebraic construct. But that's, admittedly, getting into very advanced territory. > -- > Cédric > > > -- > You received this message because you are subscribed to the Google Groups "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to [email protected]<javaposse%[email protected]> . > For more options, visit this group at http://groups.google.com/group/javaposse?hl=en. -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
