c++openmpllvm

LLVM OpenMP tasking scheduler


I have started digging into the official codebase to understand how tasks are scheduled on the different runtime threads but it is quite "hard" with no technical documents regarding the scheduling policy.

Do you have any resources to suggest on this topic?


Solution

  • Each thread submits new and ready tasks to its own (de)queue (__kmp_push_task). If a thread is at a task scheduling point, it schedules tasks from its own queue in LIFO order. If no task is in its own queue, the thread will look round robin in other thread's task queue and steal a task in FIFO order(__kmp_steal_task).

    For the classical recursive Fibonacci example this means that each thread will execute a subtree in depth-first order and free threads will steal tasks close to the root of the tree. Therefore, task stealing is a rather rare event. The same behavior also applies for more practical use cases of recursive tasking algorithms like tree traversal algorithms.