I would like to know how the task scheduling of the OpenMP task queue is performed
Abstract version
Task scheduling in OpenMP is implementation defined, even though the standard imposes some restrictions on the algorithm. Should you need to manipulate the scheduler, the place to search is the particular OpenMP implementation you are targeting.
The long tale
The basic concept upon which all the task scheduling machinery is defined is that of task scheduling point (see section 2.11.3):
Whenever a thread reaches a task scheduling point, the implementation
may cause it to perform a task switch, beginning or resuming execution
of a different task bound to the current team.
In the notes below they give a broader explanation of what should be the expected behavior (emphasis mine):
Task scheduling points dynamically divide task regions into parts.
Each part is executed uninterrupted from start to end. Different parts
of the same task region are executed in the order in which they are
encountered. In the absence of task synchronization constructs, the
order in which a thread executes parts of different schedulable tasks
is unspecified.
A correct program must behave correctly and consistently with all
conceivable scheduling sequences that are compatible with the rules
above
...
The standard also specifies where task scheduling points are implied:
- the point immediately following the generation of an explicit task
- after the point of completion of a task region
- in a taskyield region
- in a taskwait region
- at the end of a taskgroup region
- in an implicit and explicit barrier region
- the point immediately following the generation of a target region
- at the beginning and end of a target data region
- in a target update region
and what a thread may do when it meets one of them:
- begin execution of a tied task bound to the current team
- resume any suspended task region, bound to the current team, to which it is tied
- begin execution of an untied task bound to the current team
- resume any suspended untied task region bound to the current team.
It says explicitly, though:
If more than one of the above choices is available, it is unspecified
as to which will be chosen.
leaving space for different conforming behaviors. It only imposes four constraints:
- An included task is executed immediately after generation of the task.
- Scheduling of new tied tasks is constrained by the set of task regions that are currently tied to the thread, and that are not
suspended in a barrier region. If this set is empty, any new tied task
may be scheduled. Otherwise, a new tied task may be scheduled only if
it is a descendent task of every task in the set.
- A dependent task shall not be scheduled until its task dependences are fulfilled.
- When an explicit task is generated by a construct containing an if clause for which the expression evaluated to false, and the previous
constraints are already met, the task is executed immediately after
generation of the task.
that every scheduling algorithm must fulfill to be considered conforming.