News for hackers. Stuff that matters.
Re:Clio: A functional, distributed programming language that... by throwaway4good on Thursday March 18, 2021 @09:22AM (#26502373)
Really? Can you expand on that? I have seen Fibonacci being the poster child of the usefulness of memoization and maybe tail recursion, but never parallelization.
Re:Clio: A functional, distributed programming language that... by chrisseaton on Thursday March 18, 2021 @09:43AM (#26502594)
> I have seen Fibonacci being the poster child of the usefulness of memoization and maybe tail recursion, but never parallelization.

That baffles me. I think I've hardly read a paper on parallel functional programming that doesn't start with fib.

Here's example that agrees that it's the hello-world of parallelisation.

https://wiki.haskell.org/Haskell_for_multicores

It's trivial for a compiler to automatically parallelise it - for every binary operator evaluate the two operands in parallel - done.

Re:Clio: A functional, distributed programming language that... by johnday on Thursday March 18, 2021 @10:52AM (#26503295)
The reason `fib` is a useful benchmark here is not because `fib` is an inherently parallel problem, but because the functionality is obvious and it's easy to parallelise.

Computing fib with memoisation from 1 will certainly be faster than (parallel) recursion without memoisation and data sharing.

Re:Clio: A functional, distributed programming language that... by firebacon on Thursday March 18, 2021 @11:06AM (#26503444)
Interesting to consider the total complexity of that approach though.

An iterative fibonacci solution runs in linear time. Calculating the N'th fibonacci number requires O(N) serial operations.

A fully parallel, recursive solution without memoization requires that each value in the sequence is computed more than once. Consider the example of fib(4):

   fib(4) = fib(3) + fib(2)
   fib(3) = fib(2) + fib(1)
   fib(2) = fib(1) + fib(0)
You can see, that if we run this in parallel, the value of fib(1) has to be calculated twice. As the tree of operation branches out, more and more duplicate calculations are required.

A quick google suggests that the time complexity of the recursive approach is O(2^N).

Re:Clio: A functional, distributed programming language that... by chrisseaton on Thursday March 18, 2021 @11:15AM (#26503540)
> An iterative fibonacci solution runs in linear time.

Absolutely nobody is under the impression that the naive parallel implementation of fib is actually useful code or the most efficient way to do it. You're missing the point if you're suggesting a different way to do it in the first place.

It's just something to use as a running example... like on the original article this whole thread is about.

Re:Clio: A functional, distributed programming language that... by SamBam on Thursday March 18, 2021 @01:06PM (#26504880)
Ok, but it's a bit odd that you kept reacting with incredulity at people not knowing that fib was THE parallel example to know, and then it turns out it's a poor example because synchronous fib with memoization (which is the way many people learn it in any early CS class, and which wouldn't be possible async) is so much faster.

I think maybe if there hadn't been such a vibe of "what, you don't know X?!?" then it would have just been an interesting fact to mention that parallelization demos often use fib, because it's an easy example to grok (though a confusing one if you already understand the faster method).