Previous | Next --- Slide 39 of 63
Back to Lecture Thumbnails
yey1

I am confused here. In my view it is a FIFO Queue. In the for-loop you push 0, then 1, 2, ... N-1. You will also pop 0 first.

bpr

@yey1, the Cilk queue is double-ended. This sequence of slides is illustrating the two different scheduling policies. What are the advantages to pushing / popping at the same end? What if the local and remote threads have different policies? How should the library implement its work stealing policy?

TJ

@bpr, then how can I understand this

  • If no stealing, execution order is very different than that of program with clik_spawn removed

execution order is different mainly because Thread 0 can pop jobs from both ends?

bpr

@TJ, it could pop jobs from either end. In practice, the local thread treats the work queue as a stack, while the local threads pop from the other end of the queue.

fire

Above comment by @bpr solved my confusion too. For local thread, the recent work added to the queue gonna perform earlier than former added work.

amolakn

Sidenote, regarding the comments above, the Grand Central Dispatch system on iOS manages work blocks in threads this way. Although the blocks will run in parallel, there is a guarantee that the blocks that enter the queue first will begin first, but not necessarily end.