What is the irght way to compute Fibonacci using cilk?

While I’m learning cilk, I countered with 2 opposite examples:
1. From intel:
enter link description here

  1. from wiki (or other examples in the net):
    enter link description here

The oppposite lies on those 2 lines:

x = spawn fib (n-1);
y = spawn fib (n-2);

The first site says: “You do not need to add a cilk_spawn attribute to the second recursive call to fib() because that will create an empty continuation”

  1. I dont understand why ?
  2. What is the right way ? (using 2 spawn commands or just one ? )


Source: c++

Leave a Reply