You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
supercooldave edited this page Dec 8, 2014
·
6 revisions
Here is a tentative fibonacci number calculation in Encore using a
strawman task library design:
class Fib
def fib(n:int) : int
if n < 2 then n else
let
x = 0
y = 0
in {
finish {
async { fib(n - 1) }
async { fib(n - 2) }
}
x + y
}
This uses X10 style async and finish which becomes less
elegant with the way we handle local variables. In any case, I am
proposing to push async and finish primitives. Here is how we
could write the program in a better way using a let-like finish
construct:
class Fib
def fib(n:int) : int
if n < 2 then n else
finish
x = async fib(n - 1)
y = async fib(n - n)
in
x + y
One important question is how to integrate with the actor-driven
parallelism of PonyRT. The following is a strawman proposal for
this:
Dave's comment
My feeling was that the task lib was something that went on under the hood, as the target of (some) running closures and the party types.
The core above code could be expressed something like, assuming that reduce exists:
reduce (+) (fib (n - 1) | fib n)
or, synchronising first, then calling sequential foldl: