Multicore & Synchronization

When 64 cores continuously update one shared counter with atomic instructions, adding cores does not speed things up. What is the main reason?

  1. AAtomic instructions can execute on only one core
  2. BWith many cores the counter value automatically gets smaller
  3. CThe counter's cache line moves from core to core, so updates proceed only one at a time
Show answer and explanation

Answer: C. The counter's cache line moves from core to core, so updates proceed only one at a time

An atomic update requires the core to own the line in the M state, so the line migrates to another core on every update. Each migration costs inter-core communication time, and only one core can update at a time, so adding cores just lengthens the wait. The fix is to reduce shared writes, for example by having each core count locally and summing at the end.

  • A. Any core can execute them.
  • B. The value does not change by itself.
  • C. Correct. Contention for the line determines performance.
Practice this topic Back to topic

More Multicore & Synchronization questions

  1. Which describes a NUMA (non-uniform memory access) system?
  2. Under the first-touch policy common on Linux NUMA systems (a page is placed in the memory of the node where the thread first writing it runs), what should programmers watch out for?
  3. Which is NOT a reason a parallel program fails to scale as cores are added?
  4. When splitting loop iterations among threads, which division suits iterations whose costs vary widely?
  5. When several threads sum all elements of an array, which approach performs well?