Multicore & Synchronization
When splitting loop iterations among threads, which division suits iterations whose costs vary widely?
- AStatic assignment, dividing iterations evenly by count at the start and never adjusting
- BGiving every iteration to a single thread
- CDynamic assignment, where work is split into small chunks and idle threads grab the next chunk
Show answer and explanation
Answer: C. Dynamic assignment, where work is split into small chunks and idle threads grab the next chunk
Static assignment has little overhead, but if iterations differ in cost, the threads that drew heavy parts lag while the rest wait. With dynamic assignment, threads take the next piece of work from a shared counter or similar, so faster threads take on more and the load evens out. Chunks that are too small increase the overhead of fetching work, so their size must be tuned.
- A. Equal counts with unequal costs leave imbalance.
- B. That is not parallelization at all.
- C. Correct. It evens out imbalance automatically.