Multicore & Synchronization

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?

  1. AUnder first touch pages are placed on random nodes
  2. BAll page placements are fixed when malloc is called
  3. CIf one thread zero-initializes a large array, all of it lands on one node, and threads on other nodes end up using far memory
Show answer and explanation

Answer: C. If one thread zero-initializes a large array, all of it lands on one node, and threads on other nodes end up using far memory

malloc alone assigns no physical pages; the page fault on first write places each page in the memory of the node where the writing thread runs. So if one thread does the initialization, the whole array gathers on that node, and in the parallel computation much of each thread's portion is in far memory. Initializing in parallel with the same division of work as the computation puts each portion near its thread.

  • A. It is not random; the first thread to touch decides.
  • B. Placement happens at first write, not at malloc.
  • C. Correct. Initialization should be split among the threads that later use the data.
Practice this topic Back to topic

More Multicore & Synchronization questions

  1. Which is NOT a reason a parallel program fails to scale as cores are added?
  2. When splitting loop iterations among threads, which division suits iterations whose costs vary widely?
  3. When several threads sum all elements of an array, which approach performs well?
  4. What is a characteristic of a reader-writer lock?
  5. What is the most suitable use of a counting semaphore?