Previous | Next --- Slide 54 of 64
Back to Lecture Thumbnails
pslui88

Why are there only 3 threads max? How does cilk know how many threads are allowed to work on the 10 foo() calls?

nickbowman

@pslui88 From what my understanding is based on questions that have been answered on Piazza is that the number of available threads is something that is constrained by available hardware. The cilk constructs we've talked about are similar to ISPC tasks in the sense that they identify pieces of work that can be done in parallel. At runtime, the underlying Cilk implementation will usually instantiate a number of worker threads equal to the number of hardware execution contexts (threads) available on the machine. Then, it does the work of assigning independent, parallelizable pieces of work to different worker threads as diagrammed here. So I think in this example we just assume that the Cilk runtime has access to 3 hardware threads and this initializes 3 threads to collectively do the work of the 10 foo() calls.

Please log in to leave a comment.