Cilk/Cilk++

Robert Jacques sandford at jhu.edu
Mon Aug 11 22:05:21 PDT 2008


On Mon, 11 Aug 2008 18:20:25 -0700, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Robert Jacques:
>> Cilk is a less flexible (and also probably less efficient) version of
>> futures/promises.
>
> I don't know how much efficient is one compared to the other, from the  
> site and articles efficiency seems "acceptable". And sometimes less  
> flexible things are simpler to use, and this Cilk seems already getting  
> difficult enough for me.
>
> Bye,
> bearophile

On their own, futures don't require work stealing (inherently greedy), so  
they have less overhead. (I think) They also can be library implemented  
and don't require compilier changes.
As for simplicity compare

cilk int fib (int n)
{
      if (n < 2) return n;
      else
      {
         int x = spawn fib (n-1);
         int y = spawn fib (n-2);
         sync;
         return (x+y);
      }
}

with

int fib (int n)
{
      if (n < 2) return n;
      else
      {
         auto x = future!(fib)(n-1);
         auto y = future!(fib)(n-2);
         return (x+y);
      }
}



More information about the Digitalmars-d mailing list