The second illustration is a bad usage of cilk_spawn because it created a thread of control that is useless.
This comment was marked helpful 0 times.
drayson
Would the second example really be that much slower? It seems like the thread that's doing nothing would just immediately block on cilk_sync and not be awoken until the other threads have finished, which should involve only very minimal overhead...
This comment was marked helpful 0 times.
paraU
I don't think case 2 is bad because its aim is just to mark a place to sync all the threads. It will not waste a thread because of stealing. Without the continuation, it's hard to tell the compiler when to sync all the spawned threads.
This comment was marked helpful 0 times.
crs
I don't see why it would be harder for the compiler to see when to sync all the threads if we do not leave the main thread idle. I think whether case 2 is bad depends on the task.
The second illustration is a bad usage of
cilk_spawn
because it created a thread of control that is useless.This comment was marked helpful 0 times.
Would the second example really be that much slower? It seems like the thread that's doing nothing would just immediately block on cilk_sync and not be awoken until the other threads have finished, which should involve only very minimal overhead...
This comment was marked helpful 0 times.
I don't think case 2 is bad because its aim is just to mark a place to sync all the threads. It will not waste a thread because of stealing. Without the continuation, it's hard to tell the compiler when to sync all the spawned threads.
This comment was marked helpful 0 times.
I don't see why it would be harder for the compiler to see when to sync all the threads if we do not leave the main thread idle. I think whether case 2 is bad depends on the task.
This comment was marked helpful 0 times.