问题描述
我想知道OpenMP任务队列的任务调度是如何执行的.
I would like to know how the task scheduling of the OpenMP task queue is performed.
这里我读到,默认情况下,OpenMP强制采用广度优先的调度程序,并且他们对FIFO与LIFO进行了一些测试,但是他们没有说默认值.由于我只有一个线程(我使用单个指令)来创建多个任务,因此比较它们的广度优先与工作优先的调度没有任何意义.
Here I read that, by default, OpenMP imposes a breadth-first scheduler and that they did some tests FIFO vs. LIFO, but they don't say anything about the default. Since I only have a single thread (I use the single directive) creating multiple tasks, I don't think it makes any sense comparing their breadth-first vs work-first scheduling.
那么,默认的FIFO还是LIFO?可以更改它吗?
So, is the default FIFO or LIFO? And is it possible to change it?
谢谢
推荐答案
摘要版本
即使标准,OpenMP中的任务调度也是由实现定义的对算法施加了一些限制.如果您需要操纵调度程序,则搜索的地方就是您要定位的特定OpenMP实现.
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.
定义所有任务调度机制的基本概念是任务调度点的概念(请参阅第2.11.3节):
The basic concept upon which all the task scheduling machinery is defined is that of task scheduling point (see section 2.11.3):
在下面的注释中,他们对预期行为(强调我的行为)进行了更广泛的解释:
In the notes below they give a broader explanation of what should be the expected behavior (emphasis mine):
正确的程序必须与所有程序正确一致地运行 与规则兼容的可想象的调度顺序 以上 ...
A correct program must behave correctly and consistently with all conceivable scheduling sequences that are compatible with the rules above ...
该标准还指定了隐含任务安排点的位置:
遇到一个线程时,
和做什么:
and what a thread may do when it meets one of them:
它明确地说:
为不同的遵循行为留出空间.它仅施加四个约束:
leaving space for different conforming behaviors. It only imposes four constraints:
- 包含的任务在生成任务后立即执行.
- 新的绑定任务的调度受当前绑定到线程的任务区域集约束,而不是 悬浮在障碍区域.如果此集合为空,则任何新的绑定任务 可能是预定的.否则,只有在以下情况下才可以安排新的捆绑任务: 这是集合中每个任务的后代任务.
- 从属任务必须在满足其任务依赖关系后才能安排.
- 当由包含if子句的构造生成显式任务时,如果该子句的表达式求值为false,则前一个 约束已经满足,任务将在之后立即执行 任务的生成.
- 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.
这篇关于OpenMP任务计划策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!